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 1tgRpO-00AlSn-6c for pgsql-general@arkaria.postgresql.org; Fri, 07 Feb 2025 17:07:42 +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 1tgRpN-003QJL-9I for pgsql-general@arkaria.postgresql.org; Fri, 07 Feb 2025 17:07:41 +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 1tgRpM-003QIy-Uy for pgsql-general@lists.postgresql.org; Fri, 07 Feb 2025 17:07:40 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tgRpJ-004Olk-30 for pgsql-general@lists.postgresql.org; Fri, 07 Feb 2025 17:07:40 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1B84A25401CE; Fri, 7 Feb 2025 12:07:37 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 07 Feb 2025 12:07:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=1738948056; x=1739034456; bh=KTzl5P4qNOd0UehJ/6kSKnsqPYaxLDMhrE+4eX4BN6E=; b= SrEpqdU2bVq614TWzkq/UqYIYCF9UtuBoa1rasIxF3Q2srZ2TF3ALeshQZwQ3TEP jRjiaD+XeM4BJuL/Ze9cSUEzbd5NuoAaqW45LPLOlDLn1vwtDkw2N9ZF3vfXwDkJ +uFDaEoB+WRVX1Eu2DdHeMXgKouioCsGzyMUL4Rp0seIR9hPId9XqdP1TjLOwJtM TWcEtPAIB8DhCspEEwTKoOfvP5DCtSvvrvnSvuHTOLVkSCpiEhSi3ld8n1jKTSX9 GnWrAAr0jWXCOHgiFz7yiud79reBW/vWMKkkuK+FsnxjLpNZFx5jafx8p9JS2lpo lp/WZklfL7odmwxnNyg/Jw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1738948056; x=1739034456; bh=K Tzl5P4qNOd0UehJ/6kSKnsqPYaxLDMhrE+4eX4BN6E=; b=JuozVFKo3FH1TIPGv 0W7qw9dwNymXUeb+F/4Bdt2Ppt8S1q2V30RDHtzhz6/LJpez/V+1nOxp2Z+dZmLU EeycIlWp/TbJzWlTAjYTmqbI+EnENNKpkmsaX3gLI/XfXsrYtVcmCaNq+GEOuytg CAReoJPsXMMpIB0H8b5DO9jfGUdcOvl4Dk2zCtM7dL8QUMIPb/tGMNPWIcCNK9M0 jJmlzcMR5MF79UUOlzM1S8Jt/1bmWULz4z2ISgt8QdKWtNPWZI/EEcp20BfzB+O3 D7RLKpXXFVCadO6cwOcgEF8qWX878Qd/jWY7LYOeYwhfxz/LeqdKfn93pbb7efyl 4S4lA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvleekgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtvdej necuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepheelgffgleelgfegjeef vdekiedvhfekveeiffevuddvheeiteeivddtieehgfeknecuffhomhgrihhnpehpghgruh guihhtrdhorhhgpdhpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkh hlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehikhhorhhothdtudesghhmrghilhdrtghomhdprhgtphhtthhopehpgh hsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Feb 2025 12:07:35 -0500 (EST) Message-ID: Date: Fri, 7 Feb 2025 09:07:35 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to get a notification To: Igor Korot , "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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 > > Thank you. > > -- Adrian Klaver adrian.klaver@aklaver.com