The attached, applied patch preserves
pg_largeobject_metadata.relfrozenxid in pg_upgrade.

This is needed only in 9.1 because only 9.0 had this table and no one is
upgrading from a 9.0 beta to 9.0 anymore.  We basically don't backpatch
9.0 beta fixes at this point.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index 90cb9ab..3f6e77b
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
***************
*** 50,55 ****
--- 50,56 ----
  #include "catalog/pg_class.h"
  #include "catalog/pg_default_acl.h"
  #include "catalog/pg_largeobject.h"
+ #include "catalog/pg_largeobject_metadata.h"
  #include "catalog/pg_proc.h"
  #include "catalog/pg_trigger.h"
  #include "catalog/pg_type.h"
*************** dumpDatabase(Archive *AH)
*** 1920,1927 ****
  				 NULL);			/* Dumper Arg */
  
  	/*
! 	 * pg_largeobject comes from the old system intact, so set its
! 	 * relfrozenxid.
  	 */
  	if (binary_upgrade)
  	{
--- 1921,1928 ----
  				 NULL);			/* Dumper Arg */
  
  	/*
! 	 * pg_largeobject and pg_largeobject_metadata come from the old system
! 	 * intact, so set their relfrozenxids.
  	 */
  	if (binary_upgrade)
  	{
*************** dumpDatabase(Archive *AH)
*** 1930,1935 ****
--- 1931,1939 ----
  		PQExpBuffer loOutQry = createPQExpBuffer();
  		int			i_relfrozenxid;
  
+ 		/*
+ 		 *	pg_largeobject
+ 		 */
  		appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
  						  "FROM pg_catalog.pg_class\n"
  						  "WHERE oid = %u;\n",
*************** dumpDatabase(Archive *AH)
*** 1946,1952 ****
  
  		i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
  
! 		appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid.\n");
  		appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
  						  "SET relfrozenxid = '%u'\n"
  						  "WHERE oid = %u;\n",
--- 1950,1956 ----
  
  		i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
  
! 		appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject.relfrozenxid\n");
  		appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
  						  "SET relfrozenxid = '%u'\n"
  						  "WHERE oid = %u;\n",
*************** dumpDatabase(Archive *AH)
*** 1960,1965 ****
--- 1964,2010 ----
  					 NULL, NULL);
  
  		PQclear(lo_res);
+ 
+ 		/*
+ 		 *	pg_largeobject_metadata
+ 		 */
+ 		if (g_fout->remoteVersion >= 90000)
+ 		{
+ 			resetPQExpBuffer(loFrozenQry);
+ 			resetPQExpBuffer(loOutQry);
+ 	
+ 			appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
+ 							  "FROM pg_catalog.pg_class\n"
+ 							  "WHERE oid = %u;\n",
+ 							  LargeObjectMetadataRelationId);
+ 	
+ 			lo_res = PQexec(g_conn, loFrozenQry->data);
+ 			check_sql_result(lo_res, g_conn, loFrozenQry->data, PGRES_TUPLES_OK);
+ 	
+ 			if (PQntuples(lo_res) != 1)
+ 			{
+ 				write_msg(NULL, "dumpDatabase(): could not find pg_largeobject_metadata.relfrozenxid\n");
+ 				exit_nicely();
+ 			}
+ 	
+ 			i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
+ 	
+ 			appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject_metadata.relfrozenxid\n");
+ 			appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
+ 							  "SET relfrozenxid = '%u'\n"
+ 							  "WHERE oid = %u;\n",
+ 							  atoi(PQgetvalue(lo_res, 0, i_relfrozenxid)),
+ 							  LargeObjectMetadataRelationId);
+ 			ArchiveEntry(AH, nilCatalogId, createDumpId(),
+ 						 "pg_largeobject_metadata", NULL, NULL, "",
+ 						 false, "pg_largeobject_metadata", SECTION_PRE_DATA,
+ 						 loOutQry->data, "", NULL,
+ 						 NULL, 0,
+ 						 NULL, NULL);
+ 	
+ 			PQclear(lo_res);
+ 		}
+ 
  		destroyPQExpBuffer(loFrozenQry);
  		destroyPQExpBuffer(loOutQry);
  	}
*************** dumpTableSchema(Archive *fout, TableInfo
*** 12176,12182 ****
  				}
  			}
  
! 			appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n");
  			appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
  							  "SET relfrozenxid = '%u'\n"
  							  "WHERE oid = ",
--- 12221,12227 ----
  				}
  			}
  
! 			appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid\n");
  			appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
  							  "SET relfrozenxid = '%u'\n"
  							  "WHERE oid = ",
-- 
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