BUG #13597: Event trigger fires on conditional DDL when no DDL action is carried out

From: hillel(dot)eilat(at)attunity(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13597: Event trigger fires on conditional DDL when no DDL action is carried out
Date: 2015-08-30 10:58:18
Message-ID: 20150830105818.2090.27792@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13597
Logged by: Hillel Eilat
Email address: hillel(dot)eilat(at)attunity(dot)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.

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2015-08-31 06:51:57 Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe
Previous Message Amit Kapila 2015-08-29 13:35:15 Re: PQexec() hangs on OOM