Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit344487e

Browse files
committed
Tweak behavior of pg_dump --extension with configuration tables
6568cef, that introduced the option, had an inconsistent behavior whenit comes to configuration tables set up by pg_extension_config_dump, asthe data of all configuration tables would included in a dump even forextensions not listed by a set of --extension switches.The contents dumped changed depending on the schema where an extensionwas installed when an extension was not listed. For example, anextension installed under the public schema would have its configurationdata not dumped even when not listed with --extension, which wasinconsistent with the case of an extension installed on a non-publicschema, where the configuration would be dumped.Per discussion with Noah, we have settled down to the simple rule ofdumping configuration data of an extension if it is listed in--extension (default is unchanged and backward-compatible, to dumpeverything on sight if there are no extensions directly listed). Thisavoids some weird cases where the dumps depended on a --schema for one.More tests are added to cover the gap, where we cross-check morebehaviors depending on --schema when an extension is not listed.Reported-by: Noah MischReviewed-by: Noah MischDiscussion:https://postgr.es/m/20210404220802.GA728316@rfd.leadboat.com
1 parente1623b7 commit344487e

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ PostgreSQL documentation
234234
shell from expanding the wildcards.
235235
</para>
236236

237+
<para>
238+
Any configuration relation registered by
239+
<function>pg_extension_config_dump</function> is included in the
240+
dump if its extension is specified by <option>--extension</option>.
241+
</para>
242+
237243
<note>
238244
<para>
239245
When <option>-e</option> is specified,

‎src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18271,7 +18271,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
1827118271
* Note that we create TableDataInfo objects even in schemaOnly mode, ie,
1827218272
* user data in a configuration table is treated like schema data. This
1827318273
* seems appropriate since system data in a config table would get
18274-
* reloaded by CREATE EXTENSION.
18274+
* reloaded by CREATE EXTENSION. If the extension is not listed in the
18275+
* list of extensions to be included, none of its data is dumped.
1827518276
*/
1827618277
for (i = 0; i < numExtensions; i++)
1827718278
{
@@ -18283,6 +18284,15 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
1828318284
intnconfigitems = 0;
1828418285
intnconditionitems = 0;
1828518286

18287+
/*
18288+
* Check if this extension is listed as to include in the dump. If
18289+
* not, any table data associated with it is discarded.
18290+
*/
18291+
if (extension_include_oids.head != NULL &&
18292+
!simple_oid_list_member(&extension_include_oids,
18293+
curext->dobj.catId.oid))
18294+
continue;
18295+
1828618296
if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
1828718297
{
1828818298
intj;

‎src/test/modules/test_pg_dump/t/001_base.pl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,34 @@
208208
'pg_dump','--no-sync',"--file=$tempdir/without_extension.sql",
209209
'--extension=plpgsql','postgres',
210210
],
211+
},
212+
213+
# plgsql in the list of extensions blocks the dump of extension
214+
# test_pg_dump. "public" is the schema used by the extension
215+
# test_pg_dump, but none of its objects should be dumped.
216+
without_extension_explicit_schema=> {
217+
dump_cmd=> [
218+
'pg_dump',
219+
'--no-sync',
220+
"--file=$tempdir/without_extension_explicit_schema.sql",
221+
'--extension=plpgsql',
222+
'--schema=public',
223+
'postgres',
224+
],
225+
},
226+
227+
# plgsql in the list of extensions blocks the dump of extension
228+
# test_pg_dump, but not the dump of objects not dependent on the
229+
# extension located on a schema maintained by the extension.
230+
without_extension_internal_schema=> {
231+
dump_cmd=> [
232+
'pg_dump',
233+
'--no-sync',
234+
"--file=$tempdir/without_extension_internal_schema.sql",
235+
'--extension=plpgsql',
236+
'--schema=regress_pg_dump_schema',
237+
'postgres',
238+
],
211239
},);
212240

213241
###############################################################
@@ -632,6 +660,8 @@
632660
pg_dumpall_globals => 1,
633661
section_data => 1,
634662
section_pre_data => 1,
663+
# Excludes this schema as extension is not listed.
664+
without_extension_explicit_schema => 1,
635665
},
636666
},
637667
@@ -646,6 +676,8 @@
646676
pg_dumpall_globals => 1,
647677
section_data => 1,
648678
section_pre_data => 1,
679+
# Excludes this schema as extension is not listed.
680+
without_extension_explicit_schema => 1,
649681
},
650682
},
651683
@@ -662,6 +694,8 @@
662694
%full_runs,
663695
schema_only => 1,
664696
section_pre_data => 1,
697+
# Excludes the extension and keeps the schema's data.
698+
without_extension_internal_schema => 1,
665699
},
666700
},);
667701

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp