mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-04 16:17:18 +02:00
Fix pg_identify_object_as_address() with event triggers
Attempting to use this function with event triggers failed, as, since
its introduction in a676201
, this code has never associated an object
name with event triggers. This addresses the failure by adding the
event trigger name to the set defining its object address.
Note that regression tests are added within event_trigger and not
object_address to avoid issues with concurrent connections in parallel
schedules.
Author: Joel Jacobson
Discussion: https://postgr.es/m/3c905e77-a026-46ae-8835-c3f6cd1d24c8@www.fastmail.com
Backpatch-through: 9.6
This commit is contained in:
parent
4b610547c2
commit
5b717e13c9
@ -5027,10 +5027,7 @@ getObjectIdentityParts(const ObjectAddress *object,
|
||||
{
|
||||
HeapTuple tup;
|
||||
Form_pg_event_trigger trigForm;
|
||||
|
||||
/* no objname support here */
|
||||
if (objname)
|
||||
*objname = NIL;
|
||||
char *evtname;
|
||||
|
||||
tup = SearchSysCache1(EVENTTRIGGEROID,
|
||||
ObjectIdGetDatum(object->objectId));
|
||||
@ -5038,8 +5035,10 @@ getObjectIdentityParts(const ObjectAddress *object,
|
||||
elog(ERROR, "cache lookup failed for event trigger %u",
|
||||
object->objectId);
|
||||
trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
||||
appendStringInfoString(&buffer,
|
||||
quote_identifier(NameStr(trigForm->evtname)));
|
||||
evtname = NameStr(trigForm->evtname);
|
||||
appendStringInfoString(&buffer, quote_identifier(evtname));
|
||||
if (objname)
|
||||
*objname = list_make1(evtname);
|
||||
ReleaseSysCache(tup);
|
||||
break;
|
||||
}
|
||||
|
@ -489,6 +489,23 @@ DROP POLICY p2 ON event_trigger_test;
|
||||
NOTICE: DROP POLICY - ddl_command_start
|
||||
NOTICE: DROP POLICY - sql_drop
|
||||
NOTICE: DROP POLICY - ddl_command_end
|
||||
-- Check the object addresses of all the event triggers.
|
||||
SELECT
|
||||
e.evtname,
|
||||
pg_describe_object('pg_event_trigger'::regclass, e.oid, 0) as descr,
|
||||
b.type, b.object_names, b.object_args,
|
||||
pg_identify_object(a.classid, a.objid, a.objsubid) as ident
|
||||
FROM pg_event_trigger as e,
|
||||
LATERAL pg_identify_object_as_address('pg_event_trigger'::regclass, e.oid, 0) as b,
|
||||
LATERAL pg_get_object_address(b.type, b.object_names, b.object_args) as a
|
||||
ORDER BY e.evtname;
|
||||
evtname | descr | type | object_names | object_args | ident
|
||||
-------------------+---------------------------------+---------------+---------------------+-------------+--------------------------------------------------------
|
||||
end_rls_command | event trigger end_rls_command | event trigger | {end_rls_command} | {} | ("event trigger",,end_rls_command,end_rls_command)
|
||||
sql_drop_command | event trigger sql_drop_command | event trigger | {sql_drop_command} | {} | ("event trigger",,sql_drop_command,sql_drop_command)
|
||||
start_rls_command | event trigger start_rls_command | event trigger | {start_rls_command} | {} | ("event trigger",,start_rls_command,start_rls_command)
|
||||
(3 rows)
|
||||
|
||||
DROP EVENT TRIGGER start_rls_command;
|
||||
DROP EVENT TRIGGER end_rls_command;
|
||||
DROP EVENT TRIGGER sql_drop_command;
|
||||
|
@ -399,6 +399,17 @@ ALTER POLICY p1 ON event_trigger_test USING (TRUE);
|
||||
ALTER POLICY p1 ON event_trigger_test RENAME TO p2;
|
||||
DROP POLICY p2 ON event_trigger_test;
|
||||
|
||||
-- Check the object addresses of all the event triggers.
|
||||
SELECT
|
||||
e.evtname,
|
||||
pg_describe_object('pg_event_trigger'::regclass, e.oid, 0) as descr,
|
||||
b.type, b.object_names, b.object_args,
|
||||
pg_identify_object(a.classid, a.objid, a.objsubid) as ident
|
||||
FROM pg_event_trigger as e,
|
||||
LATERAL pg_identify_object_as_address('pg_event_trigger'::regclass, e.oid, 0) as b,
|
||||
LATERAL pg_get_object_address(b.type, b.object_names, b.object_args) as a
|
||||
ORDER BY e.evtname;
|
||||
|
||||
DROP EVENT TRIGGER start_rls_command;
|
||||
DROP EVENT TRIGGER end_rls_command;
|
||||
DROP EVENT TRIGGER sql_drop_command;
|
||||
|
Loading…
Reference in New Issue
Block a user