Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcdrL-0004x8-VX for pgsql-general@arkaria.postgresql.org; Mon, 09 Jul 2018 21:38:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fcdrJ-00060F-SI for pgsql-general@arkaria.postgresql.org; Mon, 09 Jul 2018 21:38:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcdrH-000608-Sm for pgsql-general@lists.postgresql.org; Mon, 09 Jul 2018 21:38:13 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcdrE-0000Ep-AI for pgsql-general@postgresql.org; Mon, 09 Jul 2018 21:38:10 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 618602156E; Mon, 9 Jul 2018 17:38:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 09 Jul 2018 17:38:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=J2OtGI7L4g3fIVf2FmbpgZkedlzDl qof8iO+82+r8h0=; b=vZflGo3wEXYM93RlYdaTrPTW71FdjyvMrO9lwPfPlWVCB RBu9JRQXSUHjTOPHkAjeN19XsYpQjyngVEN2tyJ1yRfcp7Cb2Iqqeq2bDcMqlfvl jGUfXIdYkAvnhPrR2+OjBfKthBxM5j3BIRG2R1tof6hX6jma5rmeA6FAYoazqa9r 6tEJGkn0OUTz06GjEq7MWYdoYjca9LThKN0c0tT9kO+vJa63OrENJr4LCwXtYCdS 9KbDwoZWyuccrtpqxZOOiuN8UEDURw8oUUqdeKL8g4/rg00HAGGta2pGMqDYaYHX CzUgVQqZ0pLyPdRpN3eWC4jKC+/GGKqcRQRJr0nEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=J2OtGI 7L4g3fIVf2FmbpgZkedlzDlqof8iO+82+r8h0=; b=nM5QKydSgAnonUedxJl4nK KuG61VHyJxsWCjjrPuE8ITBvard5VWgtAHIeI/GLRmhFuRZBh3yYDhbblNSDI/co QLNX66QZBBGWke+66gzpL5PLMSdEBuMxazirlvJkNAg3wgWCU8omQxtI7eoNCBYF ZXGRHQ2b1/6jirFM1bjO6oiQrDp2YukcHBMnWaItScNQF89C6zLMgg+3Zn8E9RQ/ 6YYZgT2fJu58pm1E/q1y7uehUEnZN4Y5ReA14+UGQFR36bExzmIa41uHvca/37HW 6Y5sPbwIUsPs1K5VW3Yc+Q3W2t34vomgIYnog++/1oiArR65Lq9QZ2i8ATnOjeCg == X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 90087E49E9; Mon, 9 Jul 2018 17:38:06 -0400 (EDT) Subject: Re: How to watch for schema changes To: Igor Korot Cc: pgsql-general References: <7fc929ec-8e34-5824-6511-d1dd1188434f@aklaver.com> From: Adrian Klaver Message-ID: <7faddf4c-3a58-d7f6-cef8-c65098fc16f5@aklaver.com> Date: Mon, 9 Jul 2018 14:38:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/09/2018 01:49 PM, Igor Korot wrote: > Hi, Adrian > > On Tue, Jul 3, 2018 at 1:24 PM, Adrian Klaver wrote: >> On 07/03/2018 11:15 AM, Igor Korot wrote: >>> >>> Adrian, >>> >>> On Tue, Jul 3, 2018 at 12:32 PM, Adrian Klaver >>> wrote: >>>> >>>> On 07/03/2018 10:21 AM, Igor Korot wrote: >>>>> >>>>> >>>>> Hi, ALL, >>>>> Is there any trigger or some other means I can do on the server >>>>> which will watch for CREATE/ALTER/DROP TABLE command and after >>>>> successful >>>>> execution of those will issue a NOTIFY statement? >>>> >>>> >>>> >>>> https://www.postgresql.org/docs/10/static/event-triggers.html >>> >>> >>> According to the documentation the lowest version it supports is 9.3. >>> Anything prior to that? >>> >>> I'm working with OX 10.8 and it has 9.1 installed. >> >> 9.1 went EOL almost two years ago. The oldest supported version is 9.3, >> though it will go EOL this September: >> >> https://www.postgresql.org/support/versioning/ >> >> Are you forced to work with 9.1 or can you use something from here: >> >> https://www.postgresql.org/download/macosx/ >> >> to get a newer version? FYI that will be a major upgrade so will require a >> dump/restore or use of pg_upgrade. > > Just a thought... > Is it possible to create a trigger for a system table? Or this > operation is restricted Easy enough to test. As postgres super user: test_(postgres)# create trigger info_test before insert on pg_class execute procedure ts_update(); ERROR: permission denied: "pg_class" is a system catalog > for when the server is actually being set-up? > > Successful "CREATE TABLE..." statement creates a row inside the > information_schema.tables > so if I can create a trigger after this record is inserted or deleted > that should be fine. > > Thank you. > >> >>> >>> And a second question - how do I work with it? >>> I presume that function will have to be compiled in its own module >>> (either dll, so or dylib). >>> But then from the libpq interface how do I call it? >> >> >> It can use functions written in PL languages. See below: >> >> https://www.postgresql.org/docs/10/static/sql-createeventtrigger.html >> >> for an example written in plpgsql. >> >> >> >> >> >>> >>> Thank you. >>> >>>> >>>>> >>>>> Thank you. >>>>> >>>> >>>> >>>> -- >>>> Adrian Klaver >>>> adrian.klaver@aklaver.com >> >> >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com -- Adrian Klaver adrian.klaver@aklaver.com