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

Commitd77354e

Browse files
committed
Fix up dumping conditions for extension configuration tables.
Various filters that were meant to prevent dumping of table data were notbeing applied to extension config tables, notably --exclude-table-data and--no-unlogged-table-data. We also would bogusly try to dump data fromviews, sequences, or foreign tables, should an extension try to claim theywere config tables. Fix all that, and refactor/redocument to try to makethis a bit less fragile. This reverts the implementation, though not thefeature, of commit7b070e8, which hadbroken config-table dumping altogether :-(.It is still the case that the code will dump config-table data even if--schema is specified. That behavior was intentional, as per the commentsin getExtensionMembership, so I think it requires some more discussionbefore we change it.
1 parentcb7c84f commitd77354e

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,15 +1140,6 @@ selectDumpableTable(TableInfo *tbinfo)
11401140
simple_oid_list_member(&table_exclude_oids,
11411141
tbinfo->dobj.catId.oid))
11421142
tbinfo->dobj.dump= false;
1143-
1144-
/* If table is to be dumped, check that the data is not excluded */
1145-
if (tbinfo->dobj.dump&& !
1146-
simple_oid_list_member(&tabledata_exclude_oids,
1147-
tbinfo->dobj.catId.oid))
1148-
tbinfo->dobj.dumpdata= true;
1149-
else
1150-
tbinfo->dobj.dumpdata= false;
1151-
11521143
}
11531144

11541145
/*
@@ -1599,10 +1590,6 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
15991590
DataDumperPtrdumpFn;
16001591
char*copyStmt;
16011592

1602-
/* don't do anything if the data isn't wanted */
1603-
if (!tbinfo->dobj.dumpdata)
1604-
return;
1605-
16061593
if (!dump_inserts)
16071594
{
16081595
/* Dump/restore using COPY */
@@ -1644,33 +1631,50 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
16441631

16451632
for (i=0;i<numTables;i++)
16461633
{
1647-
/* Skip VIEWs (no data to dump) */
1648-
if (tblinfo[i].relkind==RELKIND_VIEW)
1649-
continue;
1650-
/* Skip SEQUENCEs (handled elsewhere) */
1651-
if (tblinfo[i].relkind==RELKIND_SEQUENCE)
1652-
continue;
1653-
/* Skip FOREIGN TABLEs (no data to dump) */
1654-
if (tblinfo[i].relkind==RELKIND_FOREIGN_TABLE)
1655-
continue;
1656-
/* Skip unlogged tables if so requested */
1657-
if (tblinfo[i].relpersistence==RELPERSISTENCE_UNLOGGED
1658-
&&no_unlogged_table_data)
1659-
continue;
1660-
1661-
if (tblinfo[i].dobj.dump&&tblinfo[i].dataObj==NULL)
1634+
if (tblinfo[i].dobj.dump)
16621635
makeTableDataInfo(&(tblinfo[i]),oids);
16631636
}
16641637
}
16651638

16661639
/*
16671640
* Make a dumpable object for the data of this specific table
1641+
*
1642+
* Note: we make a TableDataInfo if and only if we are going to dump the
1643+
* table data; the "dump" flag in such objects isn't used.
16681644
*/
16691645
staticvoid
16701646
makeTableDataInfo(TableInfo*tbinfo,booloids)
16711647
{
16721648
TableDataInfo*tdinfo;
16731649

1650+
/*
1651+
* Nothing to do if we already decided to dump the table. This will
1652+
* happen for "config" tables.
1653+
*/
1654+
if (tbinfo->dataObj!=NULL)
1655+
return;
1656+
1657+
/* Skip VIEWs (no data to dump) */
1658+
if (tbinfo->relkind==RELKIND_VIEW)
1659+
return;
1660+
/* Skip SEQUENCEs (handled elsewhere) */
1661+
if (tbinfo->relkind==RELKIND_SEQUENCE)
1662+
return;
1663+
/* Skip FOREIGN TABLEs (no data to dump) */
1664+
if (tbinfo->relkind==RELKIND_FOREIGN_TABLE)
1665+
return;
1666+
1667+
/* Don't dump data in unlogged tables, if so requested */
1668+
if (tbinfo->relpersistence==RELPERSISTENCE_UNLOGGED&&
1669+
no_unlogged_table_data)
1670+
return;
1671+
1672+
/* Check that the data is not explicitly excluded */
1673+
if (simple_oid_list_member(&tabledata_exclude_oids,
1674+
tbinfo->dobj.catId.oid))
1675+
return;
1676+
1677+
/* OK, let's dump it */
16741678
tdinfo= (TableDataInfo*)pg_malloc(sizeof(TableDataInfo));
16751679

16761680
tdinfo->dobj.objType=DO_TABLE_DATA;
@@ -14127,14 +14131,17 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
1412714131
TableInfo*configtbl;
1412814132

1412914133
configtbl=findTableByOid(atooid(extconfigarray[j]));
14130-
if (configtbl&&configtbl->dataObj==NULL)
14134+
if (configtbl==NULL)
14135+
continue;
14136+
14137+
/*
14138+
* Note: config tables are dumped without OIDs regardless
14139+
* of the --oids setting. This is because row filtering
14140+
* conditions aren't compatible with dumping OIDs.
14141+
*/
14142+
makeTableDataInfo(configtbl, false);
14143+
if (configtbl->dataObj!=NULL)
1413114144
{
14132-
/*
14133-
* Note: config tables are dumped without OIDs regardless
14134-
* of the --oids setting. This is because row filtering
14135-
* conditions aren't compatible with dumping OIDs.
14136-
*/
14137-
makeTableDataInfo(configtbl, false);
1413814145
if (strlen(extconditionarray[j])>0)
1413914146
configtbl->dataObj->filtercond=pg_strdup(extconditionarray[j]);
1414014147
}

‎src/bin/pg_dump/pg_dump.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ typedef struct _dumpableObject
129129
char*name;/* object name (should never be NULL) */
130130
struct_namespaceInfo*namespace;/* containing namespace, or NULL */
131131
booldump;/* true if we want to dump this object */
132-
booldumpdata;/* true if we want data for this object */
133132
boolext_member;/* true if object is member of extension */
134133
DumpId*dependencies;/* dumpIds of objects this one depends on */
135134
intnDeps;/* number of valid dependencies */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp