mirror of
https://github.com/postgres/postgres.git
synced 2025-11-29 23:43:17 +03:00
Extend the BKI infrastructure to allow system catalogs to be given
hand-assigned rowtype OIDs, even when they are not "bootstrapped" catalogs that 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 bootstrapped catalogs. (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's necessary infrastructure for reverting some ill-considered changes in relcache.c.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.97 2009/07/29 20:56:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.98 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -108,13 +108,13 @@ int num_columns_read = 0;
|
||||
%type <ival> boot_const boot_ident
|
||||
%type <ival> optbootstrap optsharedrelation optwithoutoids
|
||||
%type <ival> boot_tuple boot_tuplelist
|
||||
%type <oidval> oidspec optoideq
|
||||
%type <oidval> oidspec optoideq optrowtypeoid
|
||||
|
||||
%token <ival> CONST_P ID
|
||||
%token OPEN XCLOSE XCREATE INSERT_TUPLE
|
||||
%token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE XTOAST
|
||||
%token COMMA EQUALS LPAREN RPAREN
|
||||
%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS NULLVAL
|
||||
%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS XROWTYPE_OID NULLVAL
|
||||
%start TopLevel
|
||||
|
||||
%nonassoc low
|
||||
@@ -168,15 +168,15 @@ Boot_CloseStmt:
|
||||
;
|
||||
|
||||
Boot_CreateStmt:
|
||||
XCREATE optbootstrap optsharedrelation optwithoutoids boot_ident oidspec LPAREN
|
||||
XCREATE boot_ident oidspec optbootstrap optsharedrelation optwithoutoids optrowtypeoid LPAREN
|
||||
{
|
||||
do_start();
|
||||
numattr = 0;
|
||||
elog(DEBUG4, "creating%s%s relation %s %u",
|
||||
$2 ? " bootstrap" : "",
|
||||
$3 ? " shared" : "",
|
||||
LexIDStr($5),
|
||||
$6);
|
||||
$4 ? " bootstrap" : "",
|
||||
$5 ? " shared" : "",
|
||||
LexIDStr($2),
|
||||
$3);
|
||||
}
|
||||
boot_typelist
|
||||
{
|
||||
@@ -188,9 +188,9 @@ Boot_CreateStmt:
|
||||
|
||||
do_start();
|
||||
|
||||
tupdesc = CreateTupleDesc(numattr, !($4), attrtypes);
|
||||
tupdesc = CreateTupleDesc(numattr, !($6), attrtypes);
|
||||
|
||||
if ($2)
|
||||
if ($4)
|
||||
{
|
||||
if (boot_reldesc)
|
||||
{
|
||||
@@ -198,13 +198,13 @@ Boot_CreateStmt:
|
||||
closerel(NULL);
|
||||
}
|
||||
|
||||
boot_reldesc = heap_create(LexIDStr($5),
|
||||
boot_reldesc = heap_create(LexIDStr($2),
|
||||
PG_CATALOG_NAMESPACE,
|
||||
$3 ? GLOBALTABLESPACE_OID : 0,
|
||||
$6,
|
||||
$5 ? GLOBALTABLESPACE_OID : 0,
|
||||
$3,
|
||||
tupdesc,
|
||||
RELKIND_RELATION,
|
||||
$3,
|
||||
$5,
|
||||
true);
|
||||
elog(DEBUG4, "bootstrap relation created");
|
||||
}
|
||||
@@ -212,15 +212,16 @@ Boot_CreateStmt:
|
||||
{
|
||||
Oid id;
|
||||
|
||||
id = heap_create_with_catalog(LexIDStr($5),
|
||||
id = heap_create_with_catalog(LexIDStr($2),
|
||||
PG_CATALOG_NAMESPACE,
|
||||
$3 ? GLOBALTABLESPACE_OID : 0,
|
||||
$6,
|
||||
$5 ? GLOBALTABLESPACE_OID : 0,
|
||||
$3,
|
||||
$7,
|
||||
BOOTSTRAP_SUPERUSERID,
|
||||
tupdesc,
|
||||
NIL,
|
||||
RELKIND_RELATION,
|
||||
$3,
|
||||
$5,
|
||||
true,
|
||||
0,
|
||||
ONCOMMIT_NOOP,
|
||||
@@ -343,6 +344,11 @@ optwithoutoids:
|
||||
| { $$ = 0; }
|
||||
;
|
||||
|
||||
optrowtypeoid:
|
||||
XROWTYPE_OID oidspec { $$ = $2; }
|
||||
| { $$ = InvalidOid; }
|
||||
;
|
||||
|
||||
boot_typelist:
|
||||
boot_type_thing
|
||||
| boot_typelist COMMA boot_type_thing
|
||||
@@ -363,7 +369,7 @@ oidspec:
|
||||
|
||||
optoideq:
|
||||
OBJ_ID EQUALS oidspec { $$ = $3; }
|
||||
| { $$ = (Oid) 0; }
|
||||
| { $$ = InvalidOid; }
|
||||
;
|
||||
|
||||
boot_tuplelist:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.48 2009/01/01 17:23:36 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.49 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -77,6 +77,7 @@ OID { return(OBJ_ID); }
|
||||
bootstrap { return(XBOOTSTRAP); }
|
||||
"shared_relation" { return(XSHARED_RELATION); }
|
||||
"without_oids" { return(XWITHOUT_OIDS); }
|
||||
"rowtype_oid" { return(XROWTYPE_OID); }
|
||||
_null_ { return(NULLVAL); }
|
||||
|
||||
insert { return(INSERT_TUPLE); }
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.46 2009/01/01 17:23:36 momjian Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.47 2009/09/26 22:42:01 tgl Exp $
|
||||
#
|
||||
# NOTES
|
||||
# non-essential whitespace is removed from the generated file.
|
||||
@@ -178,6 +178,7 @@ BEGIN {
|
||||
bootstrap = "";
|
||||
shared_relation = "";
|
||||
without_oids = "";
|
||||
rowtype_oid = "";
|
||||
nc = 0;
|
||||
reln_open = 0;
|
||||
comment_level = 0;
|
||||
@@ -319,13 +320,16 @@ comment_level > 0 { next; }
|
||||
oid = substr(catalogandoid, pos+1, length(catalogandoid)-pos);
|
||||
|
||||
if ($0 ~ /BKI_BOOTSTRAP/) {
|
||||
bootstrap = "bootstrap ";
|
||||
bootstrap = " bootstrap";
|
||||
}
|
||||
if ($0 ~ /BKI_SHARED_RELATION/) {
|
||||
shared_relation = "shared_relation ";
|
||||
shared_relation = " shared_relation";
|
||||
}
|
||||
if ($0 ~ /BKI_WITHOUT_OIDS/) {
|
||||
without_oids = "without_oids ";
|
||||
without_oids = " without_oids";
|
||||
}
|
||||
if ($0 ~ /BKI_ROWTYPE_OID\([0-9]*\)/) {
|
||||
rowtype_oid = gensub(/^.*BKI_ROWTYPE_OID\(([0-9]*)\).*$/, " rowtype_oid \\1", 1);
|
||||
}
|
||||
|
||||
i = 1;
|
||||
@@ -351,7 +355,7 @@ inside == 1 {
|
||||
# if this is the last line, then output the bki catalog stuff.
|
||||
# ----
|
||||
if ($1 ~ /}/) {
|
||||
print "create " bootstrap shared_relation without_oids catalog " " oid;
|
||||
print "create " catalog " " oid bootstrap shared_relation without_oids rowtype_oid;
|
||||
print "\t(";
|
||||
|
||||
for (j=1; j<i-1; j++) {
|
||||
@@ -370,6 +374,7 @@ inside == 1 {
|
||||
bootstrap = "";
|
||||
shared_relation = "";
|
||||
without_oids = "";
|
||||
rowtype_oid = "";
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.358 2009/08/23 19:23:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.359 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -80,6 +80,7 @@ static Oid AddNewRelationType(const char *typeName,
|
||||
Oid new_rel_oid,
|
||||
char new_rel_kind,
|
||||
Oid ownerid,
|
||||
Oid new_row_type,
|
||||
Oid new_array_type);
|
||||
static void RelationRemoveInheritance(Oid relid);
|
||||
static void StoreRelCheck(Relation rel, char *ccname, Node *expr,
|
||||
@@ -790,10 +791,11 @@ AddNewRelationType(const char *typeName,
|
||||
Oid new_rel_oid,
|
||||
char new_rel_kind,
|
||||
Oid ownerid,
|
||||
Oid new_row_type,
|
||||
Oid new_array_type)
|
||||
{
|
||||
return
|
||||
TypeCreate(InvalidOid, /* no predetermined OID */
|
||||
TypeCreate(new_row_type, /* optional predetermined OID */
|
||||
typeName, /* type name */
|
||||
typeNamespace, /* type namespace */
|
||||
new_rel_oid, /* relation oid */
|
||||
@@ -836,6 +838,7 @@ heap_create_with_catalog(const char *relname,
|
||||
Oid relnamespace,
|
||||
Oid reltablespace,
|
||||
Oid relid,
|
||||
Oid reltypeid,
|
||||
Oid ownerid,
|
||||
TupleDesc tupdesc,
|
||||
List *cooked_constraints,
|
||||
@@ -952,7 +955,9 @@ heap_create_with_catalog(const char *relname,
|
||||
|
||||
/*
|
||||
* Since defining a relation also defines a complex type, we add a new
|
||||
* system type corresponding to the new relation.
|
||||
* system type corresponding to the new relation. The OID of the type
|
||||
* can be preselected by the caller, but if reltypeid is InvalidOid,
|
||||
* we'll generate a new OID for it.
|
||||
*
|
||||
* NOTE: we could get a unique-index failure here, in case someone else is
|
||||
* creating the same type name in parallel but hadn't committed yet when
|
||||
@@ -963,6 +968,7 @@ heap_create_with_catalog(const char *relname,
|
||||
relid,
|
||||
relkind,
|
||||
ownerid,
|
||||
reltypeid,
|
||||
new_array_oid);
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.18 2009/07/29 20:56:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.19 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -203,6 +203,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
|
||||
namespaceid,
|
||||
rel->rd_rel->reltablespace,
|
||||
toastOid,
|
||||
InvalidOid,
|
||||
rel->rd_rel->relowner,
|
||||
tupdesc,
|
||||
NIL,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.186 2009/06/11 20:46:11 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.187 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -703,6 +703,7 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace)
|
||||
RelationGetNamespace(OldHeap),
|
||||
NewTableSpace,
|
||||
InvalidOid,
|
||||
InvalidOid,
|
||||
OldHeap->rd_rel->relowner,
|
||||
tupdesc,
|
||||
NIL,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.298 2009/08/23 19:23:41 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.299 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -510,6 +510,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
namespaceId,
|
||||
tablespaceId,
|
||||
InvalidOid,
|
||||
InvalidOid,
|
||||
GetUserId(),
|
||||
descriptor,
|
||||
list_concat(cookedDefaults,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.327 2009/07/29 20:56:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.328 2009/09/26 22:42:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -2925,6 +2925,7 @@ OpenIntoRel(QueryDesc *queryDesc)
|
||||
namespaceId,
|
||||
tablespaceId,
|
||||
InvalidOid,
|
||||
InvalidOid,
|
||||
GetUserId(),
|
||||
tupdesc,
|
||||
NIL,
|
||||
|
||||
Reference in New Issue
Block a user