Re: CREATE OR REPLACE FUNCTION

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

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > ... I see no reason to add this capability
> > if it requires adding a new toplevel keyword.
>
> That kind of annoys me too, but since the keyword can be made a TokenId,
> it won't create any conflicts. I think the argument of Oracle
> compatibility is probably a sufficient reason to do it with this syntax.

I just hate to add another psql help item and manual page for a REPLACE
FUNCTION. It seems to asymetrical.

Again, if we go all out and allow REPLACE for other items, it would be a
big win. In fact, I can see a REPLACE TYPE/OPERATOR, but again ALTER
would work for that too.

> > You could hack ALTER FUNCTION to create automatically if it
> > doesn't exist,
>
> That's considerably uglier than this alternative, wouldn't you say?
> We have no other ALTER commands that work that way.

Yes but that is assuming we want the ability to CREATE or ALTER in one
command, which I am not sure we need. Just CREATE to create it and
ALTER to replace it.

We could use CARLETAETRE as C-R-E-A-T-E and A-L-T-E-R mixed. :-)

Our stuff is different enough that I am not sure REPLACE has much
validity. However, we could allow REPLACE FUNCTION to behave as ALTER
FUNCTION and not advertize it so it would be used only for Oracle
compatibility.

OK, how about this. We do CREATE/ALTER FUNCTION and allow REPLACE to do
CREATE/ALTER FUNCTION as needed. That way, we allow a specific way to
alter a function that _will_ _fail_ if the function doesn't exist. And
we add REPLACE TABLE to do that same where it drops and recreates the
table if it already exists. People have asked for that in the past and
we have told them to DROP and ignore the result. Seems this would be a
nice win and be symetrical for all objects. And it gets us Oracle
compatibility.

(It would be nice for USER/INDEX/VIEW/SEQUENCE and the others too.)

--
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:57:00 Re: CREATE OR REPLACE FUNCTION
Previous Message Tom Lane 2001-09-22 15:37:17 Re: CREATE OR REPLACE FUNCTION