I wrote:
> What I think we should do is fix pg_dump so that these classes of
> TOC entries do indeed have tags that meet the expectation held by
> _tocEntryRequired, as per the first attached patch.

Some further poking around identified another place that was taking
dubious shortcuts to identify large-object TOC entries, further down
in _tocEntryRequired.  Since that code is executed only during
binary upgrade, which will be working from a schema-only dump anyway,
it *might* be harmless.  But I'm not sure, and it's certainly far from
future-proof.  I also noted a copy-and-pasteo in dumpSecLabel.

Hence, I intend to add the attached to the back-patched fix proposed
previously.

                        regards, tom lane

diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 41741ae..acef20f 100644
*** a/src/bin/pg_dump/pg_backup_archiver.c
--- b/src/bin/pg_dump/pg_backup_archiver.c
*************** _tocEntryRequired(TocEntry *te, teSectio
*** 2944,2957 ****
  	if (ropt->schemaOnly)
  	{
  		/*
  		 * In binary-upgrade mode, even with schema-only set, we do not mask
  		 * out large objects.  Only large object definitions, comments and
  		 * other information should be generated in binary-upgrade mode (not
  		 * the actual data).
  		 */
  		if (!(ropt->sequence_data && strcmp(te->desc, "SEQUENCE SET") == 0) &&
! 			!(ropt->binary_upgrade && strcmp(te->desc, "BLOB") == 0) &&
! 			!(ropt->binary_upgrade && strncmp(te->tag, "LARGE OBJECT ", 13) == 0))
  			res = res & REQ_SCHEMA;
  	}
  
--- 2944,2965 ----
  	if (ropt->schemaOnly)
  	{
  		/*
+ 		 * The sequence_data option overrides schema-only for SEQUENCE SET.
+ 		 *
  		 * In binary-upgrade mode, even with schema-only set, we do not mask
  		 * out large objects.  Only large object definitions, comments and
  		 * other information should be generated in binary-upgrade mode (not
  		 * the actual data).
  		 */
  		if (!(ropt->sequence_data && strcmp(te->desc, "SEQUENCE SET") == 0) &&
! 			!(ropt->binary_upgrade &&
! 			  (strcmp(te->desc, "BLOB") == 0 ||
! 			   (strcmp(te->desc, "ACL") == 0 &&
! 				strncmp(te->tag, "LARGE OBJECT ", 13) == 0) ||
! 			   (strcmp(te->desc, "COMMENT") == 0 &&
! 				strncmp(te->tag, "LARGE OBJECT ", 13) == 0) ||
! 			   (strcmp(te->desc, "SECURITY LABEL") == 0 &&
! 				strncmp(te->tag, "LARGE OBJECT ", 13) == 0))))
  			res = res & REQ_SCHEMA;
  	}
  
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 0bdd398..8e5e2d5 100644
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** dumpSecLabel(Archive *fout, const char *
*** 14811,14817 ****
  	if (dopt->no_security_labels)
  		return;
  
! 	/* Comments are schema not data ... except blob comments are data */
  	if (strncmp(target, "LARGE OBJECT ", 13) != 0)
  	{
  		if (dopt->dataOnly)
--- 14811,14817 ----
  	if (dopt->no_security_labels)
  		return;
  
! 	/* Security labels are schema not data ... except blob labels are data */
  	if (strncmp(target, "LARGE OBJECT ", 13) != 0)
  	{
  		if (dopt->dataOnly)

Reply via email to