Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWDcI-00043Q-Kt for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Aug 2015 01:10:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZWDcH-0004Nq-SA for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Aug 2015 01:10:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZW0KL-000292-1g for pgsql-bugs@postgresql.org; Sun, 30 Aug 2015 10:59:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZW0KH-0006Fy-2m for pgsql-bugs@postgresql.org; Sun, 30 Aug 2015 10:59:08 +0000 MIME-Version: 1.0 Subject: BUG #13597: Event trigger fires on conditional DDL when no DDL action is carried out To: pgsql-bugs@postgresql.org From: hillel.eilat@attunity.com Date: Sun, 30 Aug 2015 10:58:18 +0000 Message-ID: <20150830105818.2090.27792@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs