mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Add test for copy of shared dependencies from template database
As 98ec35b has proved, there has never been any coverage in this area of the code. This commit adds a new TAP test with a template database that includes a small set of shared dependencies copied to a new database. The test is added in createdb, where we have never tested that -T generates a query with TEMPLATE, either. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/YXDTl+PfSnqmbbkE@paquier.xyz
This commit is contained in:
parent
5a2832465f
commit
70bfc5ae53
@ -6,7 +6,7 @@ use warnings;
|
|||||||
|
|
||||||
use PostgreSQL::Test::Cluster;
|
use PostgreSQL::Test::Cluster;
|
||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More tests => 22;
|
use Test::More tests => 25;
|
||||||
|
|
||||||
program_help_ok('createdb');
|
program_help_ok('createdb');
|
||||||
program_version_ok('createdb');
|
program_version_ok('createdb');
|
||||||
@ -28,6 +28,30 @@ $node->issues_sql_like(
|
|||||||
$node->command_fails([ 'createdb', 'foobar1' ],
|
$node->command_fails([ 'createdb', 'foobar1' ],
|
||||||
'fails if database already exists');
|
'fails if database already exists');
|
||||||
|
|
||||||
|
# Check use of templates with shared dependencies copied from the template.
|
||||||
|
my ($ret, $stdout, $stderr) = $node->psql(
|
||||||
|
'foobar2',
|
||||||
|
'CREATE ROLE role_foobar;
|
||||||
|
CREATE TABLE tab_foobar (id int);
|
||||||
|
ALTER TABLE tab_foobar owner to role_foobar;
|
||||||
|
CREATE POLICY pol_foobar ON tab_foobar FOR ALL TO role_foobar;');
|
||||||
|
$node->issues_sql_like(
|
||||||
|
[ 'createdb', '-l', 'C', '-T', 'foobar2', 'foobar3' ],
|
||||||
|
qr/statement: CREATE DATABASE foobar3 TEMPLATE foobar2/,
|
||||||
|
'create database with template');
|
||||||
|
($ret, $stdout, $stderr) = $node->psql(
|
||||||
|
'foobar3',
|
||||||
|
"SELECT pg_describe_object(classid, objid, objsubid) AS obj,
|
||||||
|
pg_describe_object(refclassid, refobjid, 0) AS refobj
|
||||||
|
FROM pg_shdepend s JOIN pg_database d ON (d.oid = s.dbid)
|
||||||
|
WHERE d.datname = 'foobar3' ORDER BY obj;", on_error_die => 1);
|
||||||
|
chomp($stdout);
|
||||||
|
like(
|
||||||
|
$stdout,
|
||||||
|
qr/^policy pol_foobar on table tab_foobar\|role role_foobar
|
||||||
|
table tab_foobar\|role role_foobar$/,
|
||||||
|
'shared dependencies copied over to target database');
|
||||||
|
|
||||||
# Check quote handling with incorrect option values.
|
# Check quote handling with incorrect option values.
|
||||||
$node->command_checks_all(
|
$node->command_checks_all(
|
||||||
[ 'createdb', '--encoding', "foo'; SELECT '1", 'foobar2' ],
|
[ 'createdb', '--encoding', "foo'; SELECT '1", 'foobar2' ],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user