]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #1978: always give encoding/collate explicitly when creating db
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 7 Nov 2018 14:47:56 +0000 (15:47 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 8 Nov 2018 08:53:13 +0000 (09:53 +0100)
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@proxmox.com>
PMG/DBTools.pm

index 2a132ad209a090134bd9f70f83e68d5d9e837890..24a692a223d2df38e9bdf8c5c4ac92e0c129effa 100644 (file)
@@ -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";