1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +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:
Alvaro Herrera
2015-03-03 14:10:50 -03:00
parent 6f9d799047
commit a2e35b53c3
68 changed files with 840 additions and 558 deletions

View File

@ -460,7 +460,7 @@ RemovePolicyById(Oid policy_id)
*
* stmt - the CreatePolicyStmt that describes the policy to create.
*/
Oid
ObjectAddress
CreatePolicy(CreatePolicyStmt *stmt)
{
Relation pg_policy_rel;
@ -626,7 +626,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
relation_close(target_table, NoLock);
heap_close(pg_policy_rel, RowExclusiveLock);
return policy_id;
return myself;
}
/*
@ -635,7 +635,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
*
* stmt - the AlterPolicyStmt that describes the policy and how to alter it.
*/
Oid
ObjectAddress
AlterPolicy(AlterPolicyStmt *stmt)
{
Relation pg_policy_rel;
@ -830,14 +830,14 @@ AlterPolicy(AlterPolicyStmt *stmt)
relation_close(target_table, NoLock);
heap_close(pg_policy_rel, RowExclusiveLock);
return policy_id;
return myself;
}
/*
* rename_policy -
* change the name of a policy on a relation
*/
Oid
ObjectAddress
rename_policy(RenameStmt *stmt)
{
Relation pg_policy_rel;
@ -847,6 +847,7 @@ rename_policy(RenameStmt *stmt)
ScanKeyData skey[2];
SysScanDesc sscan;
HeapTuple policy_tuple;
ObjectAddress address;
/* Get id of table. Also handles permissions checks. */
table_id = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
@ -925,6 +926,8 @@ rename_policy(RenameStmt *stmt)
InvokeObjectPostAlterHook(PolicyRelationId,
HeapTupleGetOid(policy_tuple), 0);
ObjectAddressSet(address, PolicyRelationId, opoloid);
/*
* Invalidate relation's relcache entry so that other backends (and
* this one too!) are sent SI message to make them rebuild relcache
@ -937,7 +940,7 @@ rename_policy(RenameStmt *stmt)
heap_close(pg_policy_rel, RowExclusiveLock);
relation_close(target_table, NoLock);
return opoloid;
return address;
}
/*