Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dtJ9F-00064C-F9 for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Sep 2017 19:53:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dtJ9E-0001z3-N6 for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Sep 2017 19:53:04 +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_2) (envelope-from ) id 1dtJ8W-0000kW-S4 for pgsql-bugs@postgresql.org; Sat, 16 Sep 2017 19:52:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dtJ8T-0004W4-DM for pgsql-bugs@postgresql.org; Sat, 16 Sep 2017 19:52:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v8GJqF7S026966; Sat, 16 Sep 2017 15:52:15 -0400 From: Tom Lane To: gomer94@yandex.ru cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14815: event trigger in extension In-reply-to: <20170913075559.25630.41587@wrigleys.postgresql.org> References: <20170913075559.25630.41587@wrigleys.postgresql.org> Comments: In-reply-to gomer94@yandex.ru message dated "Wed, 13 Sep 2017 07:55:59 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26964.1505591535.1@sss.pgh.pa.us> Date: Sat, 16 Sep 2017 15:52:15 -0400 Message-ID: <26965.1505591535@sss.pgh.pa.us> 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 gomer94@yandex.ru writes: > I want to create extension with sql like: > CREATE OR REPLACE FUNCTION keep_any_ddl_command() RETURNS event_trigger > LANGUAGE plpgsql > AS $$ > BEGIN > SELECT classid, objid, objsubid FROM > pg_event_trigger_ddl_commands(); > -- some insert code; > END; > $$; > CREATE TABLE ddl_events(); > CREATE EVENT TRIGGER keep_all_ddl ON ddl_command_end > EXECUTE PROCEDURE keep_any_ddl_command(); I think the reason this fails is that on the way out of the CREATE EXTENSION command, the event trigger code sees that an event trigger exists, so it tries to call it. But because no event trigger existed when we started the CREATE EXTENSION command, the necessary infrastructure hasn't been set up --- in particular, EventTriggerBeginCompleteQuery did nothing at the time. This seems like it would be an equal hazard for any situation where CREATE EVENT TRIGGER is executed not at top level. Don't see an easy fix right offhand. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs