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: Wed, 14 Apr 2021 05:31:15 -0700
Message-ID: <20210414123115.GA1263822@rfd.leadboat.com> (raw)
In-Reply-To: <YHZG3zEpO0PbpeHL@paquier.xyz>
References: <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>
	<YHUvb4QxkMfy7pjN@paquier.xyz>
	<20210413150034.GA1218136@rfd.leadboat.com>
	<YHZG3zEpO0PbpeHL@paquier.xyz>

On Wed, Apr 14, 2021 at 10:38:17AM +0900, Michael Paquier wrote:
> On Tue, Apr 13, 2021 at 08:00:34AM -0700, Noah Misch wrote:
> > On Tue, Apr 13, 2021 at 02:43:11PM +0900, Michael Paquier wrote:
> >>> - 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.)

> > This isn't a problem of selecting schemas for inclusion in the dump.  This is
> > a problem of associating extensions with their pg_extension_config_dump()
> > relations and omitting those extension-member relations when "-e" causes
> > omission of the extension.
> 
> At code level, the decision to dump the data of any extension's
> dumpable table is done in processExtensionTables().  I have to admit
> that your feeling here keeps the code simpler than what I have been
> thinking if we apply an extra filtering based on the list of
> extensions in this code path.  So I can see the value in your argument
> to not dump at all the data of an extension's dumpable table as long
> as its extension is not listed, and this, even if its schema is
> explicitly listed.
> 
> So I got down to make the behavior more consistent with the patch
> attached.  This passes your case.

Yes.

> It is worth noting that if a
> table is part of a schema created by an extension, but that the table
> is not dependent on the extension, we would still dump its data if
> using --schema with this table's schema while the extension is not
> part of the list from --extension.  In the attached, that's just the
> extra test with without_extension_implicit_schema.

That's consistent with v13, and it seems fine.  I've not used a non-test
extension that creates a schema.

> --- a/src/test/modules/test_pg_dump/t/001_base.pl
> +++ b/src/test/modules/test_pg_dump/t/001_base.pl
> @@ -208,6 +208,30 @@ my %pgdump_runs = (
>  			'pg_dump', '--no-sync', "--file=$tempdir/without_extension.sql",
>  			'--extension=plpgsql', 'postgres',
>  		],
> +	},
> +
> +	# plgsql in the list of extensions blocks the dump of extension
> +	# test_pg_dump.
> +	without_extension_explicit_schema => {
> +		dump_cmd => [
> +			'pg_dump',
> +			'--no-sync',
> +			"--file=$tempdir/without_extension_explicit_schema.sql",
> +			'--extension=plpgsql',
> +			'--schema=public',
> +			'postgres',
> +		],
> +	},
> +
> +	without_extension_implicit_schema => {
> +		dump_cmd => [
> +			'pg_dump',
> +			'--no-sync',
> +			"--file=$tempdir/without_extension_implicit_schema.sql",
> +			'--extension=plpgsql',
> +			'--schema=regress_pg_dump_schema',
> +			'postgres',
> +		],
>  	},);

The name "without_extension_explicit_schema" arose because that test differs
from the "without_extension" test by adding --schema=public.  The test named
"without_extension_implicit_schema" differs from "without_extension" by adding
--schema=regress_pg_dump_schema, so the word "implicit" feels not-descriptive
of the test.  I recommend picking a different name.  Other than that, the
change looks good.





view thread (38+ messages)  latest in thread

Message-ID: <20210414123115.GA1263822@rfd.leadboat.com>
Permalink:  ../20210414123115.GA1263822@rfd.leadboat.com/
Also on:    postgresql.org/message-id/20210414123115.GA1263822@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: <20210414123115.GA1263822@rfd.leadboat.com>
  References: <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> <YHUvb4QxkMfy7pjN@paquier.xyz> <20210413150034.GA1218136@rfd.leadboat.com> <YHZG3zEpO0PbpeHL@paquier.xyz> <20210414123115.GA1263822@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