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

Commit4985635

Browse files
committed
Extend the BKI infrastructure to allow system catalogs to be given
hand-assigned rowtype OIDs, even when they are not "bootstrapped" catalogsthat have handmade type rows in pg_type.h. Give pg_database such an OID.Restore the availability of C macros for the rowtype OIDs of the bootstrappedcatalogs. (These macros are now in the individual catalogs' .h files,though, not in pg_type.h.)This commit doesn't do anything especially useful by itself, but it'snecessary infrastructure for reverting some ill-considered changes inrelcache.c.
1 parentc2e228d commit4985635

File tree

20 files changed

+104
-61
lines changed

20 files changed

+104
-61
lines changed

‎doc/src/sgml/bki.sgml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.21 2007/02/01 00:28:16 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.22 2009/09/26 22:42:00 tgl Exp $ -->
22

33
<chapter id="bki">
44
<title><acronym>BKI</acronym> Backend Interface</title>
@@ -67,12 +67,13 @@
6767
<variablelist>
6868
<varlistentry>
6969
<term>
70-
<literal>create</>
70+
<literal>create</>
71+
<replaceable class="parameter">tablename</replaceable>
72+
<replaceable class="parameter">tableoid</replaceable>
7173
<optional><literal>bootstrap</></optional>
7274
<optional><literal>shared_relation</></optional>
7375
<optional><literal>without_oids</></optional>
74-
<replaceable class="parameter">tablename</replaceable>
75-
<replaceable class="parameter">tableoid</replaceable>
76+
<optional><literal>rowtype_oid</> <replaceable>oid</></optional>
7677
(<replaceable class="parameter">name1</replaceable> =
7778
<replaceable class="parameter">type1</replaceable> <optional>,
7879
<replaceable class="parameter">name2</replaceable> = <replaceable
@@ -121,6 +122,11 @@
121122
The table is created as shared if <literal>shared_relation</> is
122123
specified.
123124
It will have OIDs unless <literal>without_oids</> is specified.
125+
The table's rowtype OID (<structname>pg_type</> OID) can optionally
126+
be specified via the <literal>rowtype_oid</> clause; if not specified,
127+
an OID is automatically generated for it. (The <literal>rowtype_oid</>
128+
clause is useless if <literal>bootstrap</> is specified, but it can be
129+
provided anyway for documentation.)
124130
</para>
125131
</listitem>
126132
</varlistentry>

‎src/backend/bootstrap/bootparse.y

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.97 2009/07/29 20:56:18 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.98 2009/09/26 22:42:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -108,13 +108,13 @@ int num_columns_read = 0;
108108
%type<ival>boot_constboot_ident
109109
%type<ival>optbootstrapoptsharedrelationoptwithoutoids
110110
%type<ival>boot_tupleboot_tuplelist
111-
%type<oidval>oidspecoptoideq
111+
%type<oidval>oidspecoptoideqoptrowtypeoid
112112

113113
%token<ival>CONST_PID
114114
%tokenOPENXCLOSEXCREATEINSERT_TUPLE
115115
%tokenXDECLAREINDEXONUSINGXBUILDINDICESUNIQUEXTOAST
116116
%tokenCOMMAEQUALSLPARENRPAREN
117-
%tokenOBJ_IDXBOOTSTRAPXSHARED_RELATIONXWITHOUT_OIDSNULLVAL
117+
%tokenOBJ_IDXBOOTSTRAPXSHARED_RELATIONXWITHOUT_OIDSXROWTYPE_OIDNULLVAL
118118
%startTopLevel
119119

120120
%nonassoclow
@@ -168,15 +168,15 @@ Boot_CloseStmt:
168168
;
169169

170170
Boot_CreateStmt:
171-
XCREATEoptbootstrapoptsharedrelationoptwithoutoidsboot_identoidspecLPAREN
171+
XCREATEboot_identoidspecoptbootstrapoptsharedrelationoptwithoutoidsoptrowtypeoidLPAREN
172172
{
173173
do_start();
174174
numattr =0;
175175
elog(DEBUG4,"creating%s%s relation %s %u",
176-
$2 ?" bootstrap" :"",
177-
$3 ?" shared" :"",
178-
LexIDStr($5),
179-
$6);
176+
$4 ?" bootstrap" :"",
177+
$5 ?" shared" :"",
178+
LexIDStr($2),
179+
$3);
180180
}
181181
boot_typelist
182182
{
@@ -188,39 +188,40 @@ Boot_CreateStmt:
188188

189189
do_start();
190190

191-
tupdesc =CreateTupleDesc(numattr, !($4), attrtypes);
191+
tupdesc =CreateTupleDesc(numattr, !($6), attrtypes);
192192

193-
if ($2)
193+
if ($4)
194194
{
195195
if (boot_reldesc)
196196
{
197197
elog(DEBUG4,"create bootstrap: warning, open relation exists, closing first");
198198
closerel(NULL);
199199
}
200200

201-
boot_reldesc =heap_create(LexIDStr($5),
201+
boot_reldesc =heap_create(LexIDStr($2),
202202
PG_CATALOG_NAMESPACE,
203-
$3 ? GLOBALTABLESPACE_OID :0,
204-
$6,
203+
$5 ? GLOBALTABLESPACE_OID :0,
204+
$3,
205205
tupdesc,
206206
RELKIND_RELATION,
207-
$3,
207+
$5,
208208
true);
209209
elog(DEBUG4,"bootstrap relation created");
210210
}
211211
else
212212
{
213213
Oid id;
214214

215-
id =heap_create_with_catalog(LexIDStr($5),
215+
id =heap_create_with_catalog(LexIDStr($2),
216216
PG_CATALOG_NAMESPACE,
217-
$3 ? GLOBALTABLESPACE_OID :0,
218-
$6,
217+
$5 ? GLOBALTABLESPACE_OID :0,
218+
$3,
219+
$7,
219220
BOOTSTRAP_SUPERUSERID,
220221
tupdesc,
221222
NIL,
222223
RELKIND_RELATION,
223-
$3,
224+
$5,
224225
true,
225226
0,
226227
ONCOMMIT_NOOP,
@@ -343,6 +344,11 @@ optwithoutoids:
343344
|{ $$ =0; }
344345
;
345346

347+
optrowtypeoid:
348+
XROWTYPE_OID oidspec{ $$ = $2; }
349+
|{ $$ = InvalidOid; }
350+
;
351+
346352
boot_typelist:
347353
boot_type_thing
348354
| boot_typelist COMMA boot_type_thing
@@ -363,7 +369,7 @@ oidspec:
363369

364370
optoideq:
365371
OBJ_ID EQUALS oidspec{ $$ = $3; }
366-
|{ $$ =(Oid)0; }
372+
|{ $$ =InvalidOid; }
367373
;
368374

369375
boot_tuplelist:

‎src/backend/bootstrap/bootscanner.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.48 2009/01/01 17:23:36 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.49 2009/09/26 22:42:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -77,6 +77,7 @@ OID{ return(OBJ_ID); }
7777
bootstrap{return(XBOOTSTRAP); }
7878
"shared_relation"{return(XSHARED_RELATION); }
7979
"without_oids"{return(XWITHOUT_OIDS); }
80+
"rowtype_oid"{return(XROWTYPE_OID); }
8081
_null_{return(NULLVAL); }
8182

8283
insert{return(INSERT_TUPLE); }

‎src/backend/catalog/genbki.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.46 2009/01/01 17:23:36 momjian Exp $
14+
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.47 2009/09/26 22:42:01 tgl Exp $
1515
#
1616
# NOTES
1717
# non-essential whitespace is removed from the generated file.
@@ -178,6 +178,7 @@ BEGIN {
178178
bootstrap = "";
179179
shared_relation = "";
180180
without_oids = "";
181+
rowtype_oid = "";
181182
nc = 0;
182183
reln_open = 0;
183184
comment_level = 0;
@@ -319,13 +320,16 @@ comment_level > 0 { next; }
319320
oid = substr(catalogandoid, pos+1, length(catalogandoid)-pos);
320321
321322
if ($0 ~ /BKI_BOOTSTRAP/) {
322-
bootstrap = "bootstrap";
323+
bootstrap = " bootstrap";
323324
}
324325
if ($0 ~ /BKI_SHARED_RELATION/) {
325-
shared_relation = "shared_relation";
326+
shared_relation = " shared_relation";
326327
}
327328
if ($0 ~ /BKI_WITHOUT_OIDS/) {
328-
without_oids = "without_oids ";
329+
without_oids = " without_oids";
330+
}
331+
if ($0 ~ /BKI_ROWTYPE_OID\([0-9]*\)/) {
332+
rowtype_oid = gensub(/^.*BKI_ROWTYPE_OID\(([0-9]*)\).*$/, " rowtype_oid \\1", 1);
329333
}
330334
331335
i = 1;
@@ -351,7 +355,7 @@ inside == 1 {
351355
# if this is the last line, then output the bki catalog stuff.
352356
# ----
353357
if ($1 ~ /}/) {
354-
print "create "bootstrap shared_relation without_oidscatalog " " oid;
358+
print "create " catalog " " oid bootstrap shared_relation without_oids rowtype_oid;
355359
print "\t(";
356360
357361
for (j=1; j<i-1; j++) {
@@ -370,6 +374,7 @@ inside == 1 {
370374
bootstrap = "";
371375
shared_relation = "";
372376
without_oids = "";
377+
rowtype_oid = "";
373378
next;
374379
}
375380

‎src/backend/catalog/heap.c

Lines changed: 9 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/heap.c,v 1.358 2009/08/23 19:23:40 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.359 2009/09/26 22:42:01 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -80,6 +80,7 @@ static Oid AddNewRelationType(const char *typeName,
8080
Oidnew_rel_oid,
8181
charnew_rel_kind,
8282
Oidownerid,
83+
Oidnew_row_type,
8384
Oidnew_array_type);
8485
staticvoidRelationRemoveInheritance(Oidrelid);
8586
staticvoidStoreRelCheck(Relationrel,char*ccname,Node*expr,
@@ -790,10 +791,11 @@ AddNewRelationType(const char *typeName,
790791
Oidnew_rel_oid,
791792
charnew_rel_kind,
792793
Oidownerid,
794+
Oidnew_row_type,
793795
Oidnew_array_type)
794796
{
795797
return
796-
TypeCreate(InvalidOid,/*no predetermined OID */
798+
TypeCreate(new_row_type,/*optional predetermined OID */
797799
typeName,/* type name */
798800
typeNamespace,/* type namespace */
799801
new_rel_oid,/* relation oid */
@@ -836,6 +838,7 @@ heap_create_with_catalog(const char *relname,
836838
Oidrelnamespace,
837839
Oidreltablespace,
838840
Oidrelid,
841+
Oidreltypeid,
839842
Oidownerid,
840843
TupleDesctupdesc,
841844
List*cooked_constraints,
@@ -952,7 +955,9 @@ heap_create_with_catalog(const char *relname,
952955

953956
/*
954957
* Since defining a relation also defines a complex type, we add a new
955-
* system type corresponding to the new relation.
958+
* system type corresponding to the new relation. The OID of the type
959+
* can be preselected by the caller, but if reltypeid is InvalidOid,
960+
* we'll generate a new OID for it.
956961
*
957962
* NOTE: we could get a unique-index failure here, in case someone else is
958963
* creating the same type name in parallel but hadn't committed yet when
@@ -963,6 +968,7 @@ heap_create_with_catalog(const char *relname,
963968
relid,
964969
relkind,
965970
ownerid,
971+
reltypeid,
966972
new_array_oid);
967973

968974
/*

‎src/backend/catalog/toasting.c

Lines changed: 2 additions & 1 deletion
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.18 2009/07/29 20:56:18 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.19 2009/09/26 22:42:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -203,6 +203,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
203203
namespaceid,
204204
rel->rd_rel->reltablespace,
205205
toastOid,
206+
InvalidOid,
206207
rel->rd_rel->relowner,
207208
tupdesc,
208209
NIL,

‎src/backend/commands/cluster.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186 2009/06/11 20:46:11 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.187 2009/09/26 22:42:01 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -703,6 +703,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace)
703703
RelationGetNamespace(OldHeap),
704704
NewTableSpace,
705705
InvalidOid,
706+
InvalidOid,
706707
OldHeap->rd_rel->relowner,
707708
tupdesc,
708709
NIL,

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.298 2009/08/23 19:23:41 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.299 2009/09/26 22:42:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -510,6 +510,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
510510
namespaceId,
511511
tablespaceId,
512512
InvalidOid,
513+
InvalidOid,
513514
GetUserId(),
514515
descriptor,
515516
list_concat(cookedDefaults,

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.327 2009/07/29 20:56:18 tgl Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.328 2009/09/26 22:42:01 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -2925,6 +2925,7 @@ OpenIntoRel(QueryDesc *queryDesc)
29252925
namespaceId,
29262926
tablespaceId,
29272927
InvalidOid,
2928+
InvalidOid,
29282929
GetUserId(),
29292930
tupdesc,
29302931
NIL,

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.539 2009/09/22 23:43:41 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.540 2009/09/26 22:42:01 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200909221
56+
#defineCATALOG_VERSION_NO200909261
5757

5858
#endif

‎src/include/catalog/duplicate_oids

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
#
33
# duplicate_oids
44
#
5-
# $PostgreSQL: pgsql/src/include/catalog/duplicate_oids,v 1.8 2006/07/31 01:16:37 tgl Exp $
5+
# $PostgreSQL: pgsql/src/include/catalog/duplicate_oids,v 1.9 2009/09/26 22:42:01 tgl Exp $
66
#
77
# finds manually-assigned oids that are duplicated in the system tables.
88
#
99
# run this script in src/include/catalog.
1010
#
1111

1212
# note: we exclude BKI_BOOTSTRAP relations since they are expected to have
13-
# matching DATA lines in pg_class.h
13+
# matching DATA lines in pg_class.h and pg_type.h
1414

1515
cat pg_*.h toasting.h indexing.h| \
1616
egrep -v -e'^CATALOG\(.*BKI_BOOTSTRAP'| \
1717
sed -n-e's/^DATA(insert *OID *= *\([0-9][0-9]*\).*$/\1/p' \
18+
-e's/^CATALOG([^,]*, *\([0-9][0-9]*\).*BKI_ROWTYPE_OID(\([0-9][0-9]*\)).*$/\1,\2/p' \
1819
-e's/^CATALOG([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
1920
-e's/^DECLARE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
2021
-e's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp