[pmg-devel] [PATCH pmg-api] fix #1978: always give encoding/collate explicitly when creating db
Dominik Csapak
d.csapak at proxmox.com
Wed Nov 7 15:47:56 CET 2018
already existing clusters still have the wrong encoding,
so if a user has a problem with it, they have to either recreate
the slave db with pmgdb delete && pmgdb init,
or remove the slave and add it again after this patch
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PMG/DBTools.pm | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/PMG/DBTools.pm b/PMG/DBTools.pm
index 2a132ad..24a692a 100644
--- a/PMG/DBTools.pm
+++ b/PMG/DBTools.pm
@@ -341,6 +341,19 @@ sub database_column_exists {
return defined($res);
}
+my $createdb = sub {
+ my ($dbname) = @_;
+ postgres_admin_cmd(
+ 'createdb',
+ undef,
+ '-E', 'sql_ascii',
+ '-T', 'template0',
+ '--lc-collate=C',
+ '--lc-ctype=C',
+ $dbname,
+ );
+};
+
sub create_ruledb {
my ($dbname) = @_;
@@ -355,8 +368,7 @@ sub create_ruledb {
# use sql_ascii to avoid any character set conversions, and be compatible with
# older postgres versions (update from 8.1 must be possible)
- postgres_admin_cmd('createdb', undef, '-E', 'sql_ascii', '-T', 'template0',
- '--lc-collate=C', '--lc-ctype=C', $dbname);
+ $createdb->($dbname);
my $dbh = open_ruledb($dbname);
@@ -1146,7 +1158,7 @@ sub init_nodedb {
print STDERR "create new local database\n";
- postgres_admin_cmd('createdb', undef, $dbname);
+ $createdb->($dbname);
print STDERR "insert received data into local database\n";
--
2.11.0
More information about the pmg-devel
mailing list