pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martín Marqués <martin@2ndquadrant.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Stephen Frost <sfrost@snowman.net>
Subject: pg_dump with tables created in schemas created by extensions
Date: Fri, 12 Aug 2016 18:58:26 -0300
Message-ID: <99581032-71de-6466-c325-069861f1947d@2ndquadrant.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

add_pg_dump_tests_for_tables_in_schemas_from_extensions.diff (text/x-diff, 2.2K) download 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;

view thread (26+ messages)  latest in thread

Message-ID: <99581032-71de-6466-c325-069861f1947d@2ndquadrant.com>
Permalink:  ../99581032-71de-6466-c325-069861f1947d@2ndquadrant.com/
Also on:    postgresql.org/message-id/99581032-71de-6466-c325-069861f1947d@2ndquadrant.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: martin@2ndquadrant.com, michael.paquier@gmail.com, sfrost@snowman.net
  Subject: Re: pg_dump with tables created in schemas created by extensions
  In-Reply-To: <99581032-71de-6466-c325-069861f1947d@2ndquadrant.com>
  References: <99581032-71de-6466-c325-069861f1947d@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox