On 02/07/2012 02:56 PM, Tom Lane wrote:
Andrew Dunstan<and...@dunslane.net>  writes:
On 01/31/2012 11:10 PM, Andrew Dunstan wrote:
Here's a possible patch for the exclude-table-data problem along the
lines you suggest.
Should I apply this?
I'm not happy with this yet.  My core complaint is that pg_dump used to
consider that creation of a TableDataInfo object for a table happens
if and only if we're going to dump the table's data.  And the comments
(eg in pg_dump.h) still say that.  But the previous patch left us in a
halfway zone where sometimes we'd create a TableDataInfo object and then
choose not to dump the data, and this patch doesn't get us out of that.
I think we should either revert to the previous definition, or go over
to a design wherein we always create TableDataInfo objects for all
tables (but probably still excluding data-less relations such as views)
and the whether-to-dump decision is expressed only by setting or not
setting the object's dump flag.

I worked a little bit on a patch to do the latter but found that it was
more invasive than I'd hoped.  Given the lack of any immediate payoff
I think it'd probably make more sense to do the former.  We could still
centralize the decision making into makeTableDataInfo a bit more than
now, but it should take the form of not creating the object at all,
rather than creating it and then clearing its dump flag.

                        


OK, in this version we simply suppress creation of the TableDataInfo object if it's not wanted. I actually removed the code from makeTableDataInfo - there are only two places it gets called and doing it in those two spots seemed a bit cleaner.

cheers

andrew
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
***************
*** 1141,1154 **** selectDumpableTable(TableInfo *tbinfo)
  							   tbinfo->dobj.catId.oid))
  		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;
- 
  }
  
  /*
--- 1141,1146 ----
***************
*** 1599,1608 **** dumpTableData(Archive *fout, TableDataInfo *tdinfo)
  	DataDumperPtr dumpFn;
  	char	   *copyStmt;
  
- 	/* don't do anything if the data isn't wanted */
- 	if (!tbinfo->dobj.dumpdata)
- 		return;
- 
  	if (!dump_inserts)
  	{
  		/* Dump/restore using COPY */
--- 1591,1596 ----
***************
*** 1658,1663 **** getTableData(TableInfo *tblinfo, int numTables, bool oids)
--- 1646,1656 ----
  			&& no_unlogged_table_data)
  			continue;
  
+ 		/* Check that the data is not explicitly excluded */
+ 		if (simple_oid_list_member(&tabledata_exclude_oids,
+ 								   tblinfo[i].dobj.catId.oid))
+ 			continue;
+ 
  		if (tblinfo[i].dobj.dump && tblinfo[i].dataObj == NULL)
  			makeTableDataInfo(&(tblinfo[i]), oids);
  	}
***************
*** 14127,14133 **** getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
  				TableInfo  *configtbl;
  
  				configtbl = findTableByOid(atooid(extconfigarray[j]));
! 				if (configtbl && configtbl->dataObj == NULL)
  				{
  					/*
  					 * Note: config tables are dumped without OIDs regardless
--- 14120,14132 ----
  				TableInfo  *configtbl;
  
  				configtbl = findTableByOid(atooid(extconfigarray[j]));
! 
! 				if (configtbl == NULL || 
! 					simple_oid_list_member(&tabledata_exclude_oids,
! 										   configtbl->dobj.catId.oid))
! 					continue;
! 
! 				if (configtbl->dataObj == NULL)
  				{
  					/*
  					 * Note: config tables are dumped without OIDs regardless
*** a/src/bin/pg_dump/pg_dump.h
--- b/src/bin/pg_dump/pg_dump.h
***************
*** 129,135 **** typedef struct _dumpableObject
  	char	   *name;			/* object name (should never be NULL) */
  	struct _namespaceInfo *namespace;	/* containing namespace, or NULL */
  	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 */
  	DumpId	   *dependencies;	/* dumpIds of objects this one depends on */
  	int			nDeps;			/* number of valid dependencies */
--- 129,134 ----
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to