Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70bfc5a

Browse files
committed
Add test for copy of shared dependencies from template database
As98ec35b has proved, there has never been any coverage in this area ofthe code. This commit adds a new TAP test with a template database thatincludes a small set of shared dependencies copied to a new database.The test is added in createdb, where we have never tested that -Tgenerates a query with TEMPLATE, either.Reviewed-by: Tom LaneDiscussion:https://postgr.es/m/YXDTl+PfSnqmbbkE@paquier.xyz
1 parent5a28324 commit70bfc5a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎src/bin/scripts/t/020_createdb.pl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use PostgreSQL::Test::Cluster;
88
use PostgreSQL::Test::Utils;
9-
use Test::Moretests=>22;
9+
use Test::Moretests=>25;
1010

1111
program_help_ok('createdb');
1212
program_version_ok('createdb');
@@ -28,6 +28,30 @@
2828
$node->command_fails(['createdb','foobar1' ],
2929
'fails if database already exists');
3030

31+
# Check use of templates with shared dependencies copied from the template.
32+
my ($ret,$stdout,$stderr) =$node->psql(
33+
'foobar2',
34+
'CREATE ROLE role_foobar;
35+
CREATE TABLE tab_foobar (id int);
36+
ALTER TABLE tab_foobar owner to role_foobar;
37+
CREATE POLICY pol_foobar ON tab_foobar FOR ALL TO role_foobar;');
38+
$node->issues_sql_like(
39+
['createdb','-l','C','-T','foobar2','foobar3' ],
40+
qr/statement: CREATE DATABASE foobar3 TEMPLATE foobar2/,
41+
'create database with template');
42+
($ret,$stdout,$stderr) =$node->psql(
43+
'foobar3',
44+
"SELECT pg_describe_object(classid, objid, objsubid) AS obj,
45+
pg_describe_object(refclassid, refobjid, 0) AS refobj
46+
FROM pg_shdepend s JOIN pg_database d ON (d.oid = s.dbid)
47+
WHERE d.datname = 'foobar3' ORDER BY obj;",on_error_die=> 1);
48+
chomp($stdout);
49+
like(
50+
$stdout,
51+
qr/^policy pol_foobar on table tab_foobar\|role role_foobar
52+
table tab_foobar\|role role_foobar$/,
53+
'shared dependencies copied over to target database');
54+
3155
# Check quote handling with incorrect option values.
3256
$node->command_checks_all(
3357
['createdb','--encoding',"foo'; SELECT '1",'foobar2' ],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp