mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +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:
@ -291,9 +291,9 @@ CheckIndexCompatible(Oid oldId,
|
||||
* it will be filled later.
|
||||
* 'quiet': suppress the NOTICE chatter ordinarily provided for constraints.
|
||||
*
|
||||
* Returns the OID of the created index.
|
||||
* Returns the object address of the created index.
|
||||
*/
|
||||
Oid
|
||||
ObjectAddress
|
||||
DefineIndex(Oid relationId,
|
||||
IndexStmt *stmt,
|
||||
Oid indexRelationId,
|
||||
@ -323,6 +323,7 @@ DefineIndex(Oid relationId,
|
||||
int numberOfAttributes;
|
||||
TransactionId limitXmin;
|
||||
VirtualTransactionId *old_snapshots;
|
||||
ObjectAddress address;
|
||||
int n_old_snapshots;
|
||||
LockRelId heaprelid;
|
||||
LOCKTAG heaplocktag;
|
||||
@ -613,10 +614,12 @@ DefineIndex(Oid relationId,
|
||||
stmt->concurrent, !check_rights,
|
||||
stmt->if_not_exists);
|
||||
|
||||
ObjectAddressSet(address, RelationRelationId, indexRelationId);
|
||||
|
||||
if (!OidIsValid(indexRelationId))
|
||||
{
|
||||
heap_close(rel, NoLock);
|
||||
return indexRelationId;
|
||||
return address;
|
||||
}
|
||||
|
||||
/* Add any requested comment */
|
||||
@ -628,7 +631,7 @@ DefineIndex(Oid relationId,
|
||||
{
|
||||
/* Close the heap and we're done, in the non-concurrent case */
|
||||
heap_close(rel, NoLock);
|
||||
return indexRelationId;
|
||||
return address;
|
||||
}
|
||||
|
||||
/* save lockrelid and locktag for below, then close rel */
|
||||
@ -873,7 +876,7 @@ DefineIndex(Oid relationId,
|
||||
*/
|
||||
UnlockRelationIdForSession(&heaprelid, ShareUpdateExclusiveLock);
|
||||
|
||||
return indexRelationId;
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user