From e7889b83b7059e776f0a3d76bbbdd98687f4592c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 3 Sep 2007 18:46:30 +0000 Subject: Support SET FROM CURRENT in CREATE/ALTER FUNCTION, ALTER DATABASE, ALTER ROLE. (Actually, it works as a plain statement too, but I didn't document that because it seems a bit useless.) Unify VariableResetStmt with VariableSetStmt, and clean up some ancient cruft in the representation of same. --- doc/src/sgml/ref/alter_database.sgml | 86 ++++++++++++++++++----------------- doc/src/sgml/ref/alter_function.sgml | 14 ++++-- doc/src/sgml/ref/alter_role.sgml | 8 +++- doc/src/sgml/ref/alter_user.sgml | 4 +- doc/src/sgml/ref/create_function.sgml | 8 ++-- 5 files changed, 68 insertions(+), 52 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/alter_database.sgml b/doc/src/sgml/ref/alter_database.sgml index 8ddff97e029..d16cc2fdad1 100644 --- a/doc/src/sgml/ref/alter_database.sgml +++ b/doc/src/sgml/ref/alter_database.sgml @@ -1,5 +1,5 @@ @@ -26,12 +26,14 @@ where option can be: CONNECTION LIMIT connlimit -ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT } -ALTER DATABASE name RESET parameter - ALTER DATABASE name RENAME TO newname ALTER DATABASE name OWNER TO new_owner + +ALTER DATABASE name SET configuration_parameter { TO | = } { value | DEFAULT } +ALTER DATABASE name SET configuration_parameter FROM CURRENT +ALTER DATABASE name RESET configuration_parameter +ALTER DATABASE name RESET ALL @@ -49,20 +51,7 @@ ALTER DATABASE name OWNER TO - The second and third forms change the session default for a run-time - configuration variable for a PostgreSQL - database. Whenever a new session is subsequently started in that - database, the specified value becomes the session default value. - The database-specific default overrides whatever setting is present - in postgresql.conf or has been received from the - postgres command line. Only the database - owner or a superuser can change the session defaults for a - database. Certain variables cannot be set this way, or can only be - set by a superuser. - - - - The fourth form changes the name of the database. Only the database + The second form changes the name of the database. Only the database owner or a superuser can rename a database; non-superuser owners must also have the CREATEDB privilege. The current database cannot @@ -71,12 +60,25 @@ ALTER DATABASE name OWNER TO - The fifth form changes the owner of the database. + The third form changes the owner of the database. To alter the owner, you must own the database and also be a direct or indirect member of the new owning role, and you must have the CREATEDB privilege. (Note that superusers have all these privileges automatically.) + + + The remaining forms change the session default for a run-time + configuration variable for a PostgreSQL + database. Whenever a new session is subsequently started in that + database, the specified value becomes the session default value. + The database-specific default overrides whatever setting is present + in postgresql.conf or has been received from the + postgres command line. Only the database + owner or a superuser can change the session defaults for a + database. Certain variables cannot be set this way, or can only be + set by a superuser. + @@ -102,8 +104,26 @@ ALTER DATABASE name OWNER TO + + newname + + + The new name of the database. + + + + + + new_owner + + + The new owner of the database. + + + + - parameter + configuration_parameter value @@ -114,6 +134,8 @@ ALTER DATABASE name OWNER TO RESET ALL to clear all database-specific settings. + SET FROM CURRENT saves the session's current value of + the parameter as the database-specific value. @@ -123,24 +145,6 @@ ALTER DATABASE name OWNER TO - - - newname - - - The new name of the database. - - - - - - new_owner - - - The new owner of the database. - - - @@ -148,10 +152,10 @@ ALTER DATABASE name OWNER TO Notes - It is also possible to tie a session default to a specific user + It is also possible to tie a session default to a specific role rather than to a database; see - . - User-specific settings override database-specific + . + Role-specific settings override database-specific ones if there is a conflict. diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml index 964603b067a..bee2f6f4390 100644 --- a/doc/src/sgml/ref/alter_function.sgml +++ b/doc/src/sgml/ref/alter_function.sgml @@ -1,5 +1,5 @@ @@ -21,7 +21,7 @@ PostgreSQL documentation ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) - action [, ... ] [ RESTRICT ] + action [ ... ] [ RESTRICT ] ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) RENAME TO new_name ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) @@ -36,8 +36,10 @@ where action is one of: [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER COST execution_cost ROWS result_rows - SET parameter { TO | = } { value | DEFAULT } - RESET parameter + SET configuration_parameter { TO | = } { value | DEFAULT } + SET configuration_parameter FROM CURRENT + RESET configuration_parameter + RESET ALL @@ -215,7 +217,7 @@ where action is one of: - parameter + configuration_parameter value @@ -226,6 +228,8 @@ where action is one of: setting is removed, so that the function executes with the value present in its environment. Use RESET ALL to clear all function-local settings. + SET FROM CURRENT saves the session's current value of + the parameter as the value to be applied when the function is entered. diff --git a/doc/src/sgml/ref/alter_role.sgml b/doc/src/sgml/ref/alter_role.sgml index ce28f2ad597..a471095e496 100644 --- a/doc/src/sgml/ref/alter_role.sgml +++ b/doc/src/sgml/ref/alter_role.sgml @@ -1,5 +1,5 @@ @@ -37,7 +37,9 @@ where option can be: ALTER ROLE name RENAME TO newname ALTER ROLE name SET configuration_parameter { TO | = } { value | DEFAULT } +ALTER ROLE name SET configuration_parameter FROM CURRENT ALTER ROLE name RESET configuration_parameter +ALTER ROLE name RESET ALL @@ -77,7 +79,7 @@ ALTER ROLE name RESET - The third and the fourth variant change a role's session default for + The remaining variants change a role's session default for a specified configuration variable. Whenever the role subsequently starts a new session, the specified value becomes the session default, overriding whatever setting is present in postgresql.conf @@ -155,6 +157,8 @@ ALTER ROLE name RESET role-specific variable setting is removed, so the role will inherit the system-wide default setting in new sessions. Use RESET ALL to clear all role-specific settings. + SET FROM CURRENT saves the session's current value of + the parameter as the role-specific value. diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml index 8f41a35e7aa..f989651d6fe 100644 --- a/doc/src/sgml/ref/alter_user.sgml +++ b/doc/src/sgml/ref/alter_user.sgml @@ -1,5 +1,5 @@ @@ -37,7 +37,9 @@ where option can be: ALTER USER name RENAME TO newname ALTER USER name SET configuration_parameter { TO | = } { value | DEFAULT } +ALTER USER name SET configuration_parameter FROM CURRENT ALTER USER name RESET configuration_parameter +ALTER USER name RESET ALL diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index 7aff876d37d..b0cfe84db1c 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -1,5 +1,5 @@ @@ -28,7 +28,7 @@ CREATE [ OR REPLACE ] FUNCTION | [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER | COST execution_cost | ROWS result_rows - | SET parameter { TO | = } { value | DEFAULT } + | SET configuration_parameter { TO value | = value | FROM CURRENT } | AS 'definition' | AS 'obj_file', 'link_symbol' } ... @@ -324,13 +324,15 @@ CREATE [ OR REPLACE ] FUNCTION - parameter + configuration_parameter value The SET clause causes the specified configuration parameter to be set to the specified value when the function is entered, and then restored to its prior value when the function exits. + SET FROM CURRENT saves the session's current value of + the parameter as the value to be applied when the function is entered. -- cgit v1.2.3