diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml new file mode 100644 index 58ae1da..ac05682 *** a/doc/src/sgml/ref/alter_user.sgml --- b/doc/src/sgml/ref/alter_user.sgml *************** ALTER USER name RENAME TO new_name ! 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 --- 38,47 ---- ALTER USER name RENAME TO new_name ! ALTER USER name [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT } ! ALTER USER { name | ALL } [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT ! ALTER USER { name | ALL } [ IN DATABASE database_name ] RESET configuration_parameter ! ALTER USER { name | ALL } [ IN DATABASE database_name ] RESET ALL diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y new file mode 100644 index 0de9584..d7c0586 *** a/src/backend/parser/gram.y --- b/src/backend/parser/gram.y *************** static Node *makeRecursiveViewSelect(cha *** 230,236 **** AlterFdwStmt AlterForeignServerStmt AlterGroupStmt AlterObjectSchemaStmt AlterOwnerStmt AlterSeqStmt AlterSystemStmt AlterTableStmt AlterTblSpcStmt AlterExtensionStmt AlterExtensionContentsStmt AlterForeignTableStmt ! AlterCompositeTypeStmt AlterUserStmt AlterUserMappingStmt AlterUserSetStmt AlterRoleStmt AlterRoleSetStmt AlterPolicyStmt AlterDefaultPrivilegesStmt DefACLAction AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt --- 230,236 ---- AlterFdwStmt AlterForeignServerStmt AlterGroupStmt AlterObjectSchemaStmt AlterOwnerStmt AlterSeqStmt AlterSystemStmt AlterTableStmt AlterTblSpcStmt AlterExtensionStmt AlterExtensionContentsStmt AlterForeignTableStmt ! AlterCompositeTypeStmt AlterUserMappingStmt AlterRoleStmt AlterRoleSetStmt AlterPolicyStmt AlterDefaultPrivilegesStmt DefACLAction AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt *************** static Node *makeRecursiveViewSelect(cha *** 520,525 **** --- 520,527 ---- %type opt_existing_window_name %type opt_if_not_exists + %type role_or_user + /* * Non-keyword token types. These are hard-wired into the "flex" lexer. * They must be listed first so that their numeric codes do not depend on *************** stmt : *** 756,763 **** | AlterTSConfigurationStmt | AlterTSDictionaryStmt | AlterUserMappingStmt - | AlterUserSetStmt - | AlterUserStmt | AnalyzeStmt | CheckPointStmt | ClosePortalStmt --- 758,763 ---- *************** CreateUserStmt: *** 1033,1042 **** * * Alter a postgresql DBMS role * *****************************************************************************/ AlterRoleStmt: ! ALTER ROLE RoleId opt_with AlterOptRoleList { AlterRoleStmt *n = makeNode(AlterRoleStmt); n->role = $3; --- 1033,1044 ---- * * Alter a postgresql DBMS role * + * ALTER USER is accepted interchangeably with ALTER ROLE. + * *****************************************************************************/ AlterRoleStmt: ! ALTER role_or_user RoleId opt_with AlterOptRoleList { AlterRoleStmt *n = makeNode(AlterRoleStmt); n->role = $3; *************** AlterRoleStmt: *** 1046,1058 **** } ; opt_in_database: /* EMPTY */ { $$ = NULL; } | IN_P DATABASE database_name { $$ = $3; } ; AlterRoleSetStmt: ! ALTER ROLE RoleId opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); n->role = $3; --- 1048,1065 ---- } ; + role_or_user: + ROLE {} + | USER {} + ; + opt_in_database: /* EMPTY */ { $$ = NULL; } | IN_P DATABASE database_name { $$ = $3; } ; AlterRoleSetStmt: ! ALTER role_or_user RoleId opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); n->role = $3; *************** AlterRoleSetStmt: *** 1060,1066 **** n->setstmt = $5; $$ = (Node *)n; } ! | ALTER ROLE ALL opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); n->role = NULL; --- 1067,1073 ---- n->setstmt = $5; $$ = (Node *)n; } ! | ALTER role_or_user ALL opt_in_database SetResetClause { AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); n->role = NULL; *************** AlterRoleSetStmt: *** 1073,1108 **** /***************************************************************************** * - * Alter a postgresql DBMS user - * - *****************************************************************************/ - - AlterUserStmt: - ALTER USER RoleId opt_with AlterOptRoleList - { - AlterRoleStmt *n = makeNode(AlterRoleStmt); - n->role = $3; - n->action = +1; /* add, if there are members */ - n->options = $5; - $$ = (Node *)n; - } - ; - - - AlterUserSetStmt: - ALTER USER RoleId SetResetClause - { - AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); - n->role = $3; - n->database = NULL; - n->setstmt = $4; - $$ = (Node *)n; - } - ; - - - /***************************************************************************** - * * Drop a postgresql DBMS role * * XXX Ideally this would have CASCADE/RESTRICT options, but since a role --- 1080,1085 ---- *************** DropUserMappingStmt: DROP USER MAPPING F *** 4493,4501 **** * QUERY : * ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS * ****************************************************************************/ ! AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options { AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt); n->username = $5; --- 4470,4483 ---- * QUERY : * ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS * + * Note: we also accept "ALTER ROLE MAPPING", because distinguishing that + * case in the grammar would require us to distinguish ROLE from USER in all + * other ALTER cases, and we don't want to do that. However, that spelling + * of the command is nonstandard and is not documented. + * ****************************************************************************/ ! AlterUserMappingStmt: ALTER role_or_user MAPPING FOR auth_ident SERVER name alter_generic_options { AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt); n->username = $5; *************** RenameStmt: ALTER AGGREGATE func_name ag *** 7611,7626 **** n->newname = $7; $$ = (Node *)n; } ! | ALTER ROLE RoleId RENAME TO RoleId ! { ! RenameStmt *n = makeNode(RenameStmt); ! n->renameType = OBJECT_ROLE; ! n->subname = $3; ! n->newname = $6; ! n->missing_ok = false; ! $$ = (Node *)n; ! } ! | ALTER USER RoleId RENAME TO RoleId { RenameStmt *n = makeNode(RenameStmt); n->renameType = OBJECT_ROLE; --- 7593,7599 ---- n->newname = $7; $$ = (Node *)n; } ! | ALTER role_or_user RoleId RENAME TO RoleId { RenameStmt *n = makeNode(RenameStmt); n->renameType = OBJECT_ROLE;