mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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:
@ -100,7 +100,7 @@ static void AfterTriggerEnlargeQueryState(void);
|
||||
|
||||
|
||||
/*
|
||||
* Create a trigger. Returns the OID of the created trigger.
|
||||
* Create a trigger. Returns the address of the created trigger.
|
||||
*
|
||||
* queryString is the source text of the CREATE TRIGGER command.
|
||||
* This must be supplied if a whenClause is specified, else it can be NULL.
|
||||
@ -129,10 +129,11 @@ static void AfterTriggerEnlargeQueryState(void);
|
||||
* relation, as well as ACL_EXECUTE on the trigger function. For internal
|
||||
* triggers the caller must apply any required permission checks.
|
||||
*
|
||||
* Note: can return InvalidOid if we decided to not create a trigger at all,
|
||||
* but a foreign-key constraint. This is a kluge for backwards compatibility.
|
||||
* Note: can return InvalidObjectAddress if we decided to not create a trigger
|
||||
* at all, but a foreign-key constraint. This is a kluge for backwards
|
||||
* compatibility.
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
|
||||
bool isInternal)
|
||||
@ -459,7 +460,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
|
||||
ConvertTriggerToFK(stmt, funcoid);
|
||||
|
||||
return InvalidOid;
|
||||
return InvalidObjectAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -799,7 +800,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
/* Keep lock on target rel until end of xact */
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return trigoid;
|
||||
return myself;
|
||||
}
|
||||
|
||||
|
||||
@ -1249,7 +1250,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
* modify tgname in trigger tuple
|
||||
* update row in catalog
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
renametrig(RenameStmt *stmt)
|
||||
{
|
||||
Oid tgoid;
|
||||
@ -1259,6 +1260,7 @@ renametrig(RenameStmt *stmt)
|
||||
SysScanDesc tgscan;
|
||||
ScanKeyData key[2];
|
||||
Oid relid;
|
||||
ObjectAddress address;
|
||||
|
||||
/*
|
||||
* Look up name, check permissions, and acquire lock (which we will NOT
|
||||
@ -1351,6 +1353,8 @@ renametrig(RenameStmt *stmt)
|
||||
stmt->subname, RelationGetRelationName(targetrel))));
|
||||
}
|
||||
|
||||
ObjectAddressSet(address, TriggerRelationId, tgoid);
|
||||
|
||||
systable_endscan(tgscan);
|
||||
|
||||
heap_close(tgrel, RowExclusiveLock);
|
||||
@ -1360,7 +1364,7 @@ renametrig(RenameStmt *stmt)
|
||||
*/
|
||||
relation_close(targetrel, NoLock);
|
||||
|
||||
return tgoid;
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user