summaryrefslogtreecommitdiff
path: root/src/bin/scripts/t
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-02-27 11:21:00 +0900
committerMichael Paquier <michael@paquier.xyz>2020-02-27 11:21:00 +0900
commit943affb3d1db38ba0960ee9a0666ea2598b78f1f (patch)
tree564e33b98c1c64b782061052a929b3681e31ca80 /src/bin/scripts/t
parent30d5c6bf2e09fe76448e59e9889ab5b38171da34 (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')
-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..d94d4edd901 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: error: "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: error: 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: error: database creation failed: ERROR: invalid locale name/s
+ ],
+ 'createdb with incorrect --lc-ctype');