Hi, About a month or two ago I reported a pg_dump bug regarding tables (and other objects) created inside a schema from an extension.
Objects created by the extensions are not dumped, as they will be created once again with the CREATE EXTENSION call, but and other objects which might live inside an object created by the extension should be dumped so they get created inside the same schema. The problem showed up when dumping a DB with PgQ installed as an extension. Check here: https://www.postgresql.org/message-id/d86dd685-1870-cfa0-e5e4-def1f918bec9%402ndquadrant.com and here: https://www.postgresql.org/message-id/409fe594-f4cc-89f5-c0d2-0a921987a864%402ndquadrant.com Some discussion came up on the bugs list on how to fix the issue, and the fact the new tests were needed. I'm attaching a patch to provide such test, which if applied now, returns failure on a number of runs, all expected due to the bug we have at hand. I believe the fix will be simple after the back and forth mails with Michael, Stephen and Tom. I will work on that later, but preferred to have the tests the show the problem which will also make testing the fix easier. Thoughts? Regards, -- Martín Marqués http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl new file mode 100644 index fb4f573..6086317 *** a/src/test/modules/test_pg_dump/t/001_base.pl --- b/src/test/modules/test_pg_dump/t/001_base.pl *************** my %tests = ( *** 283,288 **** --- 283,313 ---- schema_only => 1, section_pre_data => 1, section_post_data => 1, }, }, + 'CREATE TABLE regress_test_schema_table' => { + create_order => 3, + create_sql => 'CREATE TABLE regress_pg_dump_schema.test_schema_table ( + col1 serial primary key, + CHECK (col1 <= 1000) + );', + regexp => qr/^ + \QCREATE TABLE test_schema_table (\E + \n\s+\Qcol1 integer NOT NULL,\E + \n\s+\QCONSTRAINT test_table_col1_check CHECK \E + \Q((col1 <= 1000))\E + \n\);/xm, + like => { + binary_upgrade => 1, + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + schema_only => 1, + section_pre_data => 1, }, + unlike => { + pg_dumpall_globals => 1, + section_post_data => 1, }, }, 'CREATE ACCESS METHOD regress_test_am' => { regexp => qr/^ \QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E diff --git a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql new file mode 100644 index c2fe90d..3f88e6c *** a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql --- b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql *************** CREATE TABLE regress_pg_dump_table ( *** 10,15 **** --- 10,24 ---- CREATE SEQUENCE regress_pg_dump_seq; + -- We want to test that schemas and objects created in the schema by the + -- extension are not dumped, yet other objects created afterwards will be + -- dumped. + CREATE SCHEMA regress_pg_dump_schema + CREATE TABLE regress_pg_dump_schema_table ( + col1 serial, + col2 int + ); + GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role; GRANT SELECT ON regress_pg_dump_table TO regress_dump_test_role;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers