Skip to content

Commit 4dbe52d

Browse files
committed
Ensure that user created rows in extension tables get dumped if the table is explicitly requested, either with a -t/--table switch of the table itself, or by -n/--schema switch of the schema containing the extension table. Patch reviewed by Vibhor Kumar and Dimitri Fontaine.
Backpatched to 9.1 when the extension management facility was added.
1 parent 9e859a9 commit 4dbe52d

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14028,10 +14028,6 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
1402814028
int nconfigitems;
1402914029
int nconditionitems;
1403014030

14031-
/* Tables of not-to-be-dumped extensions shouldn't be dumped */
14032-
if (!curext->dobj.dump)
14033-
continue;
14034-
1403514031
if (parsePGArray(extconfig, &extconfigarray, &nconfigitems) &&
1403614032
parsePGArray(extcondition, &extconditionarray, &nconditionitems) &&
1403714033
nconfigitems == nconditionitems)
@@ -14041,21 +14037,54 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
1404114037
for (j = 0; j < nconfigitems; j++)
1404214038
{
1404314039
TableInfo *configtbl;
14040+
Oid configtbloid = atooid(extconfigarray[j]);
14041+
bool dumpobj = curext->dobj.dump;
1404414042

14045-
configtbl = findTableByOid(atooid(extconfigarray[j]));
14043+
configtbl = findTableByOid(configtbloid);
1404614044
if (configtbl == NULL)
1404714045
continue;
1404814046

1404914047
/*
14050-
* Note: config tables are dumped without OIDs regardless of
14051-
* the --oids setting. This is because row filtering
14052-
* conditions aren't compatible with dumping OIDs.
14048+
* Tables of not-to-be-dumped extensions shouldn't be dumped
14049+
* unless the table or its schema is explicitly included
1405314050
*/
14054-
makeTableDataInfo(configtbl, false);
14055-
if (configtbl->dataObj != NULL)
14051+
if (!curext->dobj.dump)
1405614052
{
14057-
if (strlen(extconditionarray[j]) > 0)
14058-
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
14053+
/* check table explicitly requested */
14054+
if (table_include_oids.head != NULL &&
14055+
simple_oid_list_member(&table_include_oids,
14056+
configtbloid))
14057+
dumpobj = true;
14058+
14059+
/* check table's schema explicitly requested */
14060+
if (configtbl->dobj.namespace->dobj.dump)
14061+
dumpobj = true;
14062+
}
14063+
14064+
/* check table excluded by an exclusion switch */
14065+
if (table_exclude_oids.head != NULL &&
14066+
simple_oid_list_member(&table_exclude_oids,
14067+
configtbloid))
14068+
dumpobj = false;
14069+
14070+
/* check schema excluded by an exclusion switch */
14071+
if (simple_oid_list_member(&schema_exclude_oids,
14072+
configtbl->dobj.namespace->dobj.catId.oid))
14073+
dumpobj = false;
14074+
14075+
if (dumpobj)
14076+
{
14077+
/*
14078+
* Note: config tables are dumped without OIDs regardless of
14079+
* the --oids setting. This is because row filtering
14080+
* conditions aren't compatible with dumping OIDs.
14081+
*/
14082+
makeTableDataInfo(configtbl, false);
14083+
if (configtbl->dataObj != NULL)
14084+
{
14085+
if (strlen(extconditionarray[j]) > 0)
14086+
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
14087+
}
1405914088
}
1406014089
}
1406114090
}

0 commit comments

Comments
 (0)