Re: How to watch for schema changes - Mailing list pgsql-general

From David G. Johnston
Subject Re: How to watch for schema changes
Date
Msg-id CAKFQuwZTLG89P6oeQdFskeTmsSgnNu=BZ_802q4wAhvnR7g+Fg@mail.gmail.com
Whole thread Raw
In response to Re: How to watch for schema changes  (Igor Korot <ikorot01@gmail.com>)
Responses Re: How to watch for schema changes  (Igor Korot <ikorot01@gmail.com>)
List pgsql-general
On Thu, Jul 5, 2018 at 8:40 AM, Igor Korot <ikorot01@gmail.com> wrote:
Hi, David,

On Tue, Jul 3, 2018 at 1:46 PM, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> On Tue, Jul 3, 2018 at 11:41 AM, Igor Korot <ikorot01@gmail.com> 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?
Can't I just check if such function exists?

You can, and depending on how often you intend to execute said code, it is probably the better way.  It also requires pl/pgsql while CREATE OR REPLACE "just works" as a single SQL command.  It seems easier to give you the simple answer than to work out the details for the more complex one.

David J.

pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: How to watch for schema changes
Next
From: David Gauthier
Date:
Subject: As a table owner, can I grant "grant" ?