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 1fb7ek-0004EB-CD for pgsql-general@arkaria.postgresql.org; Thu, 05 Jul 2018 17:02:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fb7ei-00054O-0B for pgsql-general@arkaria.postgresql.org; Thu, 05 Jul 2018 17:02:56 +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.89) (envelope-from ) id 1fb7eH-0002u5-A7 for pgsql-general@lists.postgresql.org; Thu, 05 Jul 2018 17:02:31 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fb7eB-000706-C7 for pgsql-general@postgresql.org; Thu, 05 Jul 2018 17:02:28 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 29DCF21E0F; Thu, 5 Jul 2018 13:02:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Jul 2018 13:02:21 -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=HkJK5RJs3ag3vgZ9FK4PwL0pa5A5M TmliDADZyzxFGs=; b=Gx9QX4PxLh8EoXR74HErDatUZcNL3YnhDnXOmZ6suaxLQ BesuQeMqouF3S0/AW9mVon1EndXnsvHRqihWciso+qNQoiFnDiSHlht9CvCdRgut qFkmQxPOfETQqLeIRKjFyMOWNf2oqwEk2v2DyEKxYWhdKK7Q+pspTFD0aGjDRSCD Eu0330uAXoz+OYu+Byis/An5PvOcpf/vTcqKIGI2dqHN+2xTChzxyHsBC4tuXChB TpYjJYAyj6T5T0CSuITPS+E6OoC5HVUo625RRhNYAzf9/ojdhsWQAVuXFglRB96r 8M2ntSOatF9lZ4qhDWJMcNnsUam+iphB8Z7kNvvzQ== 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=HkJK5R Js3ag3vgZ9FK4PwL0pa5A5MTmliDADZyzxFGs=; b=NWYgffx2smaHvKa3xKHHts qw6uM9euVQZsXhU5R/c8iUGuATwIS02wUGS23veDHyfX8j3w62m2ssZUI2N8mqkI 0s/CzHTcEgrJa4mkfWtmzRFy5R6cpXB7kkonr7sul3HT4D5VpqwUlvpytl0ylWAQ oBhqXz13Kvaef7yUFw6a405xrzD6ii8vTUkXqVQWRIGlq6v+qc76sL8fQltZgy5U enBWoPOcgDXsy8Ii9OoVLsXasCBAJ5rXwaDON6HYNMVOal45mrPV16GokElsP/MW 286vBHSvrM6eg7wT7IPMPsIyMH2rqu5QJG0VBfTbmnfYVy0XA0FhKQVS0L2gu5ag == X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (74-93-105-186-washington.hfc.comcastbusiness.net [74.93.105.186]) by mail.messagingengine.com (Postfix) with ESMTPA id F067FE4439; Thu, 5 Jul 2018 13:02:19 -0400 (EDT) Subject: Re: How to watch for schema changes To: Igor Korot , "David G. Johnston" Cc: pgsql-general References: <7fc929ec-8e34-5824-6511-d1dd1188434f@aklaver.com> From: Adrian Klaver Message-ID: Date: Thu, 5 Jul 2018 10:02:18 -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/05/2018 08:40 AM, Igor Korot wrote: > Hi, David, > > On Tue, Jul 3, 2018 at 1:46 PM, David G. Johnston > wrote: >> On Tue, Jul 3, 2018 at 11:41 AM, Igor Korot wrote: >>> >>> >>> I presume threre is a query which check for the function/trigger >>> existence? Something like: >>> >>> IF NOT EXIST(SELECT * FROM ) CREATE OR REPLACE FUNCTION....; >> >> >> CREATE OR REPLACE is how you re-create a function that (whose >> name/signature) might already exist; CREATE already assumes one doesn't >> exist. > > Why do I need to re-create a function with exactly the same name and body If you use CREATE OR REPLACE FUNCTION it will do just that each time you call it. Seems like overkill to me. See below for another way. > Can't I just check if such function exists? Something like this: SELECT count(*) FROM pg_proc AS proc JOIN pg_namespace AS ns ON proc.pronamespace = ns.oid WHERE ns.nspname='public' -- Function schema AND proname = 'tag_rcv_undo' -- Function name ; > > Thank you. > >> >> David J. >> -- Adrian Klaver adrian.klaver@aklaver.com