Re: Extensions not dumped when --schema is used - Mailing list pgsql-hackers
From | Noah Misch |
---|---|
Subject | Re: Extensions not dumped when --schema is used |
Date | |
Msg-id | 20210413150034.GA1218136@rfd.leadboat.com Whole thread Raw |
In response to | Re: Extensions not dumped when --schema is used (Michael Paquier <michael@paquier.xyz>) |
Responses |
Re: Extensions not dumped when --schema is used
|
List | pgsql-hackers |
On Tue, Apr 13, 2021 at 02:43:11PM +0900, Michael Paquier wrote: > On Sun, Apr 04, 2021 at 03:08:02PM -0700, Noah Misch wrote: > > 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. > > This one is expected to me. The caller of pg_dump is not specifying > the extension that should be dumped, hence it looks logic to me to not > dump the tables marked as pg_extension_config_dump() part as an > extension not listed. Agreed. > > - 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 one would be expected to me. Per the discussion of upthread, we > want --schema and --extension to be two separate and exclusive > switches. So, once the caller specifies --schema we should dump the > contents of the schema, even if its extension is not listed with > --extension. I may disagree with this later, but I'm setting it aside for the moment. > Anyway, the behavior to select if a schema can be dumped > or not is not really related to this new code, right? And "public" is > a mixed beast, being treated as a system object and a user object by > selectDumpableNamespace(). Correct. > > - If extschema is not any sort of built-in schema, "pg_dump -e plpgsql" > > includes commands to dump the relation data. This surprised me. > > Hmm. But you are right that this one is inconsistent with the first > case where the extension is not listed. I would have said that as the > extension is not directly specified and that the schema is not passed > down either then we should not dump it at all, but this combination > actually does so. Maybe we should add an extra logic into > selectDumpableNamespace(), close to the end of it, to decide if, > depending on the contents of the extensions to include, we should dump > its associated schema or not? Another solution would be to make use > of schema_include_oids to filter out the schemas we don't want, but > that would mean that --extension gets priority over --schema or > --table but we did ot want that per the original discussion. No, neither of those solutions apply. "pg_dump -e plpgsql" selects all schemas. That is consistent with its documentation; plain "pg_dump" has long selected all schemas, and the documentation for "-e" does not claim that "-e" changes the selection of non-extension objects. We're not going to solve the problem by making selectDumpableNamespace() select some additional aspect of schema foo, because it's already selecting every available aspect. Like you say, we're also not going to solve the problem by removing some existing aspect of schema foo from selection, because that would remove dump material unrelated to any extension. 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.
pgsql-hackers by date: