diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-03-03 14:10:50 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-03-03 14:10:50 -0300 |
commit | a2e35b53c39b2a27d3e332dc7c506539c306fd44 (patch) | |
tree | 1f4cd33208d33f4a8b3159b0d3757109c67d4b14 /src/backend/commands/policy.c | |
parent | 6f9d79904748c26a58991942dc6719db558f77b0 (diff) |
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
Diffstat (limited to 'src/backend/commands/policy.c')
-rw-r--r-- | src/backend/commands/policy.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index d98da0dd506..e86299781f9 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -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; } /* |