Amit,

* Amit Langote (langote_amit...@lab.ntt.co.jp) wrote:
> Attached updated patches.

Please find an updated version which corrects the issue with
binary-upgrade of partitioned tables having partitions in other schemas,
along with a few other minor improvements.

If you could take a look at it, I'd appreciate it.  We already had a
test case in the pg_dump TAP tests for partitions existing in a schema
different from the partitioned table, but we weren't checking the
binary-upgrade case, so I've added a check to do that now.  I'm sure
additional tests would be good to add and will take a look at doing that
tomorrow, but this hopefully closes at least the latest issue.

Assuming this looks good to you, I'll push it tomorrow, possibly with
other minor adjustments and perhaps a few more tests.

Thanks!

Stephen
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
new file mode 100644
index e2bc357..47191be
*** a/src/bin/pg_dump/common.c
--- b/src/bin/pg_dump/common.c
*************** static int	numextmembers;
*** 68,75 ****
  
  static void flagInhTables(TableInfo *tbinfo, int numTables,
  			  InhInfo *inhinfo, int numInherits);
- static void flagPartitions(TableInfo *tblinfo, int numTables,
- 			  PartInfo *partinfo, int numPartitions);
  static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables);
  static DumpableObject **buildIndexArray(void *objArray, int numObjs,
  				Size objSize);
--- 68,73 ----
*************** static int	DOCatalogIdCompare(const void
*** 77,84 ****
  static int	ExtensionMemberIdCompare(const void *p1, const void *p2);
  static void findParentsByOid(TableInfo *self,
  				 InhInfo *inhinfo, int numInherits);
- static void findPartitionParentByOid(TableInfo *self, PartInfo *partinfo,
- 				 int numPartitions);
  static int	strInArray(const char *pattern, char **arr, int arr_size);
  
  
--- 75,80 ----
*************** getSchemaData(Archive *fout, int *numTab
*** 97,106 ****
  	NamespaceInfo *nspinfo;
  	ExtensionInfo *extinfo;
  	InhInfo    *inhinfo;
- 	PartInfo    *partinfo;
  	int			numAggregates;
  	int			numInherits;
- 	int			numPartitions;
  	int			numRules;
  	int			numProcLangs;
  	int			numCasts;
--- 93,100 ----
*************** getSchemaData(Archive *fout, int *numTab
*** 238,247 ****
  	inhinfo = getInherits(fout, &numInherits);
  
  	if (g_verbose)
- 		write_msg(NULL, "reading partition information\n");
- 	partinfo = getPartitions(fout, &numPartitions);
- 
- 	if (g_verbose)
  		write_msg(NULL, "reading event triggers\n");
  	getEventTriggers(fout, &numEventTriggers);
  
--- 232,237 ----
*************** getSchemaData(Archive *fout, int *numTab
*** 255,265 ****
  		write_msg(NULL, "finding inheritance relationships\n");
  	flagInhTables(tblinfo, numTables, inhinfo, numInherits);
  
- 	/* Link tables to partition parents, mark parents as interesting */
- 	if (g_verbose)
- 		write_msg(NULL, "finding partition relationships\n");
- 	flagPartitions(tblinfo, numTables, partinfo, numPartitions);
- 
  	if (g_verbose)
  		write_msg(NULL, "reading column info for interesting tables\n");
  	getTableAttrs(fout, tblinfo, numTables);
--- 245,250 ----
*************** getSchemaData(Archive *fout, int *numTab
*** 293,302 ****
  	getPolicies(fout, tblinfo, numTables);
  
  	if (g_verbose)
- 		write_msg(NULL, "reading partition key information for interesting tables\n");
- 	getTablePartitionKeyInfo(fout, tblinfo, numTables);
- 
- 	if (g_verbose)
  		write_msg(NULL, "reading publications\n");
  	getPublications(fout);
  
--- 278,283 ----
*************** flagInhTables(TableInfo *tblinfo, int nu
*** 354,396 ****
  	}
  }
  
- /* flagPartitions -
-  *	 Fill in parent link fields of every target table that is partition,
-  *	 and mark parents of partitions as interesting
-  *
-  * modifies tblinfo
-  */
- static void
- flagPartitions(TableInfo *tblinfo, int numTables,
- 			  PartInfo *partinfo, int numPartitions)
- {
- 	int		i;
- 
- 	for (i = 0; i < numTables; i++)
- 	{
- 		/* Some kinds are never partitions */
- 		if (tblinfo[i].relkind == RELKIND_SEQUENCE ||
- 			tblinfo[i].relkind == RELKIND_VIEW ||
- 			tblinfo[i].relkind == RELKIND_MATVIEW)
- 			continue;
- 
- 		/* Don't bother computing anything for non-target tables, either */
- 		if (!tblinfo[i].dobj.dump)
- 			continue;
- 
- 		/* Find the parent TableInfo and save */
- 		findPartitionParentByOid(&tblinfo[i], partinfo, numPartitions);
- 
- 		/* Mark the parent as interesting for getTableAttrs */
- 		if (tblinfo[i].partitionOf)
- 		{
- 			tblinfo[i].partitionOf->interesting = true;
- 			addObjectDependency(&tblinfo[i].dobj,
- 								tblinfo[i].partitionOf->dobj.dumpId);
- 		}
- 	}
- }
- 
  /* flagInhAttrs -
   *	 for each dumpable table in tblinfo, flag its inherited attributes
   *
--- 335,340 ----
*************** findParentsByOid(TableInfo *self,
*** 992,1031 ****
  }
  
  /*
-  * findPartitionParentByOid
-  *	  find a partition's parent in tblinfo[]
-  */
- static void
- findPartitionParentByOid(TableInfo *self, PartInfo *partinfo,
- 						 int numPartitions)
- {
- 	Oid			oid = self->dobj.catId.oid;
- 	int			i;
- 
- 	for (i = 0; i < numPartitions; i++)
- 	{
- 		if (partinfo[i].partrelid == oid)
- 		{
- 			TableInfo  *parent;
- 
- 			parent = findTableByOid(partinfo[i].partparent);
- 			if (parent == NULL)
- 			{
- 				write_msg(NULL, "failed sanity check, parent OID %u of table \"%s\" (OID %u) not found\n",
- 						  partinfo[i].partparent,
- 						  self->dobj.name,
- 						  oid);
- 				exit_nicely(1);
- 			}
- 			self->partitionOf = parent;
- 
- 			/* While we're at it, also save the partdef */
- 			self->partitiondef = partinfo[i].partdef;
- 		}
- 	}
- }
- 
- /*
   * parseOidArray
   *	  parse a string of numbers delimited by spaces into a character array
   *
--- 936,941 ----
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index 2fda350..56cfcb2
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** getTables(Archive *fout, int *numTables)
*** 5507,5512 ****
--- 5507,5518 ----
  	int			i_relpages;
  	int			i_is_identity_sequence;
  	int			i_changed_acl;
+ 	int			i_partkeydef;
+ 	int			i_ispartition;
+ 	int			i_partbound;
+ 	char	   *partkeydef = "NULL";
+ 	char	   *ispartition = "NULL";
+ 	char	   *partbound = "NULL";
  
  	/* Make sure we are in proper schema */
  	selectSourceSchema(fout, "pg_catalog");
*************** getTables(Archive *fout, int *numTables)
*** 5544,5549 ****
--- 5550,5567 ----
  		PQExpBuffer attinitracl_subquery = createPQExpBuffer();
  
  		/*
+ 		 * Collect the information about any partitioned tables, which were
+ 		 * added in PG10.
+ 		 */
+ 
+ 		if (fout->remoteVersion >= 100000)
+ 		{
+ 			partkeydef = "pg_get_partkeydef(c.oid)";
+ 			ispartition = "c.relispartition";
+ 			partbound = "pg_get_expr(c.relpartbound, c.oid)";
+ 		}
+ 
+ 		/*
  		 * Left join to pick up dependency info linking sequences to their
  		 * owning column, if any (note this dependency is AUTO as of 8.2)
  		 *
*************** getTables(Archive *fout, int *numTables)
*** 5594,5600 ****
  						  "OR %s IS NOT NULL "
  						  "OR %s IS NOT NULL"
  						  "))"
! 						  "AS changed_acl "
  						  "FROM pg_class c "
  						  "LEFT JOIN pg_depend d ON "
  						  "(c.relkind = '%c' AND "
--- 5612,5621 ----
  						  "OR %s IS NOT NULL "
  						  "OR %s IS NOT NULL"
  						  "))"
! 						  "AS changed_acl, "
! 						  "%s AS partkeydef, "
! 						  "%s AS ispartition, "
! 						  "%s AS partbound "
  						  "FROM pg_class c "
  						  "LEFT JOIN pg_depend d ON "
  						  "(c.relkind = '%c' AND "
*************** getTables(Archive *fout, int *numTables)
*** 5618,5623 ****
--- 5639,5647 ----
  						  attracl_subquery->data,
  						  attinitacl_subquery->data,
  						  attinitracl_subquery->data,
+ 						  partkeydef,
+ 						  ispartition,
+ 						  partbound,
  						  RELKIND_SEQUENCE,
  						  RELKIND_RELATION, RELKIND_SEQUENCE,
  						  RELKIND_VIEW, RELKIND_COMPOSITE_TYPE,
*************** getTables(Archive *fout, int *numTables)
*** 6038,6043 ****
--- 6062,6070 ----
  	i_reloftype = PQfnumber(res, "reloftype");
  	i_is_identity_sequence = PQfnumber(res, "is_identity_sequence");
  	i_changed_acl = PQfnumber(res, "changed_acl");
+ 	i_partkeydef = PQfnumber(res, "partkeydef");
+ 	i_ispartition = PQfnumber(res, "ispartition");
+ 	i_partbound = PQfnumber(res, "partbound");
  
  	if (dopt->lockWaitTimeout)
  	{
*************** getTables(Archive *fout, int *numTables)
*** 6140,6145 ****
--- 6167,6177 ----
  		tblinfo[i].is_identity_sequence = (i_is_identity_sequence >= 0 &&
  										   strcmp(PQgetvalue(res, i, i_is_identity_sequence), "t") == 0);
  
+ 		/* Partition key string or NULL */
+ 		tblinfo[i].partkeydef = pg_strdup(PQgetvalue(res, i, i_partkeydef));
+ 		tblinfo[i].ispartition = (strcmp(PQgetvalue(res, i, i_ispartition), "t") == 0);
+ 		tblinfo[i].partbound = pg_strdup(PQgetvalue(res, i, i_partbound));
+ 
  		/*
  		 * Read-lock target tables to make sure they aren't DROPPED or altered
  		 * in schema before we get around to dumping them.
*************** getInherits(Archive *fout, int *numInher
*** 6265,6275 ****
  	 * we want more information about partitions than just the parent-child
  	 * relationship.
  	 */
! 	appendPQExpBufferStr(query,
! 						 "SELECT inhrelid, inhparent "
! 						 "FROM pg_inherits "
! 						 "WHERE inhparent NOT IN (SELECT oid FROM pg_class "
! 						 "WHERE relkind = " CppAsString2(RELKIND_PARTITIONED_TABLE) ")");
  
  	res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
  
--- 6297,6303 ----
  	 * we want more information about partitions than just the parent-child
  	 * relationship.
  	 */
! 	appendPQExpBufferStr(query, "SELECT inhrelid, inhparent FROM pg_inherits");
  
  	res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
  
*************** getInherits(Archive *fout, int *numInher
*** 6296,6367 ****
  }
  
  /*
-  * getPartitions
-  *	  read all the partition inheritance and partition bound information
-  * from the system catalogs return them in the PartInfo* structure
-  *
-  * numPartitions is set to the number of pairs read in
-  */
- PartInfo *
- getPartitions(Archive *fout, int *numPartitions)
- {
- 	PGresult   *res;
- 	int			ntups;
- 	int			i;
- 	PQExpBuffer query;
- 	PartInfo    *partinfo;
- 
- 	int			i_partrelid;
- 	int			i_partparent;
- 	int			i_partbound;
- 
- 	/* Before version 10, there are no partitions  */
- 	if (fout->remoteVersion < 100000)
- 	{
- 		*numPartitions = 0;
- 		return NULL;
- 	}
- 
- 	query = createPQExpBuffer();
- 
- 	/* Make sure we are in proper schema */
- 	selectSourceSchema(fout, "pg_catalog");
- 
- 	/* find the inheritance and boundary information about partitions */
- 
- 	appendPQExpBufferStr(query,
- 						 "SELECT inhrelid as partrelid, inhparent AS partparent,"
- 						 "       pg_get_expr(relpartbound, inhrelid) AS partbound"
- 						 " FROM pg_class c, pg_inherits"
- 						 " WHERE c.oid = inhrelid AND c.relispartition");
- 
- 	res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
- 
- 	ntups = PQntuples(res);
- 
- 	*numPartitions = ntups;
- 
- 	partinfo = (PartInfo *) pg_malloc(ntups * sizeof(PartInfo));
- 
- 	i_partrelid = PQfnumber(res, "partrelid");
- 	i_partparent = PQfnumber(res, "partparent");
- 	i_partbound = PQfnumber(res, "partbound");
- 
- 	for (i = 0; i < ntups; i++)
- 	{
- 		partinfo[i].partrelid = atooid(PQgetvalue(res, i, i_partrelid));
- 		partinfo[i].partparent = atooid(PQgetvalue(res, i, i_partparent));
- 		partinfo[i].partdef = pg_strdup(PQgetvalue(res, i, i_partbound));
- 	}
- 
- 	PQclear(res);
- 
- 	destroyPQExpBuffer(query);
- 
- 	return partinfo;
- }
- 
- /*
   * getIndexes
   *	  get information about every index on a dumpable table
   *
--- 6324,6329 ----
*************** getTransforms(Archive *fout, int *numTra
*** 7730,7778 ****
  }
  
  /*
-  * getTablePartitionKeyInfo -
-  *	  for each interesting partitioned table, read information about its
-  *	  partition key
-  *
-  *	modifies tblinfo
-  */
- void
- getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
- {
- 	PQExpBuffer q;
- 	int			i;
- 	PGresult   *res;
- 
- 	/* No partitioned tables before 10 */
- 	if (fout->remoteVersion < 100000)
- 		return;
- 
- 	q = createPQExpBuffer();
- 
- 	for (i = 0; i < numTables; i++)
- 	{
- 		TableInfo  *tbinfo = &(tblinfo[i]);
- 
- 		/* Only partitioned tables have partition key */
- 		if (tbinfo->relkind != RELKIND_PARTITIONED_TABLE)
- 			continue;
- 
- 		/* Don't bother computing anything for non-target tables, either */
- 		if (!tbinfo->dobj.dump)
- 			continue;
- 
- 		resetPQExpBuffer(q);
- 		appendPQExpBuffer(q, "SELECT pg_catalog.pg_get_partkeydef('%u'::pg_catalog.oid)",
- 							 tbinfo->dobj.catId.oid);
- 		res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
- 		Assert(PQntuples(res) == 1);
- 		tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
- 	}
- 
- 	destroyPQExpBuffer(q);
- }
- 
- /*
   * getTableAttrs -
   *	  for each interesting table, read info about its attributes
   *	  (names, types, default values, CHECK constraints, etc)
--- 7692,7697 ----
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15196,15204 ****
  		if (tbinfo->reloftype && !dopt->binary_upgrade)
  			appendPQExpBuffer(q, " OF %s", tbinfo->reloftype);
  
! 		if (tbinfo->partitionOf && !dopt->binary_upgrade)
  		{
! 			TableInfo  *parentRel = tbinfo->partitionOf;
  
  			appendPQExpBuffer(q, " PARTITION OF ");
  			if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
--- 15115,15136 ----
  		if (tbinfo->reloftype && !dopt->binary_upgrade)
  			appendPQExpBuffer(q, " OF %s", tbinfo->reloftype);
  
! 		/*
! 		 * If the table is a partition, dump it as such; except in the case
! 		 * of a binary upgrade, we dump the table normally and attach it to
! 		 * the parent afterward.
! 		 */
! 		if (tbinfo->ispartition && !dopt->binary_upgrade)
  		{
! 			TableInfo  *parentRel = tbinfo->parents[0];
! 
! 			/*
! 			 * With partitions, unlike inheritance, there can only be one
! 			 * parent.
! 			 */
! 			if (tbinfo->numParents != 1)
! 				exit_horribly(NULL, "invalid number of parents %d for table \"%s\"\n",
! 							  tbinfo->numParents, tbinfo->dobj.name);
  
  			appendPQExpBuffer(q, " PARTITION OF ");
  			if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15239,15245 ****
  					 * Skip column if fully defined by reloftype or the
  					 * partition parent.
  					 */
! 					if ((tbinfo->reloftype || tbinfo->partitionOf) &&
  						!has_default && !has_notnull && !dopt->binary_upgrade)
  						continue;
  
--- 15171,15177 ----
  					 * Skip column if fully defined by reloftype or the
  					 * partition parent.
  					 */
! 					if ((tbinfo->reloftype || tbinfo->ispartition) &&
  						!has_default && !has_notnull && !dopt->binary_upgrade)
  						continue;
  
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15276,15282 ****
  					 * partition ('PARTITION OF'), since the type comes from
  					 * the parent/partitioned table.
  					 */
! 					if (dopt->binary_upgrade || (!tbinfo->reloftype && !tbinfo->partitionOf))
  					{
  						appendPQExpBuffer(q, " %s",
  										  tbinfo->atttypnames[j]);
--- 15208,15214 ----
  					 * partition ('PARTITION OF'), since the type comes from
  					 * the parent/partitioned table.
  					 */
! 					if (dopt->binary_upgrade || (!tbinfo->reloftype && !tbinfo->ispartition))
  					{
  						appendPQExpBuffer(q, " %s",
  										  tbinfo->atttypnames[j]);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15330,15336 ****
  
  			if (actual_atts)
  				appendPQExpBufferStr(q, "\n)");
! 			else if (!((tbinfo->reloftype || tbinfo->partitionOf) &&
  						!dopt->binary_upgrade))
  			{
  				/*
--- 15262,15268 ----
  
  			if (actual_atts)
  				appendPQExpBufferStr(q, "\n)");
! 			else if (!((tbinfo->reloftype || tbinfo->ispartition) &&
  						!dopt->binary_upgrade))
  			{
  				/*
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15340,15352 ****
  				appendPQExpBufferStr(q, " (\n)");
  			}
  
! 			if (tbinfo->partitiondef && !dopt->binary_upgrade)
  			{
  				appendPQExpBufferStr(q, "\n");
! 				appendPQExpBufferStr(q, tbinfo->partitiondef);
  			}
  
! 			if (numParents > 0 && !dopt->binary_upgrade)
  			{
  				appendPQExpBufferStr(q, "\nINHERITS (");
  				for (k = 0; k < numParents; k++)
--- 15272,15287 ----
  				appendPQExpBufferStr(q, " (\n)");
  			}
  
! 			if (tbinfo->ispartition && !dopt->binary_upgrade)
  			{
  				appendPQExpBufferStr(q, "\n");
! 				appendPQExpBufferStr(q, tbinfo->partbound);
  			}
  
! 			/* Emit the INHERITS clause, except if this is a partition. */
! 			if (numParents > 0 &&
! 				!tbinfo->ispartition &&
! 				!dopt->binary_upgrade)
  			{
  				appendPQExpBufferStr(q, "\nINHERITS (");
  				for (k = 0; k < numParents; k++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15492,15509 ****
  
  			if (numParents > 0)
  			{
! 				appendPQExpBufferStr(q, "\n-- For binary upgrade, set up inheritance this way.\n");
  				for (k = 0; k < numParents; k++)
  				{
  					TableInfo  *parentRel = parents[k];
  
! 					appendPQExpBuffer(q, "ALTER TABLE ONLY %s INHERIT ",
! 									  fmtId(tbinfo->dobj.name));
  					if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
! 						appendPQExpBuffer(q, "%s.",
! 								fmtId(parentRel->dobj.namespace->dobj.name));
! 					appendPQExpBuffer(q, "%s;\n",
  									  fmtId(parentRel->dobj.name));
  				}
  			}
  
--- 15427,15464 ----
  
  			if (numParents > 0)
  			{
! 				appendPQExpBufferStr(q, "\n-- For binary upgrade, set up inheritance and partitioning this way.\n");
  				for (k = 0; k < numParents; k++)
  				{
  					TableInfo  *parentRel = parents[k];
+ 					PQExpBuffer	parentname = createPQExpBuffer();
  
! 					/* Schema-qualify the parent table, if necessary */
  					if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
! 						appendPQExpBuffer(parentname, "%s.",
! 							fmtId(parentRel->dobj.namespace->dobj.name));
! 
! 					appendPQExpBuffer(parentname, "%s",
  									  fmtId(parentRel->dobj.name));
+ 
+ 					/* In the partitioning case, we alter the parent */
+ 					if (tbinfo->ispartition)
+ 						appendPQExpBuffer(q,
+ 									"ALTER TABLE ONLY %s ATTACH PARTITION ",
+ 										  parentname->data);
+ 					else
+ 						appendPQExpBuffer(q, "ALTER TABLE ONLY %s INHERIT ",
+ 											fmtId(tbinfo->dobj.name));
+ 
+ 					/* Partition needs specifying the bounds */
+ 					if (tbinfo->ispartition)
+ 						appendPQExpBuffer(q, "%s %s;\n",
+ 										  fmtId(tbinfo->dobj.name),
+ 										  tbinfo->partbound);
+ 					else
+ 						appendPQExpBuffer(q, "%s;\n", parentname->data);
+ 
+ 					destroyPQExpBuffer(parentname);
  				}
  			}
  
*************** dumpTableSchema(Archive *fout, TableInfo
*** 15515,15530 ****
  								  tbinfo->reloftype);
  			}
  
- 			if (tbinfo->partitionOf)
- 			{
- 				appendPQExpBufferStr(q, "\n-- For binary upgrade, set up partitions this way.\n");
- 				appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
- 								  fmtId(tbinfo->partitionOf->dobj.name));
- 				appendPQExpBuffer(q, "ATTACH PARTITION %s %s;\n",
- 								  fmtId(tbinfo->dobj.name),
- 								  tbinfo->partitiondef);
- 			}
- 
  			appendPQExpBufferStr(q, "\n-- For binary upgrade, set heap's relfrozenxid and relminmxid\n");
  			appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
  							  "SET relfrozenxid = '%u', relminmxid = '%u'\n"
--- 15470,15475 ----
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
new file mode 100644
index 471cfce..4e6c83c
*** a/src/bin/pg_dump/pg_dump.h
--- b/src/bin/pg_dump/pg_dump.h
*************** typedef struct _tableInfo
*** 294,299 ****
--- 294,300 ----
  	bool		interesting;	/* true if need to collect more data */
  	bool		dummy_view;		/* view's real definition must be postponed */
  	bool		postponed_def;	/* matview must be postponed into post-data */
+ 	bool        ispartition;    /* is table a partition? */
  
  	/*
  	 * These fields are computed only if we decide the table is interesting
*************** typedef struct _tableInfo
*** 319,324 ****
--- 320,326 ----
  	struct _attrDefInfo **attrdefs;		/* DEFAULT expressions */
  	struct _constraintInfo *checkexprs; /* CHECK constraints */
  	char	   *partkeydef;		/* partition key definition */
+ 	char	   *partbound;		/* partition bound definition */
  	bool		needs_override;	/* has GENERATED ALWAYS AS IDENTITY */
  
  	/*
*************** typedef struct _tableInfo
*** 329,336 ****
  	struct _tableDataInfo *dataObj;		/* TableDataInfo, if dumping its data */
  	int			numTriggers;	/* number of triggers for table */
  	struct _triggerInfo *triggers;		/* array of TriggerInfo structs */
- 	struct _tableInfo *partitionOf;	/* TableInfo for the partition parent */
- 	char	   *partitiondef;		/* partition key definition */
  } TableInfo;
  
  typedef struct _attrDefInfo
--- 331,336 ----
*************** typedef struct _inhInfo
*** 476,490 ****
  	Oid			inhparent;		/* OID of its parent */
  } InhInfo;
  
- /* PartInfo isn't a DumpableObject, just temporary state */
- typedef struct _partInfo
- {
- 	Oid			partrelid;		/* OID of a partition */
- 	Oid			partparent;		/* OID of its parent */
- 	char	   *partdef;		/* partition bound definition */
- } PartInfo;
- 
- 
  typedef struct _prsInfo
  {
  	DumpableObject dobj;
--- 476,481 ----
*************** extern ConvInfo *getConversions(Archive
*** 691,697 ****
  extern TableInfo *getTables(Archive *fout, int *numTables);
  extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
  extern InhInfo *getInherits(Archive *fout, int *numInherits);
- extern PartInfo *getPartitions(Archive *fout, int *numPartitions);
  extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
  extern void getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables);
  extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables);
--- 682,687 ----
*************** extern void processExtensionTables(Archi
*** 717,723 ****
  					   int numExtensions);
  extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
  extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables);
- extern void getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables);
  extern void getPublications(Archive *fout);
  extern void getPublicationTables(Archive *fout, TableInfo tblinfo[],
  								 int numTables);
--- 707,712 ----
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
new file mode 100644
index ccd0ed6..253894f
*** a/src/bin/pg_dump/t/002_pg_dump.pl
--- b/src/bin/pg_dump/t/002_pg_dump.pl
*************** my %tests = (
*** 1049,1054 ****
--- 1049,1088 ----
  			section_post_data        => 1,
  			section_data             => 1, }, },
  
+ 	'ALTER TABLE ONLY dump_test.measurement ATTACH PARTITION measurement_y2006m2' => {
+ 		all_runs     => 1,
+ 		regexp => qr/^
+ 			\QALTER TABLE ONLY dump_test.measurement ATTACH PARTITION measurement_y2006m2 \E
+ 			\QFOR VALUES FROM ('2006-02-01') TO ('2006-03-01');\E\n
+ 			/xm,
+ 		like => {
+ 			binary_upgrade           => 1, },
+ 		unlike => {
+ 			clean                    => 1,
+ 			clean_if_exists          => 1,
+ 			createdb                 => 1,
+ 			defaults                 => 1,
+ 			exclude_dump_test_schema => 1,
+ 			exclude_test_table       => 1,
+ 			exclude_test_table_data  => 1,
+ 			no_blobs                 => 1,
+ 			no_privs                 => 1,
+ 			no_owner                 => 1,
+ 			pg_dumpall_dbprivs       => 1,
+ 			role                     => 1,
+ 			schema_only              => 1,
+ 			section_pre_data         => 1,
+ 			with_oids                => 1,
+ 			only_dump_test_schema    => 1,
+ 			only_dump_test_table     => 1,
+ 			pg_dumpall_globals       => 1,
+ 			pg_dumpall_globals_clean => 1,
+ 			section_post_data        => 1,
+ 			test_schema_plus_blobs   => 1,
+ 			column_inserts           => 1,
+ 			data_only                => 1,
+ 			section_data             => 1, }, },
+ 
  	'ALTER TABLE test_table CLUSTER ON test_table_pkey' => {
  		all_runs  => 1,
  		catch_all => 'ALTER TABLE ... commands',
*************** qr/CREATE TRANSFORM FOR integer LANGUAGE
*** 4764,4771 ****
  			\Q--\E\n\n
  			\QCREATE TABLE measurement_y2006m2 PARTITION OF dump_test.measurement\E\n
  			\QFOR VALUES FROM ('2006-02-01') TO ('2006-03-01');\E\n
- 			\QALTER TABLE ONLY measurement_y2006m2 ALTER COLUMN city_id SET NOT NULL;\E\n
- 			\QALTER TABLE ONLY measurement_y2006m2 ALTER COLUMN logdate SET NOT NULL;\E\n
  			/xm,
  		like => {
  			clean                    => 1,
--- 4798,4803 ----

Attachment: signature.asc
Description: Digital signature

Reply via email to