Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tgTn8-00B2t2-3D for pgsql-general@arkaria.postgresql.org; Fri, 07 Feb 2025 19:13:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tgTn5-004iZY-7Z for pgsql-general@arkaria.postgresql.org; Fri, 07 Feb 2025 19:13:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tgTn3-004iZP-Lx for pgsql-general@lists.postgresql.org; Fri, 07 Feb 2025 19:13:26 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tgTmz-004Ppj-1Y for pgsql-general@lists.postgresql.org; Fri, 07 Feb 2025 19:13:25 +0000 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id C49181140108; Fri, 7 Feb 2025 14:13:19 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 07 Feb 2025 14:13:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1738955599; x=1739041999; bh=BmHIcR9A4f6ttsxSB09fRIdFe5rBTeGDEn4JQKcwof8=; b= F8sSLGakI/RDWTjY2H8Tu4U6NsmUjbgIrK9lQ6oxhOgrvhbPKV5Y/amy7JTf9Q9+ 4A9GNM6g5+Lsl6Y/PHVv/g14C+4TphsC1Sr1eO5eFShVU1ITpkvRscx0m2gJigSV 9WepmhCnhR6MBNjj1uCvwnvFF60QBb21K6R38iD4KL07gOv3JP1bpBnQCFS9SwQX eZOUMn9VgMg9njAZwFJ4jcy2IxDtAhhVu7urO2T6xSwNkiwW4Boi1dW/Njb3Qq0P Suguks1ObrXLbYaka/f3osVPwcJ9hPZwBw0wZvNvDZc4/bE6I0La4nt49QqN+O5C BrP5qUiql7elOFMkAl+yCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1738955599; x= 1739041999; bh=BmHIcR9A4f6ttsxSB09fRIdFe5rBTeGDEn4JQKcwof8=; b=b m8qvmOHsXKS/f4QxEIIr+VqwBJPkdDMH/xoDeF/qgdAVLygReVJ9vP9yxX1dz/DZ G4QAhrUKzBiFilhWkMyCbeO7vKiuNGhsNkyDsxKpmvw8nSwMuaaw/2OynRKuFu58 znA9M41R4kNQDmytnpXGc+EuBqh70zj5ma4o+AO/OlTO7YHNZh4Froar2j2HV3DR ptqza+OO8GdhLs0/ROFPQ3profmyPnjVknisp9R9aKHQfo+ITpwh4MDexST1tM5/ EUle1YBEsTWb6ixIEpRikH8ZZt6Hq5S9hlc3JfC241d3rYKn+c4YI4REdKuG7taA Ti4FBQOOarIEps1ochI0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeftddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddv jeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpefgvdegheduheethedu jeetleeigefhfeevvddtffffteelkeefkeffjeffleegvdenucffohhmrghinhepphhgrg huughithdrohhrghdpphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrg hklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohepihhkohhrohhttddusehgmhgrihhlrdgtohhmpdhrtghpthhtohepph hgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Feb 2025 14:13:18 -0500 (EST) Message-ID: <5949efc2-64a0-4bb3-b837-2c7b90c3745b@aklaver.com> Date: Fri, 7 Feb 2025 11:13:16 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to get a notification To: Igor Korot Cc: "pgsql-generallists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/7/25 11:02 AM, Igor Korot wrote: > Hi, Adrian, > > On Fri, Feb 7, 2025 at 11:07 AM Adrian Klaver wrote: >> >> On 2/5/25 23:21, Igor Korot wrote: >>> Hi, ALL, >>> In my code I'm running following: >>> >>> queries.push_back( L"CREATE FUNCTION >>> __watch_schema_changes() RETURNS event_trigger LANGUAGE plpgsql AS $$ >>> BEGIN NOTIFY tg_tag; END; $$;" ); >>> queries.push_back( L"CREATE EVENT TRIGGER >>> schema_change_notify ON ddl_command_end WHEN TAG IN(\'CREATE TABLE\', >>> \'ALTER TABLE\', \'DROP TABLE\', \'CREATE INDEX\', \'DROP INDEX\') >>> EXECUTE PROCEDURE __watch_schema_changes();" ); >>> >>> My questions are: >>> 1 Is there a better way to get notification about CREATE/ALTER/DROP TABLE? >> >> An alternate solution: >> >> https://www.pgaudit.org/ >> >> Whether it is better or not is something you will need to decide. >> >>> 2. How do I receive notification abut the event with the object name? >> >> Use information from here?: >> >> https://www.postgresql.org/docs/current/functions-event-triggers.html#PG-EVENT-TRIGGER-DDL-COMMAND-END-FUNCTIONS > > Thx for the link > So basically all I need to do is to call > > SELECT pg_event_trigger_ddl_commands () And then unpack the information it returns. > > right? > > In both ODBC amd libpq interfaces? It is not about the interface it is about, from link above: "pg_event_trigger_ddl_commands returns a list of DDL commands executed by each user action, when invoked in a function attached to a ddl_command_end event trigger." > > Thank you. > > > >> >>> >>> Thank you. >>> >>> >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com >> -- Adrian Klaver adrian.klaver@aklaver.com