mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Change many routines to return ObjectAddress rather than OID
The changed routines are mostly those that can be directly called by ProcessUtilitySlow; the intention is to make the affected object information more precise, in support for future event trigger changes. Originally it was envisioned that the OID of the affected object would be enough, and in most cases that is correct, but upon actually implementing the event trigger changes it turned out that ObjectAddress is more widely useful. Additionally, some command execution routines grew an output argument that's an object address which provides further info about the executed command. To wit: * for ALTER DOMAIN / ADD CONSTRAINT, it corresponds to the address of the new constraint * for ALTER OBJECT / SET SCHEMA, it corresponds to the address of the schema that originally contained the object. * for ALTER EXTENSION {ADD, DROP} OBJECT, it corresponds to the address of the object added to or dropped from the extension. There's no user-visible change in this commit, and no functional change either. Discussion: 20150218213255.GC6717@tamriel.snowman.net Reviewed-By: Stephen Frost, Andres Freund
This commit is contained in:
@ -191,7 +191,7 @@ InsertRule(char *rulname,
|
||||
* DefineRule
|
||||
* Execute a CREATE RULE command.
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
DefineRule(RuleStmt *stmt, const char *queryString)
|
||||
{
|
||||
List *actions;
|
||||
@ -225,7 +225,7 @@ DefineRule(RuleStmt *stmt, const char *queryString)
|
||||
* This is essentially the same as DefineRule() except that the rule's
|
||||
* action and qual have already been passed through parse analysis.
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
DefineQueryRewrite(char *rulename,
|
||||
Oid event_relid,
|
||||
Node *event_qual,
|
||||
@ -239,6 +239,7 @@ DefineQueryRewrite(char *rulename,
|
||||
Query *query;
|
||||
bool RelisBecomingView = false;
|
||||
Oid ruleId = InvalidOid;
|
||||
ObjectAddress address;
|
||||
|
||||
/*
|
||||
* If we are installing an ON SELECT rule, we had better grab
|
||||
@ -604,10 +605,12 @@ DefineQueryRewrite(char *rulename,
|
||||
heap_close(relationRelation, RowExclusiveLock);
|
||||
}
|
||||
|
||||
ObjectAddressSet(address, RewriteRelationId, ruleId);
|
||||
|
||||
/* Close rel, but keep lock till commit... */
|
||||
heap_close(event_relation, NoLock);
|
||||
|
||||
return ruleId;
|
||||
return address;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -897,7 +900,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
/*
|
||||
* Rename an existing rewrite rule.
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
RenameRewriteRule(RangeVar *relation, const char *oldName,
|
||||
const char *newName)
|
||||
{
|
||||
@ -907,6 +910,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
|
||||
HeapTuple ruletup;
|
||||
Form_pg_rewrite ruleform;
|
||||
Oid ruleOid;
|
||||
ObjectAddress address;
|
||||
|
||||
/*
|
||||
* Look up name, check permissions, and acquire lock (which we will NOT
|
||||
@ -969,10 +973,12 @@ RenameRewriteRule(RangeVar *relation, const char *oldName,
|
||||
*/
|
||||
CacheInvalidateRelcache(targetrel);
|
||||
|
||||
ObjectAddressSet(address, RewriteRelationId, ruleOid);
|
||||
|
||||
/*
|
||||
* Close rel, but keep exclusive lock!
|
||||
*/
|
||||
relation_close(targetrel, NoLock);
|
||||
|
||||
return ruleOid;
|
||||
return address;
|
||||
}
|
||||
|
Reference in New Issue
Block a user