summaryrefslogtreecommitdiff
path: root/src/bin/scripts
diff options
context:
space:
mode:
authorRobert Haas2022-09-28 14:42:07 +0000
committerRobert Haas2022-09-28 14:42:07 +0000
commit7188b9b0fdbb4dd99915626f171d820a56b98514 (patch)
treee947bb56eebcc21541d93e5a3b51914db5d2efb5 /src/bin/scripts
parenta448e49bcbe40fb72e1ed85af910dd216d45bad8 (diff)
Fix bug in DROP OWNED BY.
Commit 6566133c5f52771198aca07ed18f84519fac1be7 broke the case where the role passed to DROP OWNED BY owns a database. Report by Rushabh Lathia, who also provided a patch, but this patch takes a slightly different approach to fixing the problem. Discussion: http://postgr.es/m/CAGPqQf2vO+nbo=3yAdZ8v26Rbug7bY4YjPaPLZx=L1NZ9-CC3w@mail.gmail.com
Diffstat (limited to 'src/bin/scripts')
-rw-r--r--src/bin/scripts/t/020_createdb.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index 2e712f4fe9..a74bf3b0d8 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -158,4 +158,22 @@ $node->issues_sql_like(
qr/statement: CREATE DATABASE foobar7 STRATEGY file_copy TEMPLATE foobar2/,
'create database with FILE_COPY strategy');
+# Create database owned by role_foobar.
+$node->issues_sql_like(
+ [ 'createdb', '-T', 'foobar2', '-O', 'role_foobar', 'foobar8' ],
+ qr/statement: CREATE DATABASE foobar8 OWNER role_foobar TEMPLATE foobar2/,
+ 'create database with owner role_foobar');
+($ret, $stdout, $stderr) = $node->psql(
+ 'foobar2',
+ 'DROP OWNED BY role_foobar;',
+ on_error_die => 1,
+);
+ok($ret == 0, "DROP OWNED BY role_foobar");
+($ret, $stdout, $stderr) = $node->psql(
+ 'foobar2',
+ 'DROP DATABASE foobar8;',
+ on_error_die => 1,
+);
+ok($ret == 0, "DROP DATABASE foobar8");
+
done_testing();