]> begriffs open source - ai-pg/blob - full-docs/txt/sql-alterprocedure.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-alterprocedure.txt
1
2 ALTER PROCEDURE
3
4    ALTER PROCEDURE — change the definition of a procedure
5
6 Synopsis
7
8 ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
9     action [ ... ] [ RESTRICT ]
10 ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
11     RENAME TO new_name
12 ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
13     OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
14 ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
15     SET SCHEMA new_schema
16 ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
17     [ NO ] DEPENDS ON EXTENSION extension_name
18
19 where action is one of:
20
21     [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
22     SET configuration_parameter { TO | = } { value | DEFAULT }
23     SET configuration_parameter FROM CURRENT
24     RESET configuration_parameter
25     RESET ALL
26
27 Description
28
29    ALTER PROCEDURE changes the definition of a procedure.
30
31    You must own the procedure to use ALTER PROCEDURE. To change a
32    procedure's schema, you must also have CREATE privilege on the new
33    schema. To alter the owner, you must be able to SET ROLE to the new
34    owning role, and that role must have CREATE privilege on the
35    procedure's schema. (These restrictions enforce that altering the owner
36    doesn't do anything you couldn't do by dropping and recreating the
37    procedure. However, a superuser can alter ownership of any procedure
38    anyway.)
39
40 Parameters
41
42    name
43           The name (optionally schema-qualified) of an existing procedure.
44           If no argument list is specified, the name must be unique in its
45           schema.
46
47    argmode
48           The mode of an argument: IN, OUT, INOUT, or VARIADIC. If
49           omitted, the default is IN.
50
51    argname
52           The name of an argument. Note that ALTER PROCEDURE does not
53           actually pay any attention to argument names, since only the
54           argument data types are used to determine the procedure's
55           identity.
56
57    argtype
58           The data type(s) of the procedure's arguments (optionally
59           schema-qualified), if any. See DROP PROCEDURE for the details of
60           how the procedure is looked up using the argument data type(s).
61
62    new_name
63           The new name of the procedure.
64
65    new_owner
66           The new owner of the procedure. Note that if the procedure is
67           marked SECURITY DEFINER, it will subsequently execute as the new
68           owner.
69
70    new_schema
71           The new schema for the procedure.
72
73    extension_name
74           This form marks the procedure as dependent on the extension, or
75           no longer dependent on the extension if NO is specified. A
76           procedure that's marked as dependent on an extension is dropped
77           when the extension is dropped, even if cascade is not specified.
78           A procedure can depend upon multiple extensions, and will be
79           dropped when any one of those extensions is dropped.
80
81    [ EXTERNAL ] SECURITY INVOKER
82           [ EXTERNAL ] SECURITY DEFINER
83           Change whether the procedure is a security definer or not. The
84           key word EXTERNAL is ignored for SQL conformance. See CREATE
85           PROCEDURE for more information about this capability.
86
87    configuration_parameter
88           value
89           Add or change the assignment to be made to a configuration
90           parameter when the procedure is called. If value is DEFAULT or,
91           equivalently, RESET is used, the procedure-local setting is
92           removed, so that the procedure executes with the value present
93           in its environment. Use RESET ALL to clear all procedure-local
94           settings. SET FROM CURRENT saves the value of the parameter that
95           is current when ALTER PROCEDURE is executed as the value to be
96           applied when the procedure is entered.
97
98           See SET and Chapter 19 for more information about allowed
99           parameter names and values.
100
101    RESTRICT
102           Ignored for conformance with the SQL standard.
103
104 Examples
105
106    To rename the procedure insert_data with two arguments of type integer
107    to insert_record:
108 ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;
109
110    To change the owner of the procedure insert_data with two arguments of
111    type integer to joe:
112 ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;
113
114    To change the schema of the procedure insert_data with two arguments of
115    type integer to accounting:
116 ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;
117
118    To mark the procedure insert_data(integer, integer) as being dependent
119    on the extension myext:
120 ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;
121
122    To adjust the search path that is automatically set for a procedure:
123 ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;
124
125    To disable automatic setting of search_path for a procedure:
126 ALTER PROCEDURE check_password(text) RESET search_path;
127
128    The procedure will now execute with whatever search path is used by its
129    caller.
130
131 Compatibility
132
133    This statement is partially compatible with the ALTER PROCEDURE
134    statement in the SQL standard. The standard allows more properties of a
135    procedure to be modified, but does not provide the ability to rename a
136    procedure, make a procedure a security definer, attach configuration
137    parameter values to a procedure, or change the owner, schema, or
138    volatility of a procedure. The standard also requires the RESTRICT key
139    word, which is optional in PostgreSQL.
140
141 See Also
142
143    CREATE PROCEDURE, DROP PROCEDURE, ALTER FUNCTION, ALTER ROUTINE