Skip to content

Commit 46d2882

Browse files
committed
Improve C comments about backend variables set by pg_upgrade_support
functions.
1 parent 7f40e30 commit 46d2882

File tree

7 files changed

+43
-9
lines changed

7 files changed

+43
-9
lines changed

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77
* contrib/pg_upgrade/pg_upgrade.c
88
*/
99

10+
/*
11+
* To simplify the upgrade process, we force certain system items to be
12+
* consistent between old and new clusters:
13+
*
14+
* We control all assignments of pg_class.relfilenode so we can keep the
15+
* same relfilenodes for old and new files. The only exception is
16+
* pg_largeobject, pg_largeobject_metadata, and its indexes, which can
17+
* change due to a cluster, reindex, or vacuum full. (We don't create
18+
* those so have no control over their oid/relfilenode values.)
19+
*
20+
* While pg_class.oid and pg_class.relfilenode are intially the same, they
21+
* can diverge due to cluster, reindex, or vacuum full. The new cluster
22+
* will again have matching pg_class.relfilenode and pg_class.oid values,
23+
* but based on the new relfilenode value, so the old/new oids might
24+
* differ.
25+
*
26+
* We control all assignments of pg_type.oid because these are stored
27+
* in composite types.
28+
*/
29+
30+
31+
1032
#include "pg_upgrade.h"
1133

1234
#ifdef HAVE_LANGINFO_H

src/backend/catalog/heap.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
#include "utils/tqual.h"
7474

7575

76-
/* Kluge for upgrade-in-place support */
76+
/* Potentially set by contrib/pg_upgrade_support functions */
7777
Oid binary_upgrade_next_heap_relfilenode = InvalidOid;
7878
Oid binary_upgrade_next_toast_relfilenode = InvalidOid;
7979

@@ -986,7 +986,10 @@ heap_create_with_catalog(const char *relname,
986986
*/
987987
if (!OidIsValid(relid))
988988
{
989-
/* Use binary-upgrade overrides if applicable */
989+
/*
990+
* Use binary-upgrade override for pg_class.relfilenode/oid,
991+
* if supplied.
992+
*/
990993
if (OidIsValid(binary_upgrade_next_heap_relfilenode) &&
991994
(relkind == RELKIND_RELATION || relkind == RELKIND_SEQUENCE ||
992995
relkind == RELKIND_VIEW || relkind == RELKIND_COMPOSITE_TYPE ||

src/backend/catalog/index.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#include "utils/tqual.h"
6969

7070

71-
/* Kluge for upgrade-in-place support */
71+
/* Potentially set by contrib/pg_upgrade_support functions */
7272
Oid binary_upgrade_next_index_relfilenode = InvalidOid;
7373

7474
/* state info for validate_index bulkdelete callback */
@@ -640,7 +640,10 @@ index_create(Oid heapRelationId,
640640
*/
641641
if (!OidIsValid(indexRelationId))
642642
{
643-
/* Use binary-upgrade override if applicable */
643+
/*
644+
* Use binary-upgrade override for pg_class.relfilenode/oid,
645+
* if supplied.
646+
*/
644647
if (OidIsValid(binary_upgrade_next_index_relfilenode))
645648
{
646649
indexRelationId = binary_upgrade_next_index_relfilenode;

src/backend/catalog/pg_enum.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "utils/tqual.h"
2929

3030

31+
/* Potentially set by contrib/pg_upgrade_support functions */
3132
Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
3233

3334
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
@@ -313,9 +314,9 @@ AddEnumLabel(Oid enumTypeOid,
313314
if (OidIsValid(binary_upgrade_next_pg_enum_oid))
314315
{
315316
/*
316-
* In binary upgrades, just add the new label with the predetermined
317-
* Oid. It's pg_upgrade's responsibility that the Oid meets
318-
* requirements.
317+
* Use binary-upgrade override for pg_enum.oid, if supplied.
318+
* During binary upgrade, all pg_enum.oid's are set this way
319+
* so they are guaranteed to be consistent.
319320
*/
320321
if (neighbor != NULL)
321322
ereport(ERROR,

src/backend/catalog/pg_type.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "utils/rel.h"
3434
#include "utils/syscache.h"
3535

36+
/* Potentially set by contrib/pg_upgrade_support functions */
3637
Oid binary_upgrade_next_pg_type_oid = InvalidOid;
3738

3839
/* ----------------------------------------------------------------
@@ -121,6 +122,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
121122
*/
122123
tup = heap_form_tuple(tupDesc, values, nulls);
123124

125+
/* Use binary-upgrade override for pg_type.oid, if supplied. */
124126
if (OidIsValid(binary_upgrade_next_pg_type_oid))
125127
{
126128
HeapTupleSetOid(tup, binary_upgrade_next_pg_type_oid);
@@ -422,6 +424,7 @@ TypeCreate(Oid newTypeOid,
422424
/* Force the OID if requested by caller */
423425
if (OidIsValid(newTypeOid))
424426
HeapTupleSetOid(tup, newTypeOid);
427+
/* Use binary-upgrade override for pg_type.oid, if supplied. */
425428
else if (OidIsValid(binary_upgrade_next_pg_type_oid))
426429
{
427430
HeapTupleSetOid(tup, binary_upgrade_next_pg_type_oid);

src/backend/catalog/toasting.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "utils/builtins.h"
3232
#include "utils/syscache.h"
3333

34-
/* Kluges for upgrade-in-place support */
34+
/* Potentially set by contrib/pg_upgrade_support functions */
3535
extern Oid binary_upgrade_next_toast_relfilenode;
3636

3737
Oid binary_upgrade_next_pg_type_toast_oid = InvalidOid;
@@ -200,6 +200,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
200200
else
201201
namespaceid = PG_TOAST_NAMESPACE;
202202

203+
/* Use binary-upgrade override for pg_type.oid, if supplied. */
203204
if (OidIsValid(binary_upgrade_next_pg_type_toast_oid))
204205
{
205206
toast_typid = binary_upgrade_next_pg_type_toast_oid;

src/backend/commands/typecmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ typedef struct
7474
/* atts[] is of allocated length RelationGetNumberOfAttributes(rel) */
7575
} RelToCheck;
7676

77+
/* Potentially set by contrib/pg_upgrade_support functions */
7778
Oid binary_upgrade_next_pg_type_array_oid = InvalidOid;
7879

7980
static Oid findTypeInputFunction(List *procname, Oid typeOid);
@@ -1517,7 +1518,7 @@ AssignTypeArrayOid(void)
15171518
{
15181519
Oid type_array_oid;
15191520

1520-
/* Pre-assign the type's array OID for use in pg_type.typarray */
1521+
/* Use binary-upgrade override for pg_type.typarray, if supplied. */
15211522
if (OidIsValid(binary_upgrade_next_pg_type_array_oid))
15221523
{
15231524
type_array_oid = binary_upgrade_next_pg_type_array_oid;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy