mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Change addRangeTableEntryForRelation() to take a Relation pointer instead
of just a relation OID, thereby not having to open the relation for itself. This actually saves code rather than adding it for most of the existing callers, which had the rel open already. The main point though is to be able to use this rather than plain addRangeTableEntry in setTargetTable, thus saving one relation_openrv/relation_close cycle for every INSERT, UPDATE, or DELETE. Seems to provide a several percent win on simple INSERTs.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.152 2005/03/29 00:16:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.153 2005/04/13 16:50:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -4732,8 +4732,8 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
|
||||
/* Expression must be able to access vars of old table */
|
||||
rte = addRangeTableEntryForRelation(pstate,
|
||||
RelationGetRelid(rel),
|
||||
makeAlias(RelationGetRelationName(rel), NIL),
|
||||
rel,
|
||||
NULL,
|
||||
false,
|
||||
true);
|
||||
addRTEtoQuery(pstate, rte, false, true);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.88 2005/04/06 16:34:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.89 2005/04/13 16:50:54 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -329,6 +329,7 @@ DefineViewRules(const RangeVar *view, Query *viewParse, bool replace)
|
||||
static Query *
|
||||
UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
|
||||
{
|
||||
Relation viewRel;
|
||||
List *new_rt;
|
||||
RangeTblEntry *rt_entry1,
|
||||
*rt_entry2;
|
||||
@@ -343,14 +344,17 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
|
||||
*/
|
||||
viewParse = (Query *) copyObject(viewParse);
|
||||
|
||||
/* need to open the rel for addRangeTableEntryForRelation */
|
||||
viewRel = relation_open(viewOid, AccessShareLock);
|
||||
|
||||
/*
|
||||
* Create the 2 new range table entries and form the new range
|
||||
* table... OLD first, then NEW....
|
||||
*/
|
||||
rt_entry1 = addRangeTableEntryForRelation(NULL, viewOid,
|
||||
rt_entry1 = addRangeTableEntryForRelation(NULL, viewRel,
|
||||
makeAlias("*OLD*", NIL),
|
||||
false, false);
|
||||
rt_entry2 = addRangeTableEntryForRelation(NULL, viewOid,
|
||||
rt_entry2 = addRangeTableEntryForRelation(NULL, viewRel,
|
||||
makeAlias("*NEW*", NIL),
|
||||
false, false);
|
||||
/* Must override addRangeTableEntry's default access-check flags */
|
||||
@@ -366,6 +370,8 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
|
||||
*/
|
||||
OffsetVarNodes((Node *) viewParse, 2, 0);
|
||||
|
||||
relation_close(viewRel, AccessShareLock);
|
||||
|
||||
return viewParse;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user