Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc44327a

Browse files
committed
Binary upgrade:
Modify pg_dump --binary-upgrade and add backend support routines tosupport the preservation of pg_type oids when doing a binary upgrade.This allows user-defined composite types and arrays to be binaryupgraded.
1 parent668e37d commitc44327a

File tree

6 files changed

+226
-27
lines changed

6 files changed

+226
-27
lines changed

‎src/backend/catalog/heap.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.361 2009/12/07 05:22:21 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.362 2009/12/2422:09:23 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1001,13 +1001,7 @@ heap_create_with_catalog(const char *relname,
10011001
if (IsUnderPostmaster&& (relkind==RELKIND_RELATION||
10021002
relkind==RELKIND_VIEW||
10031003
relkind==RELKIND_COMPOSITE_TYPE))
1004-
{
1005-
/* OK, so pre-assign a type OID for the array type */
1006-
Relationpg_type=heap_open(TypeRelationId,AccessShareLock);
1007-
1008-
new_array_oid=GetNewOid(pg_type);
1009-
heap_close(pg_type,AccessShareLock);
1010-
}
1004+
new_array_oid=AssignTypeArrayOid();
10111005

10121006
/*
10131007
* Since defining a relation also defines a complex type, we add a new

‎src/backend/catalog/pg_type.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.127 2009/08/16 18:14:34 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.128 2009/12/24 22:09:23 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,6 +32,7 @@
3232
#include"utils/rel.h"
3333
#include"utils/syscache.h"
3434

35+
Oidbinary_upgrade_next_pg_type_oid=InvalidOid;
3536

3637
/* ----------------------------------------------------------------
3738
*TypeShellMake
@@ -119,6 +120,12 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
119120
*/
120121
tup=heap_form_tuple(tupDesc,values,nulls);
121122

123+
if (OidIsValid(binary_upgrade_next_pg_type_oid))
124+
{
125+
HeapTupleSetOid(tup,binary_upgrade_next_pg_type_oid);
126+
binary_upgrade_next_pg_type_oid=InvalidOid;
127+
}
128+
122129
/*
123130
* insert the tuple in the relation and get the tuple's oid.
124131
*/
@@ -409,10 +416,16 @@ TypeCreate(Oid newTypeOid,
409416
values,
410417
nulls);
411418

412-
/* Force the OID if requested by caller, else heap_insert does it */
419+
/* Force the OID if requested by caller */
413420
if (OidIsValid(newTypeOid))
414421
HeapTupleSetOid(tup,newTypeOid);
415-
422+
elseif (OidIsValid(binary_upgrade_next_pg_type_oid))
423+
{
424+
HeapTupleSetOid(tup,binary_upgrade_next_pg_type_oid);
425+
binary_upgrade_next_pg_type_oid=InvalidOid;
426+
}
427+
/* else allow system to assign oid */
428+
416429
typeObjectId=simple_heap_insert(pg_type_desc,tup);
417430
}
418431

‎src/backend/catalog/toasting.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.22 2009/12/23 02:35:18 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.23 2009/12/24 22:09:23 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,6 +31,7 @@
3131
#include"utils/builtins.h"
3232
#include"utils/syscache.h"
3333

34+
Oidbinary_upgrade_next_pg_type_toast_oid=InvalidOid;
3435

3536
staticboolcreate_toast_table(Relationrel,OidtoastOid,OidtoastIndexOid,
3637
Datumreloptions,boolforce);
@@ -121,6 +122,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
121122
Relationclass_rel;
122123
Oidtoast_relid;
123124
Oidtoast_idxid;
125+
Oidtoast_typid=InvalidOid;
124126
Oidnamespaceid;
125127
chartoast_relname[NAMEDATALEN];
126128
chartoast_idxname[NAMEDATALEN];
@@ -199,11 +201,17 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
199201
else
200202
namespaceid=PG_TOAST_NAMESPACE;
201203

204+
if (OidIsValid(binary_upgrade_next_pg_type_toast_oid))
205+
{
206+
toast_typid=binary_upgrade_next_pg_type_toast_oid;
207+
binary_upgrade_next_pg_type_toast_oid=InvalidOid;
208+
}
209+
202210
toast_relid=heap_create_with_catalog(toast_relname,
203211
namespaceid,
204212
rel->rd_rel->reltablespace,
205213
toastOid,
206-
InvalidOid,
214+
toast_typid,
207215
rel->rd_rel->relowner,
208216
tupdesc,
209217
NIL,

‎src/backend/commands/typecmds.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.140 2009/12/19 00:47:57 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.141 2009/12/24 22:09:23 momjian Exp $
1212
*
1313
* DESCRIPTION
1414
* The "DefineFoo" routines take the parse tree and pick out the
@@ -74,6 +74,7 @@ typedef struct
7474
/* atts[] is of allocated length RelationGetNumberOfAttributes(rel) */
7575
}RelToCheck;
7676

77+
Oidbinary_upgrade_next_pg_type_array_oid=InvalidOid;
7778

7879
staticOidfindTypeInputFunction(List*procname,OidtypeOid);
7980
staticOidfindTypeOutputFunction(List*procname,OidtypeOid);
@@ -143,7 +144,6 @@ DefineType(List *names, List *parameters)
143144
Oidarray_oid;
144145
Oidtypoid;
145146
Oidresulttype;
146-
Relationpg_type;
147147
ListCell*pl;
148148

149149
/*
@@ -522,10 +522,7 @@ DefineType(List *names, List *parameters)
522522
NameListToString(analyzeName));
523523
#endif
524524

525-
/* Preassign array type OID so we can insert it in pg_type.typarray */
526-
pg_type=heap_open(TypeRelationId,AccessShareLock);
527-
array_oid=GetNewOid(pg_type);
528-
heap_close(pg_type,AccessShareLock);
525+
array_oid=AssignTypeArrayOid();
529526

530527
/*
531528
* now have TypeCreate do all the real work.
@@ -1101,7 +1098,6 @@ DefineEnum(CreateEnumStmt *stmt)
11011098
AclResultaclresult;
11021099
Oidold_type_oid;
11031100
OidenumArrayOid;
1104-
Relationpg_type;
11051101

11061102
/* Convert list of names to a name and namespace */
11071103
enumNamespace=QualifiedNameGetCreationNamespace(stmt->typeName,
@@ -1129,10 +1125,7 @@ DefineEnum(CreateEnumStmt *stmt)
11291125
errmsg("type \"%s\" already exists",enumName)));
11301126
}
11311127

1132-
/* Preassign array type OID so we can insert it in pg_type.typarray */
1133-
pg_type=heap_open(TypeRelationId,AccessShareLock);
1134-
enumArrayOid=GetNewOid(pg_type);
1135-
heap_close(pg_type,AccessShareLock);
1128+
enumArrayOid=AssignTypeArrayOid();
11361129

11371130
/* Create the pg_type entry */
11381131
enumTypeOid=
@@ -1470,6 +1463,33 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid)
14701463
returnprocOid;
14711464
}
14721465

1466+
/*
1467+
*AssignTypeArrayOid
1468+
*
1469+
*Pre-assign the type's array OID for use in pg_type.typarray
1470+
*/
1471+
Oid
1472+
AssignTypeArrayOid(void)
1473+
{
1474+
Oidtype_array_oid;
1475+
1476+
/* Pre-assign the type's array OID for use in pg_type.typarray */
1477+
if (OidIsValid(binary_upgrade_next_pg_type_array_oid))
1478+
{
1479+
type_array_oid=binary_upgrade_next_pg_type_array_oid;
1480+
binary_upgrade_next_pg_type_array_oid=InvalidOid;
1481+
}
1482+
else
1483+
{
1484+
Relationpg_type=heap_open(TypeRelationId,AccessShareLock);
1485+
1486+
type_array_oid=GetNewOid(pg_type);
1487+
heap_close(pg_type,AccessShareLock);
1488+
}
1489+
1490+
returntype_array_oid;
1491+
}
1492+
14731493

14741494
/*-------------------------------------------------------------------
14751495
* DefineCompositeType

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp