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
fa26eba221
commit
f7aab36d61
@ -5607,10 +5607,7 @@ getObjectIdentityParts(const ObjectAddress *object,
|
|||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_event_trigger trigForm;
|
Form_pg_event_trigger trigForm;
|
||||||
|
char *evtname;
|
||||||
/* no objname support here */
|
|
||||||
if (objname)
|
|
||||||
*objname = NIL;
|
|
||||||
|
|
||||||
tup = SearchSysCache1(EVENTTRIGGEROID,
|
tup = SearchSysCache1(EVENTTRIGGEROID,
|
||||||
ObjectIdGetDatum(object->objectId));
|
ObjectIdGetDatum(object->objectId));
|
||||||
@ -5622,8 +5619,10 @@ getObjectIdentityParts(const ObjectAddress *object,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
trigForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
||||||
appendStringInfoString(&buffer,
|
evtname = NameStr(trigForm->evtname);
|
||||||
quote_identifier(NameStr(trigForm->evtname)));
|
appendStringInfoString(&buffer, quote_identifier(evtname));
|
||||||
|
if (objname)
|
||||||
|
*objname = list_make1(evtname);
|
||||||
ReleaseSysCache(tup);
|
ReleaseSysCache(tup);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -533,6 +533,23 @@ DROP POLICY p2 ON event_trigger_test;
|
|||||||
NOTICE: DROP POLICY - ddl_command_start
|
NOTICE: DROP POLICY - ddl_command_start
|
||||||
NOTICE: DROP POLICY - sql_drop
|
NOTICE: DROP POLICY - sql_drop
|
||||||
NOTICE: DROP POLICY - ddl_command_end
|
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 start_rls_command;
|
||||||
DROP EVENT TRIGGER end_rls_command;
|
DROP EVENT TRIGGER end_rls_command;
|
||||||
DROP EVENT TRIGGER sql_drop_command;
|
DROP EVENT TRIGGER sql_drop_command;
|
||||||
|
@ -426,6 +426,17 @@ ALTER POLICY p1 ON event_trigger_test USING (TRUE);
|
|||||||
ALTER POLICY p1 ON event_trigger_test RENAME TO p2;
|
ALTER POLICY p1 ON event_trigger_test RENAME TO p2;
|
||||||
DROP POLICY p2 ON event_trigger_test;
|
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 start_rls_command;
|
||||||
DROP EVENT TRIGGER end_rls_command;
|
DROP EVENT TRIGGER end_rls_command;
|
||||||
DROP EVENT TRIGGER sql_drop_command;
|
DROP EVENT TRIGGER sql_drop_command;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user