From f2c657375d894ed197071c91090025d68a6057f7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 2 Oct 2001 21:39:36 +0000 Subject: Add CREATE OR REPLACE FUNCTION syntax to allow replacing a function definition without changing the function's OID, thereby not breaking rules, views, triggers, etc that depend on it. From Gavin Sherry. --- doc/src/sgml/ref/create_function.sgml | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'doc/src/sgml/ref/create_function.sgml') diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index a24a4252cf0..b151f723a77 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -1,5 +1,5 @@ @@ -15,12 +15,12 @@ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.26 2001/09/03 -CREATE FUNCTION name ( [ argtype [, ...] ] ) +CREATE [ OR REPLACE ] FUNCTION name ( [ argtype [, ...] ] ) RETURNS rettype AS 'definition' LANGUAGE langname [ WITH ( attribute [, ...] ) ] -CREATE FUNCTION name ( [ argtype [, ...] ] ) +CREATE [ OR REPLACE ] FUNCTION name ( [ argtype [, ...] ] ) RETURNS rettype AS 'obj_file', 'link_symbol' LANGUAGE langname @@ -33,6 +33,8 @@ CREATE FUNCTION name ( [ CREATE FUNCTION defines a new function. + CREATE OR REPLACE FUNCTION will either create + a new function, or replace an existing definition. Parameters @@ -202,11 +204,6 @@ CREATE FUNCTION name ( [ - - Use DROP FUNCTION - to remove user-defined functions. - - The full SQL type syntax is allowed for input arguments and return value. However, some details of the @@ -250,6 +247,29 @@ CREATE FUNCTION name ( [ command. + + Use DROP FUNCTION + to remove user-defined functions. + + + + To update the definition of an existing function, use + CREATE OR REPLACE FUNCTION. Note that it is + not possible to change the name or argument types of a function + this way (if you tried, you'd just be creating a new, distinct + function). Also, CREATE OR REPLACE FUNCTION + will not let you change the return type of an existing function. + To do that, you must drop and re-create the function. + + + + If you drop and then re-create a function, the new function is not + the same entity as the old; you will break existing rules, views, + triggers, etc that referred to the old function. Use + CREATE OR REPLACE FUNCTION to change a function + definition without breaking objects that refer to the function. + + -- cgit v1.2.3