Re: CREATE OR REPLACE FUNCTION

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: CREATE OR REPLACE FUNCTION
Date: 2001-09-22 14:24:48
Message-ID: 200109221424.f8MEOmL08996@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

> On Sat, 22 Sep 2001, Bruce Momjian wrote:
>
> [snip]
>
> > I assume it preserves the function's OID? That is something we have
> > needed for a while because it would keep oid references to the function
> > the same, or at least we should give people the option of keeping the
> > oid.
>
> Yes. The idea is that the oid is preserved. I have assumed that people
> would always want it to be if they were replacing the function. Would
> there be a time when someone wouldn't want to do this? It would be pretty
> simple to update the patch to handle a syntax which specified that a new
> oid should be generated.

Agreed. I think they always want the OID preserved. If they want a new
one, they can drop/create.

You have a good point about REPLACE allowing CREATE/ALTER depending on
whether it already exists, but I see no reason to add this capability
if it requires adding a new toplevel keyword. We already have tons of
them. You could hack ALTER FUNCTION to create automatically if it
doesn't exist, and throw a message to the user if you create it.

However, if we decide we want REPLACE TABLE, etc then I think the
REPLACE FUNCTION would be a good idea. People have asked for this
capability and we have said, "Just drop the table first and ignore the
error if it doesn't exist." The special case here is that the
REPLACE/ALTER FUNCTION preserves the OID, which gives it a special
capability not appropriate for the other objects.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-09-22 15:37:17 Re: CREATE OR REPLACE FUNCTION
Previous Message Gavin Sherry 2001-09-22 11:59:40 Re: CREATE OR REPLACE FUNCTION