1ALTER FUNCTION(7)        PostgreSQL 11.3 Documentation       ALTER FUNCTION(7)
2
3
4

NAME

6       ALTER_FUNCTION - change the definition of a function
7

SYNOPSIS

9       ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
10           action [ ... ] [ RESTRICT ]
11       ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
12           RENAME TO new_name
13       ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
14           OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
15       ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
16           SET SCHEMA new_schema
17       ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
18           DEPENDS ON EXTENSION extension_name
19
20       where action is one of:
21
22           CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
23           IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF
24           [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
25           PARALLEL { UNSAFE | RESTRICTED | SAFE }
26           COST execution_cost
27           ROWS result_rows
28           SET configuration_parameter { TO | = } { value | DEFAULT }
29           SET configuration_parameter FROM CURRENT
30           RESET configuration_parameter
31           RESET ALL
32

DESCRIPTION

34       ALTER FUNCTION changes the definition of a function.
35
36       You must own the function to use ALTER FUNCTION. To change a function's
37       schema, you must also have CREATE privilege on the new schema. To alter
38       the owner, you must also be a direct or indirect member of the new
39       owning role, and that role must have CREATE privilege on the function's
40       schema. (These restrictions enforce that altering the owner doesn't do
41       anything you couldn't do by dropping and recreating the function.
42       However, a superuser can alter ownership of any function anyway.)
43

PARAMETERS

45       name
46           The name (optionally schema-qualified) of an existing function. If
47           no argument list is specified, the name must be unique in its
48           schema.
49
50       argmode
51           The mode of an argument: IN, OUT, INOUT, or VARIADIC. If omitted,
52           the default is IN. Note that ALTER FUNCTION does not actually pay
53           any attention to OUT arguments, since only the input arguments are
54           needed to determine the function's identity. So it is sufficient to
55           list the IN, INOUT, and VARIADIC arguments.
56
57       argname
58           The name of an argument. Note that ALTER FUNCTION does not actually
59           pay any attention to argument names, since only the argument data
60           types are needed to determine the function's identity.
61
62       argtype
63           The data type(s) of the function's arguments (optionally
64           schema-qualified), if any.
65
66       new_name
67           The new name of the function.
68
69       new_owner
70           The new owner of the function. Note that if the function is marked
71           SECURITY DEFINER, it will subsequently execute as the new owner.
72
73       new_schema
74           The new schema for the function.
75
76       extension_name
77           The name of the extension that the function is to depend on.
78
79       CALLED ON NULL INPUT
80       RETURNS NULL ON NULL INPUT
81       STRICT
82           CALLED ON NULL INPUT changes the function so that it will be
83           invoked when some or all of its arguments are null.  RETURNS NULL
84           ON NULL INPUT or STRICT changes the function so that it is not
85           invoked if any of its arguments are null; instead, a null result is
86           assumed automatically. See CREATE FUNCTION (CREATE_FUNCTION(7)) for
87           more information.
88
89       IMMUTABLE
90       STABLE
91       VOLATILE
92           Change the volatility of the function to the specified setting. See
93           CREATE FUNCTION (CREATE_FUNCTION(7)) for details.
94
95       [ EXTERNAL ] SECURITY INVOKER
96       [ EXTERNAL ] SECURITY DEFINER
97           Change whether the function is a security definer or not. The key
98           word EXTERNAL is ignored for SQL conformance. See CREATE FUNCTION
99           (CREATE_FUNCTION(7)) for more information about this capability.
100
101       PARALLEL
102           Change whether the function is deemed safe for parallelism. See
103           CREATE FUNCTION (CREATE_FUNCTION(7)) for details.
104
105       LEAKPROOF
106           Change whether the function is considered leakproof or not. See
107           CREATE FUNCTION (CREATE_FUNCTION(7)) for more information about
108           this capability.
109
110       COST execution_cost
111           Change the estimated execution cost of the function. See CREATE
112           FUNCTION (CREATE_FUNCTION(7)) for more information.
113
114       ROWS result_rows
115           Change the estimated number of rows returned by a set-returning
116           function. See CREATE FUNCTION (CREATE_FUNCTION(7)) for more
117           information.
118
119       configuration_parameter
120       value
121           Add or change the assignment to be made to a configuration
122           parameter when the function is called. If value is DEFAULT or,
123           equivalently, RESET is used, the function-local setting is removed,
124           so that the function executes with the value present in its
125           environment. Use RESET ALL to clear all function-local settings.
126           SET FROM CURRENT saves the value of the parameter that is current
127           when ALTER FUNCTION is executed as the value to be applied when the
128           function is entered.
129
130           See SET(7) and Chapter 19 for more information about allowed
131           parameter names and values.
132
133       RESTRICT
134           Ignored for conformance with the SQL standard.
135

EXAMPLES

137       To rename the function sqrt for type integer to square_root:
138
139           ALTER FUNCTION sqrt(integer) RENAME TO square_root;
140
141       To change the owner of the function sqrt for type integer to joe:
142
143           ALTER FUNCTION sqrt(integer) OWNER TO joe;
144
145       To change the schema of the function sqrt for type integer to maths:
146
147           ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
148
149       To mark the function sqrt for type integer as being dependent on the
150       extension mathlib:
151
152           ALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib;
153
154       To adjust the search path that is automatically set for a function:
155
156           ALTER FUNCTION check_password(text) SET search_path = admin, pg_temp;
157
158       To disable automatic setting of search_path for a function:
159
160           ALTER FUNCTION check_password(text) RESET search_path;
161
162       The function will now execute with whatever search path is used by its
163       caller.
164

COMPATIBILITY

166       This statement is partially compatible with the ALTER FUNCTION
167       statement in the SQL standard. The standard allows more properties of a
168       function to be modified, but does not provide the ability to rename a
169       function, make a function a security definer, attach configuration
170       parameter values to a function, or change the owner, schema, or
171       volatility of a function. The standard also requires the RESTRICT key
172       word, which is optional in PostgreSQL.
173

SEE ALSO

175       CREATE FUNCTION (CREATE_FUNCTION(7)), DROP FUNCTION (DROP_FUNCTION(7)),
176       ALTER PROCEDURE (ALTER_PROCEDURE(7)), ALTER ROUTINE (ALTER_ROUTINE(7))
177
178
179
180PostgreSQL 11.3                      2019                    ALTER FUNCTION(7)
Impressum