Skip to content

Commit 108a0ec

Browse files
committed
A little further progress on schemas: push down RangeVars into
addRangeTableEntry calls. Remove relname field from RTEs, since it will no longer be a useful unique identifier of relations; we want to encourage people to rely on the relation OID instead. Further work on dumping qual expressions in EXPLAIN, too.
1 parent 56c9b73 commit 108a0ec

33 files changed

+495
-311
lines changed

src/backend/catalog/heap.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.190 2002/03/21 16:00:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.191 2002/03/22 02:56:30 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -45,6 +45,7 @@
4545
#include "commands/comment.h"
4646
#include "commands/trigger.h"
4747
#include "miscadmin.h"
48+
#include "nodes/makefuncs.h"
4849
#include "optimizer/clauses.h"
4950
#include "optimizer/planmain.h"
5051
#include "optimizer/prep.h"
@@ -1612,7 +1613,11 @@ AddRelationRawConstraints(Relation rel,
16121613
* sole rangetable entry. We need a ParseState for transformExpr.
16131614
*/
16141615
pstate = make_parsestate(NULL);
1615-
rte = addRangeTableEntry(pstate, relname, NULL, false, true);
1616+
rte = addRangeTableEntryForRelation(pstate,
1617+
RelationGetRelid(rel),
1618+
makeAlias(relname, NIL),
1619+
false,
1620+
true);
16161621
addRTEtoQuery(pstate, rte, true, true);
16171622

16181623
/*

src/backend/commands/command.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.163 2002/03/21 23:27:20 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.164 2002/03/22 02:56:31 tgl Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -37,6 +37,7 @@
3737
#include "executor/execdefs.h"
3838
#include "executor/executor.h"
3939
#include "miscadmin.h"
40+
#include "nodes/makefuncs.h"
4041
#include "optimizer/clauses.h"
4142
#include "optimizer/planmain.h"
4243
#include "optimizer/prep.h"
@@ -1262,8 +1263,11 @@ AlterTableAddConstraint(char *relationName,
12621263
* expression we can pass to ExecQual
12631264
*/
12641265
pstate = make_parsestate(NULL);
1265-
rte = addRangeTableEntry(pstate, relationName, NULL,
1266-
false, true);
1266+
rte = addRangeTableEntryForRelation(pstate,
1267+
myrelid,
1268+
makeAlias(relationName, NIL),
1269+
false,
1270+
true);
12671271
addRTEtoQuery(pstate, rte, true, true);
12681272

12691273
/*

src/backend/commands/creatinh.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.90 2002/03/21 23:27:20 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.91 2002/03/22 02:56:31 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -46,9 +46,11 @@ static List *MergeDomainAttributes(List *schema);
4646
/* ----------------------------------------------------------------
4747
* DefineRelation
4848
* Creates a new relation.
49+
*
50+
* If successful, returns the OID of the new relation.
4951
* ----------------------------------------------------------------
5052
*/
51-
void
53+
Oid
5254
DefineRelation(CreateStmt *stmt, char relkind)
5355
{
5456
char *relname = palloc(NAMEDATALEN);
@@ -165,7 +167,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
165167
* see the new rel anyway until we commit), but it keeps the lock
166168
* manager from complaining about deadlock risks.
167169
*/
168-
rel = heap_openr(relname, AccessExclusiveLock);
170+
rel = heap_open(relationId, AccessExclusiveLock);
169171

170172
/*
171173
* Now add any newly specified column default values and CHECK
@@ -210,11 +212,13 @@ DefineRelation(CreateStmt *stmt, char relkind)
210212
* visible to anyone else anyway, until commit).
211213
*/
212214
heap_close(rel, NoLock);
215+
216+
return relationId;
213217
}
214218

215219
/*
216220
* RemoveRelation
217-
* Deletes a new relation.
221+
* Deletes a relation.
218222
*
219223
* Exceptions:
220224
* BadArg if name is invalid.

0 commit comments

Comments
 (0)