diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml
index 00dfcac007..468aa2b2e2 100644
--- a/doc/src/sgml/ref/alter_function.sgml
+++ b/doc/src/sgml/ref/alter_function.sgml
@@ -1,5 +1,5 @@
@@ -20,8 +20,15 @@ PostgreSQL documentation
+ALTER FUNCTION name ( [ type [, ...] ] ) action [, ... ] [ RESTRICT ]
ALTER FUNCTION name ( [ type [, ...] ] ) RENAME TO newname
ALTER FUNCTION name ( [ type [, ...] ] ) OWNER TO newowner
+
+where action is one of:
+
+ CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
+ IMMUTABLE | STABLE | VOLATILE
+ [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
@@ -69,11 +76,65 @@ ALTER FUNCTION name ( [ newowner
- The new owner of the function.
- To change the owner of a function, you must be a superuser.
- Note that if the function is marked
- SECURITY DEFINER,
- it will subsequently execute as the new owner.
+ The new owner of the function. To change the owner of a
+ function, you must be a superuser. Note that if the function is
+ marked SECURITY DEFINER, it will subsequently
+ execute as the new owner.
+
+
+
+
+
+ CALLED ON NULL INPUT
+ RETURNS NULL ON NULL INPUT
+ STRICT
+
+
+
+ CALLED ON NULL INPUT changes the function so
+ that it will be invoked when some or all of its arguments are
+ null. RETURNS NULL ON NULL INPUT or
+ STRICT changes the function so that it
+ always returns null if any of its arguments are null. See for more information.
+
+
+
+
+
+ IMMUTABLE
+ STABLE
+ VOLATILE
+
+
+
+ Change the volatility of the function to the specified
+ type. See for more
+ information about function volatility.
+
+
+
+
+
+ EXTERNAL SECURITY INVOKER
+ EXTERNAL SECURITY DEFINER
+
+
+
+ Change whether the function is a security definer or not. The
+ key word EXTERNAL is ignored for SQL
+ conformance. See for more
+ information about this capability.
+
+
+
+
+
+ RESTRICT
+
+
+
+ Ignored for conformance with the SQL standard.
@@ -104,9 +165,13 @@ ALTER FUNCTION sqrt(integer) OWNER TO joe;
Compatibility
- There is an ALTER FUNCTION statement in the SQL
- standard, but it does not provide the option to rename the
- function or change the owner.
+ This statement is partially compatible with the ALTER
+ FUNCTION> statement in the SQL standard. The standard allows more
+ properties of a function to be modified, but does not provide the
+ ability to rename a function, make a function a security definer,
+ or change the owner or volatility of a function. The standard also
+ requires the RESTRICT> key word; it is optional in
+ PostgreSQL>.
diff --git a/doc/src/sgml/ref/alter_index.sgml b/doc/src/sgml/ref/alter_index.sgml
index 4ce4a6871c..7ea1f2e97a 100644
--- a/doc/src/sgml/ref/alter_index.sgml
+++ b/doc/src/sgml/ref/alter_index.sgml
@@ -1,5 +1,5 @@
@@ -20,10 +20,8 @@ PostgreSQL documentation
-ALTER INDEX name
- action [, ... ]
-ALTER INDEX name
- RENAME TO new_name
+ALTER INDEX nameaction [, ... ]
+ALTER INDEX name RENAME TO new_name
where action is one of:
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index e2afbce102..cbe14d130b 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -3,14 +3,14 @@
* functioncmds.c
*
* Routines for CREATE and DROP FUNCTION commands and CREATE and DROP
- * CAST commands.
+ * CAST commands.
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.55 2005/03/13 05:19:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.56 2005/03/14 00:19:36 neilc Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -195,12 +195,75 @@ examine_parameter_list(List *parameter, Oid languageOid,
return parameterCount;
}
+/*
+ * Recognize one of the options that can be passed to both CREATE
+ * FUNCTION and ALTER FUNCTION and return it via one of the out
+ * parameters. Returns true if the passed option was recognized. If
+ * the out parameter we were going to assign to points to non-NULL,
+ * raise a duplicate error.
+ */
+static bool
+compute_common_attribute(DefElem *defel,
+ DefElem **volatility_item,
+ DefElem **strict_item,
+ DefElem **security_item)
+{
+ if (strcmp(defel->defname, "volatility") == 0)
+ {
+ if (*volatility_item)
+ goto duplicate_error;
+
+ *volatility_item = defel;
+ }
+ else if (strcmp(defel->defname, "strict") == 0)
+ {
+ if (*strict_item)
+ goto duplicate_error;
+
+ *strict_item = defel;
+ }
+ else if (strcmp(defel->defname, "security") == 0)
+ {
+ if (*security_item)
+ goto duplicate_error;
+
+ *security_item = defel;
+ }
+ else
+ return false;
+
+ /* Recognized an option */
+ return true;
+
+duplicate_error:
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options")));
+ return false; /* keep compiler quiet */
+}
+
+static char
+interpret_func_volatility(DefElem *defel)
+{
+ char *str = strVal(defel->arg);
+
+ if (strcmp(str, "immutable") == 0)
+ return PROVOLATILE_IMMUTABLE;
+ else if (strcmp(str, "stable") == 0)
+ return PROVOLATILE_STABLE;
+ else if (strcmp(str, "volatile") == 0)
+ return PROVOLATILE_VOLATILE;
+ else
+ {
+ elog(ERROR, "invalid volatility \"%s\"", str);
+ return 0; /* keep compiler quiet */
+ }
+}
/*
* Dissect the list of options assembled in gram.y into function
* attributes.
*/
-
static void
compute_attributes_sql_style(List *options,
List **as,
@@ -236,29 +299,13 @@ compute_attributes_sql_style(List *options,
errmsg("conflicting or redundant options")));
language_item = defel;
}
- else if (strcmp(defel->defname, "volatility") == 0)
+ else if (compute_common_attribute(defel,
+ &volatility_item,
+ &strict_item,
+ &security_item))
{
- if (volatility_item)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
- volatility_item = defel;
- }
- else if (strcmp(defel->defname, "strict") == 0)
- {
- if (strict_item)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
- strict_item = defel;
- }
- else if (strcmp(defel->defname, "security") == 0)
- {
- if (security_item)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
- security_item = defel;
+ /* recognized common option */
+ continue;
}
else
elog(ERROR, "option \"%s\" not recognized",
@@ -280,18 +327,7 @@ compute_attributes_sql_style(List *options,
errmsg("no language specified")));
if (volatility_item)
- {
- if (strcmp(strVal(volatility_item->arg), "immutable") == 0)
- *volatility_p = PROVOLATILE_IMMUTABLE;
- else if (strcmp(strVal(volatility_item->arg), "stable") == 0)
- *volatility_p = PROVOLATILE_STABLE;
- else if (strcmp(strVal(volatility_item->arg), "volatile") == 0)
- *volatility_p = PROVOLATILE_VOLATILE;
- else
- elog(ERROR, "invalid volatility \"%s\"",
- strVal(volatility_item->arg));
- }
-
+ *volatility_p = interpret_func_volatility(volatility_item);
if (strict_item)
*strict_p = intVal(strict_item->arg);
if (security_item)
@@ -301,7 +337,7 @@ compute_attributes_sql_style(List *options,
/*-------------
* Interpret the parameters *parameters and return their contents via
- * out parameters *isStrict_p and *volatility_p.
+ * *isStrict_p and *volatility_p.
*
* These parameters supply optional information about a function.
* All have defaults if not specified. Parameters:
@@ -347,9 +383,7 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili
* In all other cases
*
* AS