Commit d77354ea authored by Tom Lane's avatar Tom Lane

Fix up dumping conditions for extension configuration tables.

Various filters that were meant to prevent dumping of table data were not
being applied to extension config tables, notably --exclude-table-data and
--no-unlogged-table-data.  We also would bogusly try to dump data from
views, sequences, or foreign tables, should an extension try to claim they
were config tables.  Fix all that, and refactor/redocument to try to make
this a bit less fragile.  This reverts the implementation, though not the
feature, of commit 7b070e89, which had
broken 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 comments
in getExtensionMembership, so I think it requires some more discussion
before we change it.
parent cb7c84fa
...@@ -1140,15 +1140,6 @@ selectDumpableTable(TableInfo *tbinfo) ...@@ -1140,15 +1140,6 @@ selectDumpableTable(TableInfo *tbinfo)
simple_oid_list_member(&table_exclude_oids, simple_oid_list_member(&table_exclude_oids,
tbinfo->dobj.catId.oid)) tbinfo->dobj.catId.oid))
tbinfo->dobj.dump = false; tbinfo->dobj.dump = false;
/* If table is to be dumped, check that the data is not excluded */
if (tbinfo->dobj.dump && !
simple_oid_list_member(&tabledata_exclude_oids,
tbinfo->dobj.catId.oid))
tbinfo->dobj.dumpdata = true;
else
tbinfo->dobj.dumpdata = false;
} }
/* /*
...@@ -1599,10 +1590,6 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) ...@@ -1599,10 +1590,6 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
DataDumperPtr dumpFn; DataDumperPtr dumpFn;
char *copyStmt; char *copyStmt;
/* don't do anything if the data isn't wanted */
if (!tbinfo->dobj.dumpdata)
return;
if (!dump_inserts) if (!dump_inserts)
{ {
/* Dump/restore using COPY */ /* Dump/restore using COPY */
...@@ -1644,33 +1631,50 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids) ...@@ -1644,33 +1631,50 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids)
for (i = 0; i < numTables; i++) for (i = 0; i < numTables; i++)
{ {
/* Skip VIEWs (no data to dump) */ if (tblinfo[i].dobj.dump)
if (tblinfo[i].relkind == RELKIND_VIEW)
continue;
/* Skip SEQUENCEs (handled elsewhere) */
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue;
/* Skip FOREIGN TABLEs (no data to dump) */
if (tblinfo[i].relkind == RELKIND_FOREIGN_TABLE)
continue;
/* Skip unlogged tables if so requested */
if (tblinfo[i].relpersistence == RELPERSISTENCE_UNLOGGED
&& no_unlogged_table_data)
continue;
if (tblinfo[i].dobj.dump && tblinfo[i].dataObj == NULL)
makeTableDataInfo(&(tblinfo[i]), oids); makeTableDataInfo(&(tblinfo[i]), oids);
} }
} }
/* /*
* Make a dumpable object for the data of this specific table * Make a dumpable object for the data of this specific table
*
* Note: we make a TableDataInfo if and only if we are going to dump the
* table data; the "dump" flag in such objects isn't used.
*/ */
static void static void
makeTableDataInfo(TableInfo *tbinfo, bool oids) makeTableDataInfo(TableInfo *tbinfo, bool oids)
{ {
TableDataInfo *tdinfo; TableDataInfo *tdinfo;
/*
* Nothing to do if we already decided to dump the table. This will
* happen for "config" tables.
*/
if (tbinfo->dataObj != NULL)
return;
/* Skip VIEWs (no data to dump) */
if (tbinfo->relkind == RELKIND_VIEW)
return;
/* Skip SEQUENCEs (handled elsewhere) */
if (tbinfo->relkind == RELKIND_SEQUENCE)
return;
/* Skip FOREIGN TABLEs (no data to dump) */
if (tbinfo->relkind == RELKIND_FOREIGN_TABLE)
return;
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
if (simple_oid_list_member(&tabledata_exclude_oids,
tbinfo->dobj.catId.oid))
return;
/* OK, let's dump it */
tdinfo = (TableDataInfo *) pg_malloc(sizeof(TableDataInfo)); tdinfo = (TableDataInfo *) pg_malloc(sizeof(TableDataInfo));
tdinfo->dobj.objType = DO_TABLE_DATA; tdinfo->dobj.objType = DO_TABLE_DATA;
...@@ -14127,14 +14131,17 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], ...@@ -14127,14 +14131,17 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
TableInfo *configtbl; TableInfo *configtbl;
configtbl = findTableByOid(atooid(extconfigarray[j])); configtbl = findTableByOid(atooid(extconfigarray[j]));
if (configtbl && configtbl->dataObj == NULL) if (configtbl == NULL)
continue;
/*
* Note: config tables are dumped without OIDs regardless
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
makeTableDataInfo(configtbl, false);
if (configtbl->dataObj != NULL)
{ {
/*
* Note: config tables are dumped without OIDs regardless
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
makeTableDataInfo(configtbl, false);
if (strlen(extconditionarray[j]) > 0) if (strlen(extconditionarray[j]) > 0)
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]); configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
} }
......
...@@ -129,7 +129,6 @@ typedef struct _dumpableObject ...@@ -129,7 +129,6 @@ typedef struct _dumpableObject
char *name; /* object name (should never be NULL) */ char *name; /* object name (should never be NULL) */
struct _namespaceInfo *namespace; /* containing namespace, or NULL */ struct _namespaceInfo *namespace; /* containing namespace, or NULL */
bool dump; /* true if we want to dump this object */ bool dump; /* true if we want to dump this object */
bool dumpdata; /* true if we want data for this object */
bool ext_member; /* true if object is member of extension */ bool ext_member; /* true if object is member of extension */
DumpId *dependencies; /* dumpIds of objects this one depends on */ DumpId *dependencies; /* dumpIds of objects this one depends on */
int nDeps; /* number of valid dependencies */ int nDeps; /* number of valid dependencies */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment