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

From Ian Lance Taylor
Subject Re: CREATE OR REPLACE FUNCTION
Date
Msg-id silmj9pok3.fsf@daffy.airs.com
Whole thread Raw
In response to Re: CREATE OR REPLACE FUNCTION  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane <tgl@sss.pgh.pa.us> writes:

> 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.

> ...

> 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...

ALTER FUNCTION seems strange to me, since the point of CREATE OR
REPLACE FUNCTION really is to create the function.  OR REPLACE is a
convenience feature when loading PL/SQL (or PL/pgSQL) files into the
database: you don't have to add a DROP FUNCTION command before each
CREATE FUNCTION command, and you don't have to look at all the
comments or warnings about dropping functions.

We actually have an implementation of CREATE OR REPLACE FUNCTION at
Zembu which I've never bothered rolling up and sending in.  It simply
drops the function first.

Ian

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: CREATE OR REPLACE FUNCTION
Next
From: Marko Kreen
Date:
Subject: pgcrypto update