]> begriffs open source - ai-pg/blob - full-docs/man7/ALTER_PROCEDURE.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / ALTER_PROCEDURE.7
1 '\" t
2 .\"     Title: ALTER PROCEDURE
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "ALTER PROCEDURE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ALTER_PROCEDURE \- change the definition of a procedure
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
36     \fIaction\fR [ \&.\&.\&. ] [ RESTRICT ]
37 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
38     RENAME TO \fInew_name\fR
39 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
40     OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
41 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
42     SET SCHEMA \fInew_schema\fR
43 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
44     [ NO ] DEPENDS ON EXTENSION \fIextension_name\fR
45
46 where \fIaction\fR is one of:
47
48     [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
49     SET \fIconfiguration_parameter\fR { TO | = } { \fIvalue\fR | DEFAULT }
50     SET \fIconfiguration_parameter\fR FROM CURRENT
51     RESET \fIconfiguration_parameter\fR
52     RESET ALL
53 .fi
54 .SH "DESCRIPTION"
55 .PP
56 \fBALTER PROCEDURE\fR
57 changes the definition of a procedure\&.
58 .PP
59 You must own the procedure to use
60 \fBALTER PROCEDURE\fR\&. To change a procedure\*(Aqs schema, you must also have
61 CREATE
62 privilege on the new schema\&. To alter the owner, you must be able to
63 SET ROLE
64 to the new owning role, and that role must have
65 CREATE
66 privilege on the procedure\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the procedure\&. However, a superuser can alter ownership of any procedure anyway\&.)
67 .SH "PARAMETERS"
68 .PP
69 \fIname\fR
70 .RS 4
71 The name (optionally schema\-qualified) of an existing procedure\&. If no argument list is specified, the name must be unique in its schema\&.
72 .RE
73 .PP
74 \fIargmode\fR
75 .RS 4
76 The mode of an argument:
77 IN,
78 OUT,
79 INOUT, or
80 VARIADIC\&. If omitted, the default is
81 IN\&.
82 .RE
83 .PP
84 \fIargname\fR
85 .RS 4
86 The name of an argument\&. Note that
87 \fBALTER PROCEDURE\fR
88 does not actually pay any attention to argument names, since only the argument data types are used to determine the procedure\*(Aqs identity\&.
89 .RE
90 .PP
91 \fIargtype\fR
92 .RS 4
93 The data type(s) of the procedure\*(Aqs arguments (optionally schema\-qualified), if any\&. See
94 DROP PROCEDURE (\fBDROP_PROCEDURE\fR(7))
95 for the details of how the procedure is looked up using the argument data type(s)\&.
96 .RE
97 .PP
98 \fInew_name\fR
99 .RS 4
100 The new name of the procedure\&.
101 .RE
102 .PP
103 \fInew_owner\fR
104 .RS 4
105 The new owner of the procedure\&. Note that if the procedure is marked
106 SECURITY DEFINER, it will subsequently execute as the new owner\&.
107 .RE
108 .PP
109 \fInew_schema\fR
110 .RS 4
111 The new schema for the procedure\&.
112 .RE
113 .PP
114 \fIextension_name\fR
115 .RS 4
116 This form marks the procedure as dependent on the extension, or no longer dependent on the extension if
117 NO
118 is specified\&. A procedure that\*(Aqs marked as dependent on an extension is dropped when the extension is dropped, even if cascade is not specified\&. A procedure can depend upon multiple extensions, and will be dropped when any one of those extensions is dropped\&.
119 .RE
120 .PP
121 [ EXTERNAL ] SECURITY INVOKER
122 .br
123 [ EXTERNAL ] SECURITY DEFINER
124 .RS 4
125 Change whether the procedure is a security definer or not\&. The key word
126 EXTERNAL
127 is ignored for SQL conformance\&. See
128 CREATE PROCEDURE (\fBCREATE_PROCEDURE\fR(7))
129 for more information about this capability\&.
130 .RE
131 .PP
132 \fIconfiguration_parameter\fR
133 .br
134 \fIvalue\fR
135 .RS 4
136 Add or change the assignment to be made to a configuration parameter when the procedure is called\&. If
137 \fIvalue\fR
138 is
139 DEFAULT
140 or, equivalently,
141 RESET
142 is used, the procedure\-local setting is removed, so that the procedure executes with the value present in its environment\&. Use
143 RESET ALL
144 to clear all procedure\-local settings\&.
145 SET FROM CURRENT
146 saves the value of the parameter that is current when
147 \fBALTER PROCEDURE\fR
148 is executed as the value to be applied when the procedure is entered\&.
149 .sp
150 See
151 \fBSET\fR(7)
152 and
153 Chapter\ \&19
154 for more information about allowed parameter names and values\&.
155 .RE
156 .PP
157 RESTRICT
158 .RS 4
159 Ignored for conformance with the SQL standard\&.
160 .RE
161 .SH "EXAMPLES"
162 .PP
163 To rename the procedure
164 insert_data
165 with two arguments of type
166 integer
167 to
168 insert_record:
169 .sp
170 .if n \{\
171 .RS 4
172 .\}
173 .nf
174 ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;
175 .fi
176 .if n \{\
177 .RE
178 .\}
179 .PP
180 To change the owner of the procedure
181 insert_data
182 with two arguments of type
183 integer
184 to
185 joe:
186 .sp
187 .if n \{\
188 .RS 4
189 .\}
190 .nf
191 ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;
192 .fi
193 .if n \{\
194 .RE
195 .\}
196 .PP
197 To change the schema of the procedure
198 insert_data
199 with two arguments of type
200 integer
201 to
202 accounting:
203 .sp
204 .if n \{\
205 .RS 4
206 .\}
207 .nf
208 ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;
209 .fi
210 .if n \{\
211 .RE
212 .\}
213 .PP
214 To mark the procedure
215 insert_data(integer, integer)
216 as being dependent on the extension
217 myext:
218 .sp
219 .if n \{\
220 .RS 4
221 .\}
222 .nf
223 ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;
224 .fi
225 .if n \{\
226 .RE
227 .\}
228 .PP
229 To adjust the search path that is automatically set for a procedure:
230 .sp
231 .if n \{\
232 .RS 4
233 .\}
234 .nf
235 ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;
236 .fi
237 .if n \{\
238 .RE
239 .\}
240 .PP
241 To disable automatic setting of
242 \fIsearch_path\fR
243 for a procedure:
244 .sp
245 .if n \{\
246 .RS 4
247 .\}
248 .nf
249 ALTER PROCEDURE check_password(text) RESET search_path;
250 .fi
251 .if n \{\
252 .RE
253 .\}
254 .sp
255 The procedure will now execute with whatever search path is used by its caller\&.
256 .SH "COMPATIBILITY"
257 .PP
258 This statement is partially compatible with the
259 \fBALTER PROCEDURE\fR
260 statement in the SQL standard\&. The standard allows more properties of a procedure to be modified, but does not provide the ability to rename a procedure, make a procedure a security definer, attach configuration parameter values to a procedure, or change the owner, schema, or volatility of a procedure\&. The standard also requires the
261 RESTRICT
262 key word, which is optional in
263 PostgreSQL\&.
264 .SH "SEE ALSO"
265 CREATE PROCEDURE (\fBCREATE_PROCEDURE\fR(7)), DROP PROCEDURE (\fBDROP_PROCEDURE\fR(7)), ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), ALTER ROUTINE (\fBALTER_ROUTINE\fR(7))