Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q477E-0001Z8-Iz for pgsql-general@arkaria.postgresql.org; Tue, 30 May 2023 21:42:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q477B-00045i-I8 for pgsql-general@arkaria.postgresql.org; Tue, 30 May 2023 21:42:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q477B-00045Z-73 for pgsql-general@lists.postgresql.org; Tue, 30 May 2023 21:42:49 +0000 Received: from mout-u-204.mailbox.org ([2001:67c:2050:101:465::204]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q4778-002mTC-Ej for pgsql-general@lists.postgresql.org; Tue, 30 May 2023 21:42:48 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4QW5Tp3FlNz9sM1; Tue, 30 May 2023 23:42:38 +0200 (CEST) Date: Tue, 30 May 2023 23:42:37 +0200 (CEST) From: Erik Wienhold To: Lian Jiang , pgsql-general@lists.postgresql.org Message-ID: <1154091521.527097.1685482957284@office.mailbox.org> In-Reply-To: References: Subject: Re: event trigger should provide more details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 30/05/2023 22:23 CEST Lian Jiang wrote: > > I plan to create an event trigger to detect schema change (e.g. add/remove > a column, change column type), and write it into a separate table (e.g. > EVENTS). Then a process periodically reads this table to send schema change > notification. However, the event trigger (https://www.postgresql.org/docs/current/plpgsql-trigger.html) > (43.10.2. Triggers on Events) does not provide me info such as which table > is altered, old and new schema. Am I missing something? Thanks very much for > any hints. You must use ddl_command_end event triggers[0] and call function pg_event_trigger_ddl_commands[1] to get info such as altered table and column. [0] https://www.postgresql.org/docs/current/event-trigger-definition.html [1] https://www.postgresql.org/docs/current/functions-event-triggers.html -- Erik