BUG #13597: Event trigger fires on conditional DDL when no DDL action is carried out - Mailing list pgsql-bugs

From hillel.eilat@attunity.com
Subject BUG #13597: Event trigger fires on conditional DDL when no DDL action is carried out
Date
Msg-id 20150830105818.2090.27792@wrigleys.postgresql.org
Whole thread Raw
List pgsql-bugs
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.

pgsql-bugs by date:

Previous
From: it@ramsoft.com
Date:
Subject: BUG #13595: pg_ctl.exe interferes with GPClient.exe
Next
From: Michael Paquier
Date:
Subject: Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe