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

Commitc06f6a6

Browse files
committed
Support toasting of shared system relations, and provide toast tables for
pg_database, pg_shadow, pg_group, all of which now have potentially-longfields. Along the way, get rid of SharedSystemRelationNames list: sharedrels are now identified in their include/pg_catalog/*.h files by aBKI_SHARED_RELATION macro, while indexes and toast rels inherit sharednessautomatically from their parent table. Fix some bugs with failure to detoastpg_group.grolist during ALTER GROUP.
1 parent108871f commitc06f6a6

File tree

27 files changed

+403
-531
lines changed

27 files changed

+403
-531
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
%{
22
/*-------------------------------------------------------------------------
33
*
4-
*backendparse.y
5-
* yacc parsergrammer for the "backend" initialization program.
4+
*bootparse.y
5+
* yacc parsergrammar for the "backend" initialization program.
66
*
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.45 2002/04/17 20:57:56 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.46 2002/04/27 21:24:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -88,16 +88,17 @@ int num_columns_read = 0;
8888

8989
%type<list>boot_index_params
9090
%type<ielem>boot_index_param
91-
%type<ival>boot_constboot_ident
92-
%type<ival>optbootstrapoptwithoutoidsboot_tupleboot_tuplelist
91+
%type<ival>boot_constboot_ident
92+
%type<ival>optbootstrapoptsharedrelationoptwithoutoids
93+
%type<ival>boot_tupleboot_tuplelist
9394
%type<oidval>optoideq
9495

9596
%token<ival>CONSTID
9697
%tokenOPENXCLOSEXCREATEINSERT_TUPLE
9798
%tokenSTRINGXDEFINE
9899
%tokenXDECLAREINDEXONUSINGXBUILDINDICESUNIQUE
99100
%tokenCOMMAEQUALSLPARENRPAREN
100-
%tokenOBJ_IDXBOOTSTRAPXWITHOUT_OIDSNULLVAL
101+
%tokenOBJ_IDXBOOTSTRAPXSHARED_RELATIONXWITHOUT_OIDSNULLVAL
101102
%startTopLevel
102103

103104
%nonassoclow
@@ -150,16 +151,14 @@ Boot_CloseStmt:
150151
;
151152

152153
Boot_CreateStmt:
153-
XCREATEoptbootstrapoptwithoutoidsboot_identLPAREN
154+
XCREATEoptbootstrapoptsharedrelationoptwithoutoidsboot_identLPAREN
154155
{
155156
do_start();
156157
numattr =0;
157-
if ($2)
158-
elog(DEBUG3,"creating bootstrap relation %s...",
159-
LexIDStr($4));
160-
else
161-
elog(DEBUG3,"creating relation %s...",
162-
LexIDStr($4));
158+
elog(DEBUG3,"creating%s%s relation %s...",
159+
$2 ?" bootstrap" :"",
160+
$3 ?" shared" :"",
161+
LexIDStr($5));
163162
}
164163
boot_typelist
165164
{
@@ -171,21 +170,22 @@ Boot_CreateStmt:
171170

172171
if ($2)
173172
{
174-
extern Relation reldesc;
175173
TupleDesc tupdesc;
176174

177-
if (reldesc)
175+
if (boot_reldesc)
178176
{
179177
elog(DEBUG3,"create bootstrap: warning, open relation exists, closing first");
180178
closerel(NULL);
181179
}
182180

183181
tupdesc =CreateTupleDesc(numattr, attrtypes);
184-
reldesc =heap_create(LexIDStr($4),
185-
PG_CATALOG_NAMESPACE,
186-
tupdesc,
187-
true,true);
188-
reldesc->rd_rel->relhasoids = ! ($3);
182+
boot_reldesc =heap_create(LexIDStr($5),
183+
PG_CATALOG_NAMESPACE,
184+
tupdesc,
185+
$3,
186+
true,
187+
true);
188+
boot_reldesc->rd_rel->relhasoids = ! ($4);
189189
elog(DEBUG3,"bootstrap relation created");
190190
}
191191
else
@@ -194,11 +194,12 @@ Boot_CreateStmt:
194194
TupleDesc tupdesc;
195195

196196
tupdesc =CreateTupleDesc(numattr,attrtypes);
197-
id =heap_create_with_catalog(LexIDStr($4),
197+
id =heap_create_with_catalog(LexIDStr($5),
198198
PG_CATALOG_NAMESPACE,
199199
tupdesc,
200200
RELKIND_RELATION,
201-
! ($3),
201+
$3,
202+
! ($4),
202203
true);
203204
elog(DEBUG3,"relation created with oid %u", id);
204205
}
@@ -221,7 +222,7 @@ Boot_InsertStmt:
221222
if (num_columns_read != numattr)
222223
elog(ERROR,"incorrect number of columns in row (expected %d, got %d)",
223224
numattr, num_columns_read);
224-
if (reldesc == (Relation)NULL)
225+
if (boot_reldesc == (Relation)NULL)
225226
{
226227
elog(ERROR,"relation not open");
227228
err_out();
@@ -283,6 +284,11 @@ optbootstrap:
283284
|{ $$ =0; }
284285
;
285286

287+
optsharedrelation:
288+
XSHARED_RELATION{ $$ =1; }
289+
|{ $$ =0; }
290+
;
291+
286292
optwithoutoids:
287293
XWITHOUT_OIDS{ $$ =1; }
288294
|{ $$ =0; }

‎src/backend/bootstrap/bootscanner.l

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.21 2001/08/10 18:57:33 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.22 2002/04/27 21:24:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -71,6 +71,8 @@ create{ return(XCREATE); }
7171

7272
OID{return(OBJ_ID); }
7373
bootstrap{return(XBOOTSTRAP); }
74+
"shared_relation"{return(XSHARED_RELATION); }
75+
"without_oids"{return(XWITHOUT_OIDS); }
7476
_null_{return(NULLVAL); }
7577

7678
insert{return(INSERT_TUPLE); }
@@ -94,7 +96,6 @@ insert{ return(INSERT_TUPLE); }
9496
"index"{return(INDEX); }
9597
"on"{return(ON); }
9698
"using"{return(USING); }
97-
"without_oids"{return(XWITHOUT_OIDS); }
9899

99100
{arrayid}{
100101
yylval.ival =EnterString(MapArrayTypeName((char*)yytext));

‎src/backend/bootstrap/bootstrap.c

Lines changed: 22 additions & 18 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-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.126 2002/04/25 02:56:55 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.127 2002/04/27 21:24:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -59,6 +59,9 @@ static void cleanup(void);
5959
*global variables
6060
* ----------------
6161
*/
62+
63+
Relationboot_reldesc;/* current relation descriptor */
64+
6265
/*
6366
* In the lexical analyzer, we need to get the reference number quickly from
6467
* the string, and the string from the reference number. Thus we have
@@ -500,20 +503,20 @@ boot_openrel(char *relname)
500503
heap_close(rel,NoLock);
501504
}
502505

503-
if (reldesc!=NULL)
506+
if (boot_reldesc!=NULL)
504507
closerel(NULL);
505508

506509
elog(DEBUG3,"open relation %s, attrsize %d",relname ?relname :"(null)",
507510
(int)ATTRIBUTE_TUPLE_SIZE);
508511

509-
reldesc=heap_openr(relname,NoLock);
510-
numattr=reldesc->rd_rel->relnatts;
512+
boot_reldesc=heap_openr(relname,NoLock);
513+
numattr=boot_reldesc->rd_rel->relnatts;
511514
for (i=0;i<numattr;i++)
512515
{
513516
if (attrtypes[i]==NULL)
514517
attrtypes[i]=AllocateAttribute();
515518
memmove((char*)attrtypes[i],
516-
(char*)reldesc->rd_att->attrs[i],
519+
(char*)boot_reldesc->rd_att->attrs[i],
517520
ATTRIBUTE_TUPLE_SIZE);
518521

519522
/* Some old pg_attribute tuples might not have attisset. */
@@ -523,8 +526,9 @@ boot_openrel(char *relname)
523526
* defined yet.
524527
*/
525528
if (namestrcmp(&attrtypes[i]->attname,"attisset")==0)
526-
attrtypes[i]->attisset=get_attisset(RelationGetRelid(reldesc),
527-
NameStr(attrtypes[i]->attname));
529+
attrtypes[i]->attisset=
530+
get_attisset(RelationGetRelid(boot_reldesc),
531+
NameStr(attrtypes[i]->attname));
528532
else
529533
attrtypes[i]->attisset= false;
530534

@@ -547,9 +551,9 @@ closerel(char *name)
547551
{
548552
if (name)
549553
{
550-
if (reldesc)
554+
if (boot_reldesc)
551555
{
552-
if (strcmp(RelationGetRelationName(reldesc),name)!=0)
556+
if (strcmp(RelationGetRelationName(boot_reldesc),name)!=0)
553557
elog(ERROR,"closerel: close of '%s' when '%s' was expected",
554558
name,relname ?relname :"(null)");
555559
}
@@ -559,13 +563,13 @@ closerel(char *name)
559563

560564
}
561565

562-
if (reldesc==NULL)
566+
if (boot_reldesc==NULL)
563567
elog(ERROR,"no open relation to close");
564568
else
565569
{
566570
elog(DEBUG3,"close relation %s",relname ?relname :"(null)");
567-
heap_close(reldesc,NoLock);
568-
reldesc= (Relation)NULL;
571+
heap_close(boot_reldesc,NoLock);
572+
boot_reldesc= (Relation)NULL;
569573
}
570574
}
571575

@@ -585,7 +589,7 @@ DefineAttr(char *name, char *type, int attnum)
585589
intattlen;
586590
Oidtypeoid;
587591

588-
if (reldesc!=NULL)
592+
if (boot_reldesc!=NULL)
589593
{
590594
elog(LOG,"warning: no open relations allowed with 'create' command");
591595
closerel(relname);
@@ -674,7 +678,7 @@ InsertOneTuple(Oid objectid)
674678

675679
if (objectid!= (Oid)0)
676680
tuple->t_data->t_oid=objectid;
677-
heap_insert(reldesc,tuple);
681+
heap_insert(boot_reldesc,tuple);
678682
heap_freetuple(tuple);
679683
elog(DEBUG3,"row inserted");
680684

@@ -706,13 +710,13 @@ InsertOneValue(char *value, int i)
706710

707711
elog(DEBUG3,"Typ != NULL");
708712
app=Typ;
709-
while (*app&& (*app)->am_oid!=reldesc->rd_att->attrs[i]->atttypid)
713+
while (*app&& (*app)->am_oid!=boot_reldesc->rd_att->attrs[i]->atttypid)
710714
++app;
711715
ap=*app;
712716
if (ap==NULL)
713717
{
714718
elog(FATAL,"unable to find atttypid %u in Typ list",
715-
reldesc->rd_att->attrs[i]->atttypid);
719+
boot_reldesc->rd_att->attrs[i]->atttypid);
716720
}
717721
values[i]=OidFunctionCall3(ap->am_typ.typinput,
718722
CStringGetDatum(value),
@@ -806,8 +810,8 @@ cleanup()
806810
elog(FATAL,"Memory manager fault: cleanup called twice.\n");
807811
proc_exit(1);
808812
}
809-
if (reldesc!= (Relation)NULL)
810-
heap_close(reldesc,NoLock);
813+
if (boot_reldesc!= (Relation)NULL)
814+
heap_close(boot_reldesc,NoLock);
811815
CommitTransactionCommand();
812816
proc_exit(Warnings);
813817
}

‎src/backend/catalog/README

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$Header: /cvsroot/pgsql/src/backend/catalog/README,v 1.6 2002/04/15 23:46:13 momjian Exp $
1+
$Header: /cvsroot/pgsql/src/backend/catalog/README,v 1.7 2002/04/27 21:24:33 tgl Exp $
22

33
This directory contains .c files that manipulate the system catalogs;
44
src/include/catalog contains the .h files that define the structure
@@ -69,15 +69,14 @@ manually create appropriate entries for them in the pre-loaded contents of
6969
pg_class, pg_attribute, and pg_type. You'll also need to add code to function
7070
heap_create() in heap.c to force the correct OID to be assigned when the table
7171
is first referenced. (It's near the top of the function with the comment
72-
beginning in'Real ugly stuff'.) Avoid making new catalogs be bootstrap
72+
beginning in"Real ugly stuff".) Avoid making new catalogs be bootstrap
7373
catalogs if at all possible; generally, only tables that must be written to
7474
in order to create a table should be bootstrapped.
7575

7676
- Certain BOOTSTRAP tables must be at the start of the Makefile
77-
POSTGRES_BKI_SRCS variable, as these will not be created through standard
78-
function means, but will be written directly to disk. That's how pg_class is
79-
created without depending on functions which depend on the existence of
80-
pg_class. The list of files this currently includes is:
77+
POSTGRES_BKI_SRCS variable, as these will not be created through the standard
78+
heap_create_with_catalog process, because it needs these tables to exist
79+
already. The list of files this currently includes is:
8180
pg_proc.h pg_type.h pg_attribute.h pg_class.h
8281
Also, indexing.h must be last, since the indexes can't be created until all
8382
the tables are in place. There are reputedly some other order dependencies

‎src/backend/catalog/catalog.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.45 2002/04/12 20:38:18 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.46 2002/04/27 21:24:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -177,29 +177,6 @@ IsReservedName(const char *name)
177177
name[2]=='_');
178178
}
179179

180-
/*
181-
* IsSharedSystemRelationName
182-
*True iff name is the name of a shared system catalog relation.
183-
*
184-
*Note: This function assumes that this is a system relation
185-
*in the first place. If that is not known, check the namespace
186-
*(with IsSystemNamespace) before calling this function.
187-
*/
188-
bool
189-
IsSharedSystemRelationName(constchar*relname)
190-
{
191-
inti;
192-
193-
i=0;
194-
while (SharedSystemRelationNames[i]!=NULL)
195-
{
196-
if (strcmp(SharedSystemRelationNames[i],relname)==0)
197-
return TRUE;
198-
i++;
199-
}
200-
return FALSE;
201-
}
202-
203180

204181
/*
205182
*newoid- returns a unique identifier across all catalogs.

‎src/backend/catalog/genbki.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
#
1212
# IDENTIFICATION
13-
# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.26 2002/03/26 19:15:24 tgl Exp $
13+
# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.27 2002/04/27 21:24:33 tgl Exp $
1414
#
1515
# NOTES
1616
# non-essential whitespace is removed from the generated file.
@@ -217,6 +217,7 @@ BEGIN {
217217
inside = 0;
218218
raw = 0;
219219
bootstrap = "";
220+
shared_relation = "";
220221
without_oids = "";
221222
nc = 0;
222223
reln_open = 0;
@@ -331,6 +332,9 @@ raw == 1 { print; next; }
331332
if ($0 ~ /BOOTSTRAP/) {
332333
bootstrap = "bootstrap ";
333334
}
335+
if ($0 ~ /BKI_SHARED_RELATION/) {
336+
shared_relation = "shared_relation ";
337+
}
334338
if ($0 ~ /BKI_WITHOUT_OIDS/) {
335339
without_oids = "without_oids ";
336340
}
@@ -358,7 +362,7 @@ inside == 1 {
358362
# if this is the last line, then output the bki catalog stuff.
359363
# ----
360364
if ($1 ~ /}/) {
361-
print "create " bootstrap without_oids catalog;
365+
print "create " bootstrapshared_relationwithout_oids catalog;
362366
print "\t(";
363367
364368
for (j=1; j<i-1; j++) {
@@ -375,6 +379,7 @@ inside == 1 {
375379
reln_open = 1;
376380
inside = 0;
377381
bootstrap = "";
382+
shared_relation = "";
378383
without_oids = "";
379384
next;
380385
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp