The following bug has been logged on the website:
Bug reference: 13597
Logged by: Hillel Eilat
Email address: hillel.eilat@attunity.com
PostgreSQL version: 9.4.4
Operating system: Windows 7
Description:
I do not know if this a bug or something that is not fully documented.
I use event trigger for tracking DDL-s
The trigger captures the DDL text by
retrieving current_query().
Now - there is a non-existent table -
say T_DUMMY.
Following conditional statement will
cause the trigger to fire:
DROP TABLE IF EXISTS T_DUMMY.
Trigger fires - although - no DROP DDL was carried out.
Reproduction is given below.
Is it what it meant to be?
Thanks
Hillel.
Reproduction:
-------------
1. My prototyped stuff
====================
CREATE OR REPLACE FUNCTION intercept_ddl()
RETURNS event_trigger AS
$BODY$
declare _qry text;
BEGIN
SELECT current_query() into _qry;
RAISE NOTICE 'DDLtype=''%'' XID=% DDL=%', tg_tag,cast(TXID_CURRENT()as
varchar(16)), _qry;
END;
$BODY$
CREATE EVENT TRIGGER intercept_ddl ON ddl command end EXECUTE PROCEDURE
intercept_ddl();
2. Introducing a non-existent table
================================
select * from attu.T_DUMMY
ERROR: relation "attu.t_dummy" does not exist
3. Conditionally dropping a non-existent table
======================================
drop table if exists attu.T_DUMMY
NOTICE: table "t_dummy" does not exist, skipping
NOTICE: DDLtype='DROP TABLE' XID=723 DDL=drop table if exists attu.T_DUMMY
Query returned successfully with no result in 23 ms.