1ALTER FUNCTION(7) PostgreSQL 9.2.24 Documentation ALTER FUNCTION(7)
2
3
4
6 ALTER_FUNCTION - change the definition of a function
7
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
15 ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
16 SET SCHEMA new_schema
17
18 where action is one of:
19
20 CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
21 IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF
22 [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
23 COST execution_cost
24 ROWS result_rows
25 SET configuration_parameter { TO | = } { value | DEFAULT }
26 SET configuration_parameter FROM CURRENT
27 RESET configuration_parameter
28 RESET ALL
29
31 ALTER FUNCTION changes the definition of a function.
32
33 You must own the function to use ALTER FUNCTION. To change a function's
34 schema, you must also have CREATE privilege on the new schema. To alter
35 the owner, you must also be a direct or indirect member of the new
36 owning role, and that role must have CREATE privilege on the function's
37 schema. (These restrictions enforce that altering the owner doesn't do
38 anything you couldn't do by dropping and recreating the function.
39 However, a superuser can alter ownership of any function anyway.)
40
42 name
43 The name (optionally schema-qualified) of an existing function.
44
45 argmode
46 The mode of an argument: IN, OUT, INOUT, or VARIADIC. If omitted,
47 the default is IN. Note that ALTER FUNCTION does not actually pay
48 any attention to OUT arguments, since only the input arguments are
49 needed to determine the function's identity. So it is sufficient to
50 list the IN, INOUT, and VARIADIC arguments.
51
52 argname
53 The name of an argument. Note that ALTER FUNCTION does not actually
54 pay any attention to argument names, since only the argument data
55 types are needed to determine the function's identity.
56
57 argtype
58 The data type(s) of the function's arguments (optionally
59 schema-qualified), if any.
60
61 new_name
62 The new name of the function.
63
64 new_owner
65 The new owner of the function. Note that if the function is marked
66 SECURITY DEFINER, it will subsequently execute as the new owner.
67
68 new_schema
69 The new schema for the function.
70
71 CALLED ON NULL INPUT, RETURNS NULL ON NULL INPUT, STRICT
72 CALLED ON NULL INPUT changes the function so that it will be
73 invoked when some or all of its arguments are null. RETURNS NULL
74 ON NULL INPUT or STRICT changes the function so that it is not
75 invoked if any of its arguments are null; instead, a null result is
76 assumed automatically. See CREATE FUNCTION (CREATE_FUNCTION(7)) for
77 more information.
78
79 IMMUTABLE, STABLE, VOLATILE
80 Change the volatility of the function to the specified setting. See
81 CREATE FUNCTION (CREATE_FUNCTION(7)) for details.
82
83 [ EXTERNAL ] SECURITY INVOKER, [ EXTERNAL ] SECURITY DEFINER
84 Change whether the function is a security definer or not. The key
85 word EXTERNAL is ignored for SQL conformance. See CREATE FUNCTION
86 (CREATE_FUNCTION(7)) for more information about this capability.
87
88 LEAKPROOF
89 Change whether the function is considered leakproof or not. See
90 CREATE FUNCTION (CREATE_FUNCTION(7)) for more information about
91 this capability.
92
93 COST execution_cost
94 Change the estimated execution cost of the function. See CREATE
95 FUNCTION (CREATE_FUNCTION(7)) for more information.
96
97 ROWS result_rows
98 Change the estimated number of rows returned by a set-returning
99 function. See CREATE FUNCTION (CREATE_FUNCTION(7)) for more
100 information.
101
102 configuration_parameter, value
103 Add or change the assignment to be made to a configuration
104 parameter when the function is called. If value is DEFAULT or,
105 equivalently, RESET is used, the function-local setting is removed,
106 so that the function executes with the value present in its
107 environment. Use RESET ALL to clear all function-local settings.
108 SET FROM CURRENT saves the value of the parameter that is current
109 when ALTER FUNCTION is executed as the value to be applied when the
110 function is entered.
111
112 See SET(7) and Chapter 18, Server Configuration, in the
113 documentation for more information about allowed parameter names
114 and values.
115
116 RESTRICT
117 Ignored for conformance with the SQL standard.
118
120 To rename the function sqrt for type integer to square_root:
121
122 ALTER FUNCTION sqrt(integer) RENAME TO square_root;
123
124 To change the owner of the function sqrt for type integer to joe:
125
126 ALTER FUNCTION sqrt(integer) OWNER TO joe;
127
128 To change the schema of the function sqrt for type integer to maths:
129
130 ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
131
132 To adjust the search path that is automatically set for a function:
133
134 ALTER FUNCTION check_password(text) SET search_path = admin, pg_temp;
135
136 To disable automatic setting of search_path for a function:
137
138 ALTER FUNCTION check_password(text) RESET search_path;
139
140 The function will now execute with whatever search path is used by its
141 caller.
142
144 This statement is partially compatible with the ALTER FUNCTION
145 statement in the SQL standard. The standard allows more properties of a
146 function to be modified, but does not provide the ability to rename a
147 function, make a function a security definer, attach configuration
148 parameter values to a function, or change the owner, schema, or
149 volatility of a function. The standard also requires the RESTRICT key
150 word, which is optional in PostgreSQL.
151
153 CREATE FUNCTION (CREATE_FUNCTION(7)), DROP FUNCTION (DROP_FUNCTION(7))
154
155
156
157PostgreSQL 9.2.24 2017-11-06 ALTER FUNCTION(7)