Re: CREATE OR REPLACE FUNCTION - Mailing list pgsql-patches

From Tom Lane
Subject Re: CREATE OR REPLACE FUNCTION
Date
Msg-id 3278.1001016546@sss.pgh.pa.us
Whole thread Raw
In response to CREATE OR REPLACE FUNCTION  (Gavin Sherry <swm@linuxworld.com.au>)
Responses Re: CREATE OR REPLACE FUNCTION
Re: CREATE OR REPLACE FUNCTION
Re: CREATE OR REPLACE FUNCTION
List pgsql-patches
Gavin Sherry <swm@linuxworld.com.au> writes:
> Here's a patch I put together. I thought the Oracle-style 'CREATE OR
> REPLACE FUNCTION' syntax might be useful to those doing lots of function
> creation/development. It is against the 7.1.3 source.

Hmm.  There are a couple of things that are a tad ugly about this patch
--- you should be heap_update'ing the pg_proc entry, not doing a delete
and insert --- but the main thing I don't like is that there's no
checking to ensure that the function return type doesn't change.  We
can't allow that; it'd break stored views etc that use the function.

It'd probably also be a good idea to insist that the replacer be the
same as the original owner.  (Possibly RemoveFunction does that for you
in the patch as it stands, but it'll need an explicit test if you go
the update route.)

BTW, I've been assuming that when we got around to providing a
capability like this, it'd be via an "ALTER FUNCTION" kind of
statement.  Does anyone have a strong feeling pro or con on whether
"CREATE OR REPLACE" is a preferable approach?  It doesn't seem to
fit with the spirit of our other maintenance commands, but maybe
we should just bow down before the Oracle and do it their way...

            regards, tom lane

pgsql-patches by date:

Previous
From: Gavin Sherry
Date:
Subject: CREATE OR REPLACE FUNCTION
Next
From: Ian Lance Taylor
Date:
Subject: Re: CREATE OR REPLACE FUNCTION