pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Guillaume Lelarge <guillaume@lelarge.info>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Extensions not dumped when --schema is used
Date: Sun, 4 Apr 2021 15:08:02 -0700
Message-ID: <20210404220802.GA728316@rfd.leadboat.com> (raw)
In-Reply-To: <YGPEWAJk/iEXTaAE@paquier.xyz>
References: <CAECtzeXRygssgyWkqTtkc1jBrrMtB8WsrS_fOUmfPq7QyjO1+g@mail.gmail.com>
	<YDGX5TZ6vS5YC8vk@paquier.xyz>
	<YE7p7KWxFd1zhBSq@paquier.xyz>
	<CAECtzeUh1s=0ta0tfGSscibtWxcza8g_gq2ab_fjfiTWLuCnZw@mail.gmail.com>
	<20210315102155.qgp32wo6tcuu6w4l@nol>
	<YE82HGW1XxzN3Uvu@paquier.xyz>
	<CAOBaU_Y6MT6eudq9YzB9Rj=g4K_pv5PYHucDjYbH-KxZXSKz5Q@mail.gmail.com>
	<CAECtzeWqDn6pPbERr=PVNHLtt289syXRnkOK3xmW9H5KqXZCEQ@mail.gmail.com>
	<YGKU1eksrTr3RYCl@paquier.xyz>
	<YGPEWAJk/iEXTaAE@paquier.xyz>

On Wed, Mar 31, 2021 at 09:37:44AM +0900, Michael Paquier wrote:
> On Tue, Mar 30, 2021 at 12:02:45PM +0900, Michael Paquier wrote:
> > Okay.  So I have looked at that stuff in details, and after fixing
> > all the issues reported upthread in the code, docs and tests I am
> > finishing with the attached.  The tests have been moved out of
> > src/bin/pg_dump/ to src/test/modules/test_pg_dump/, and include both
> > positive and negative tests (used the trick with plpgsql for the
> > latter to avoid the dump of the extension test_pg_dump or any data
> > related to it).
> 
> I have double-checked this stuff this morning, and did not notice any
> issues.  So, applied.

I noticed the patch's behavior for relations that are members of non-dumped
extensions and are also registered using pg_extension_config_dump().  It
depends on the schema:

- If extschema='public', "pg_dump -e plpgsql" makes no mention of the
  relations.
- If extschema='public', "pg_dump -e plpgsql --schema=public" includes
  commands to dump the relation data.  This surprised me.  (The
  --schema=public argument causes selectDumpableNamespace() to set
  nsinfo->dobj.dump=DUMP_COMPONENT_ALL instead of DUMP_COMPONENT_ACL.)
- If extschema is not any sort of built-in schema, "pg_dump -e plpgsql"
  includes commands to dump the relation data.  This surprised me.

I'm attaching a test case patch that demonstrates this.  Is this behavior
intentional?

Attachments:

without_extension_explicit_schema-v0.patch (text/plain, 1.6K) download commit d210c01 (demo-dumpext-public) Author: Noah Misch <noah@leadboat.com> AuthorDate: Thu Apr 1 17:36:13 2021 -0700 Commit: Noah Misch <noah@leadboat.com> CommitDate: Thu Apr 1 17:36:13 2021 -0700 demo --- src/test/modules/test_pg_dump/t/001_base.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index 7c053c4..600015e 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -203,11 +203,23 @@ my %pgdump_runs = ( }, # plgsql in the list blocks the dump of extension test_pg_dump + # TODO --no-sync needn't appear twice without_extension => { dump_cmd => [ 'pg_dump', '--no-sync', "--file=$tempdir/without_extension.sql", '--extension=plpgsql', '--no-sync', 'postgres', ], + }, + + without_extension_explicit_schema => { + dump_cmd => [ + 'pg_dump', + '--no-sync', + "--file=$tempdir/without_extension_explicit_schema.sql", + '--extension=plpgsql', + '--schema=public', + 'postgres', + ], },); ############################################################### @@ -632,6 +644,8 @@ my %tests = ( pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, + # excludes this schema + without_extension_explicit_schema => 1, }, }, @@ -646,6 +660,8 @@ my %tests = ( pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, + # excludes this schema + without_extension_explicit_schema => 1, }, },

view thread (38+ messages)  latest in thread

Message-ID: <20210404220802.GA728316@rfd.leadboat.com>
Permalink:  ../20210404220802.GA728316@rfd.leadboat.com/
Also on:    postgresql.org/message-id/20210404220802.GA728316@rfd.leadboat.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: noah@leadboat.com, michael@paquier.xyz, guillaume@lelarge.info, rjuju123@gmail.com, tgl@sss.pgh.pa.us, daniel@yesql.se
  Subject: Re: Extensions not dumped when --schema is used
  In-Reply-To: <20210404220802.GA728316@rfd.leadboat.com>
  References: <CAECtzeXRygssgyWkqTtkc1jBrrMtB8WsrS_fOUmfPq7QyjO1+g@mail.gmail.com> <YDGX5TZ6vS5YC8vk@paquier.xyz> <YE7p7KWxFd1zhBSq@paquier.xyz> <CAECtzeUh1s=0ta0tfGSscibtWxcza8g_gq2ab_fjfiTWLuCnZw@mail.gmail.com> <20210315102155.qgp32wo6tcuu6w4l@nol> <YE82HGW1XxzN3Uvu@paquier.xyz> <CAOBaU_Y6MT6eudq9YzB9Rj=g4K_pv5PYHucDjYbH-KxZXSKz5Q@mail.gmail.com> <CAECtzeWqDn6pPbERr=PVNHLtt289syXRnkOK3xmW9H5KqXZCEQ@mail.gmail.com> <YGKU1eksrTr3RYCl@paquier.xyz> <YGPEWAJk/iEXTaAE@paquier.xyz> <20210404220802.GA728316@rfd.leadboat.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