1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Force pg_upgrade's to preserve pg_class.oid, not pg_class.relfilenode.

Toast tables have identical pg_class.oid and pg_class.relfilenode, but
for clarity it is good to preserve the pg_class.oid.

Update comments regarding what is preserved, and do some
variable/function renaming for clarity.
This commit is contained in:
Bruce Momjian
2011-01-07 21:25:34 -05:00
parent 541fc3d4df
commit 2896c87ce4
10 changed files with 112 additions and 106 deletions

View File

@ -49,31 +49,31 @@ install_support_functions(void)
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
" binary_upgrade.set_next_pg_type_array_oid(OID) "
" binary_upgrade.set_next_array_pg_type_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
" binary_upgrade.set_next_pg_type_toast_oid(OID) "
" binary_upgrade.set_next_toast_pg_type_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
" binary_upgrade.set_next_heap_relfilenode(OID) "
" binary_upgrade.set_next_heap_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
" binary_upgrade.set_next_toast_relfilenode(OID) "
" binary_upgrade.set_next_index_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
" binary_upgrade.set_next_index_relfilenode(OID) "
" binary_upgrade.set_next_toast_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));

View File

@ -266,7 +266,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
/*
* pg_largeobject contains user data that does not appear the pg_dumpall
* --schema-only output, so we have to upgrade that system table heap and
* --schema-only output, so we have to copy that system table heap and
* index. Ideally we could just get the relfilenode from template1 but
* pg_largeobject_loid_pn_index's relfilenode can change if the table was
* reindexed so we get the relfilenode for each database and upgrade it as

View File

@ -8,23 +8,30 @@
*/
/*
* To simplify the upgrade process, we force certain system items to be
* consistent between old and new clusters:
* To simplify the upgrade process, we force certain system values to be
* identical between old and new clusters:
*
* We control all assignments of pg_class.relfilenode so we can keep the
* same relfilenodes for old and new files. The only exception is
* pg_largeobject, pg_largeobject_metadata, and its indexes, which can
* change due to a cluster, reindex, or vacuum full. (We don't create
* those so have no control over their oid/relfilenode values.)
* We control all assignments of pg_class.oid (and relfilenode) so toast
* oids are the same between old and new clusters. This is important
* because toast oids are stored as toast pointers in user tables.
*
* While pg_class.oid and pg_class.relfilenode are intially the same, they
* can diverge due to cluster, reindex, or vacuum full. The new cluster
* will again have matching pg_class.relfilenode and pg_class.oid values,
* but based on the new relfilenode value, so the old/new oids might
* differ.
* The only place where old/new relfilenode might not match is
* pg_largeobject, pg_largeobject_metadata, and its indexes,
* which can change their relfilenode values due to a cluster, reindex,
* or vacuum full. (We don't create those so have no control over their
* new relfilenode values.)
*
* We control all assignments of pg_type.oid because these are stored
* in composite types.
* FYI, while pg_class.oid and pg_class.relfilenode are intially the same
* in a cluster, but they can diverge due to cluster, reindex, or vacuum
* full. The new cluster will again have matching pg_class.relfilenode
* and pg_class.oid values, but based on the old relfilenode value, so the
* old/new oids might differ.
*
* We control all assignments of pg_type.oid because these oid are stored
* in user composite type values.
*
* We control all assignments of pg_enum.oid because these oid are stored
* in user tables as enum values.
*/

View File

@ -67,8 +67,8 @@ typedef struct
{
char nspname[NAMEDATALEN]; /* namespace name */
char relname[NAMEDATALEN]; /* relation name */
Oid reloid; /* relation oid */
Oid relfilenode; /* relation relfile node */
Oid reloid; /* relation oid */
Oid relfilenode; /* relation relfile node */
Oid toastrelid; /* oid of the toast relation */
char tablespace[MAXPGPATH]; /* relations tablespace path */
} RelInfo;