summaryrefslogtreecommitdiff
path: root/src/bin/scripts/t/020_createdb.pl
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-02-27 11:21:07 +0900
committerMichael Paquier <michael@paquier.xyz>2020-02-27 11:21:07 +0900
commit83bd732eb2c83a26db9eefb4595615fa289620a8 (patch)
treeae6f3d4627036c7cf47d4efd7fa5823fd44aa04f /src/bin/scripts/t/020_createdb.pl
parent143152439dc9482b1ae983f2819453e7300eca7f (diff)
createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate
The original coding failed to properly quote those arguments, leading to failures when using quotes in the values used. As the quoting can be encoding-sensitive, the connection to the backend needs to be taken before applying the correct quoting. Author: Michael Paquier Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/20200214041004.GB1998@paquier.xyz Backpatch-through: 9.5
Diffstat (limited to 'src/bin/scripts/t/020_createdb.pl')
-rw-r--r--src/bin/scripts/t/020_createdb.pl26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index c0f6067a923..8df32dba91b 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -3,7 +3,7 @@ use warnings;
use PostgresNode;
use TestLib;
-use Test::More tests => 13;
+use Test::More tests => 22;
program_help_ok('createdb');
program_version_ok('createdb');
@@ -24,3 +24,27 @@ $node->issues_sql_like(
$node->command_fails([ 'createdb', 'foobar1' ],
'fails if database already exists');
+
+# Check quote handling with incorrect option values.
+$node->command_checks_all(
+ [ 'createdb', '--encoding', "foo'; SELECT '1", 'foobar2' ],
+ 1,
+ [qr/^$/],
+ [qr/^createdb: "foo'; SELECT '1" is not a valid encoding name/s],
+ 'createdb with incorrect --lc-collate');
+$node->command_checks_all(
+ [ 'createdb', '--lc-collate', "foo'; SELECT '1", 'foobar2' ],
+ 1,
+ [qr/^$/],
+ [
+ qr/^createdb: database creation failed: ERROR: invalid locale name/s
+ ],
+ 'createdb with incorrect --lc-collate');
+$node->command_checks_all(
+ [ 'createdb', '--lc-ctype', "foo'; SELECT '1", 'foobar2' ],
+ 1,
+ [qr/^$/],
+ [
+ qr/^createdb: database creation failed: ERROR: invalid locale name/s
+ ],
+ 'createdb with incorrect --lc-ctype');