4 ALTER FUNCTION — change the definition of a function
8 ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
9 action [ ... ] [ RESTRICT ]
10 ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
12 ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
13 OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
14 ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
16 ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
17 [ NO ] DEPENDS ON EXTENSION extension_name
19 where action is one of:
21 CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
22 IMMUTABLE | STABLE | VOLATILE
24 [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
25 PARALLEL { UNSAFE | RESTRICTED | SAFE }
28 SUPPORT support_function
29 SET configuration_parameter { TO | = } { value | DEFAULT }
30 SET configuration_parameter FROM CURRENT
31 RESET configuration_parameter
36 ALTER FUNCTION changes the definition of a function.
38 You must own the function to use ALTER FUNCTION. To change a function's
39 schema, you must also have CREATE privilege on the new schema. To alter
40 the owner, you must be able to SET ROLE to the new owning role, and
41 that role must have CREATE privilege on the function's schema. (These
42 restrictions enforce that altering the owner doesn't do anything you
43 couldn't do by dropping and recreating the function. However, a
44 superuser can alter ownership of any function anyway.)
49 The name (optionally schema-qualified) of an existing function.
50 If no argument list is specified, the name must be unique in its
54 The mode of an argument: IN, OUT, INOUT, or VARIADIC. If
55 omitted, the default is IN. Note that ALTER FUNCTION does not
56 actually pay any attention to OUT arguments, since only the
57 input arguments are needed to determine the function's identity.
58 So it is sufficient to list the IN, INOUT, and VARIADIC
62 The name of an argument. Note that ALTER FUNCTION does not
63 actually pay any attention to argument names, since only the
64 argument data types are needed to determine the function's
68 The data type(s) of the function's arguments (optionally
69 schema-qualified), if any.
72 The new name of the function.
75 The new owner of the function. Note that if the function is
76 marked SECURITY DEFINER, it will subsequently execute as the new
80 The new schema for the function.
82 DEPENDS ON EXTENSION extension_name
83 NO DEPENDS ON EXTENSION extension_name
84 This form marks the function as dependent on the extension, or
85 no longer dependent on that extension if NO is specified. A
86 function that's marked as dependent on an extension is dropped
87 when the extension is dropped, even if CASCADE is not specified.
88 A function can depend upon multiple extensions, and will be
89 dropped when any one of those extensions is dropped.
92 RETURNS NULL ON NULL INPUT
94 CALLED ON NULL INPUT changes the function so that it will be
95 invoked when some or all of its arguments are null. RETURNS NULL
96 ON NULL INPUT or STRICT changes the function so that it is not
97 invoked if any of its arguments are null; instead, a null result
98 is assumed automatically. See CREATE FUNCTION for more
104 Change the volatility of the function to the specified setting.
105 See CREATE FUNCTION for details.
107 [ EXTERNAL ] SECURITY INVOKER
108 [ EXTERNAL ] SECURITY DEFINER
109 Change whether the function is a security definer or not. The
110 key word EXTERNAL is ignored for SQL conformance. See CREATE
111 FUNCTION for more information about this capability.
114 Change whether the function is deemed safe for parallelism. See
115 CREATE FUNCTION for details.
118 Change whether the function is considered leakproof or not. See
119 CREATE FUNCTION for more information about this capability.
122 Change the estimated execution cost of the function. See CREATE
123 FUNCTION for more information.
126 Change the estimated number of rows returned by a set-returning
127 function. See CREATE FUNCTION for more information.
129 SUPPORT support_function
130 Set or change the planner support function to use for this
131 function. See Section 36.11 for details. You must be superuser
134 This option cannot be used to remove the support function
135 altogether, since it must name a new support function. Use
136 CREATE OR REPLACE FUNCTION if you need to do that.
138 configuration_parameter
140 Add or change the assignment to be made to a configuration
141 parameter when the function is called. If value is DEFAULT or,
142 equivalently, RESET is used, the function-local setting is
143 removed, so that the function executes with the value present in
144 its environment. Use RESET ALL to clear all function-local
145 settings. SET FROM CURRENT saves the value of the parameter that
146 is current when ALTER FUNCTION is executed as the value to be
147 applied when the function is entered.
149 See SET and Chapter 19 for more information about allowed
150 parameter names and values.
153 Ignored for conformance with the SQL standard.
157 To rename the function sqrt for type integer to square_root:
158 ALTER FUNCTION sqrt(integer) RENAME TO square_root;
160 To change the owner of the function sqrt for type integer to joe:
161 ALTER FUNCTION sqrt(integer) OWNER TO joe;
163 To change the schema of the function sqrt for type integer to maths:
164 ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
166 To mark the function sqrt for type integer as being dependent on the
168 ALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib;
170 To adjust the search path that is automatically set for a function:
171 ALTER FUNCTION check_password(text) SET search_path = admin, pg_temp;
173 To disable automatic setting of search_path for a function:
174 ALTER FUNCTION check_password(text) RESET search_path;
176 The function will now execute with whatever search path is used by its
181 This statement is partially compatible with the ALTER FUNCTION
182 statement in the SQL standard. The standard allows more properties of a
183 function to be modified, but does not provide the ability to rename a
184 function, make a function a security definer, attach configuration
185 parameter values to a function, or change the owner, schema, or
186 volatility of a function. The standard also requires the RESTRICT key
187 word, which is optional in PostgreSQL.
191 CREATE FUNCTION, DROP FUNCTION, ALTER PROCEDURE, ALTER ROUTINE