From: <ale...@us...> - 2013-12-17 16:24:52
|
Revision: 58948 http://sourceforge.net/p/firebird/code/58948 Author: alexpeshkoff Date: 2013-12-17 16:24:49 +0000 (Tue, 17 Dec 2013) Log Message: ----------- Implemented CORE-3365: Extend syntax for ALTER CURRENT USER Modified Paths: -------------- firebird/trunk/doc/sql.extensions/README.user_management firebird/trunk/src/dsql/DdlNodes.epp firebird/trunk/src/dsql/parse.y Modified: firebird/trunk/doc/sql.extensions/README.user_management =================================================================== --- firebird/trunk/doc/sql.extensions/README.user_management 2013-12-17 15:52:30 UTC (rev 58947) +++ firebird/trunk/doc/sql.extensions/README.user_management 2013-12-17 16:24:49 UTC (rev 58948) @@ -11,6 +11,7 @@ CREATE USER name {PASSWORD 'password'} [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] ALTER USER name SET [PASSWORD 'password'] [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] + ALTER CURRENT USER SET [PASSWORD 'password'] [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] CREATE OR ALTER USER name SET [PASSWORD 'password'] [ options ] [ TAGS ( tag [, tag [, tag ...]] ) ] DROP USER name; @@ -22,10 +23,10 @@ - INACTIVE and each TAG may have one of two forms: -NAME = 'VALUE' + name = 'string value' or: -DROP NAME - where NAME is any valid SQL identifier. + DROP name +where NAME is any valid SQL identifier. Description: @@ -37,7 +38,8 @@ CREATE and DROP clauses are available only for SYSDBA (or other user, granted RDB$ADMIN role in security database). Ordinary user can ALTER his own password, wide names and tags. Attempt to modify -another user will fail. +another user will fail. Also will fail an attempt to make yourself inactive or active. In order to +avoid typing your name each time simplified form ALTER CURRENT USER is present. At least one of PASSWORD, FIRSTNAME, MIDDLENAME, LASTNAME, ACTIVE, INACTIVE or TAGS must be present in ALTER USER statement. Also notice that PASSWORD clause is required when creating new user. @@ -62,6 +64,7 @@ ALTER USER alex SET FIRSTNAME 'Alex' LASTNAME 'Peshkoff'; CREATE OR ALTER USER alex SET PASSWORD 'IdQfA'; DROP USER alex; + ALTER CURRENT USER SET PASSWORD 'SomethingLongEnough'; Working with tags: ALTER USER alex SET TAGS (a='a', b='b'); Modified: firebird/trunk/src/dsql/DdlNodes.epp =================================================================== --- firebird/trunk/src/dsql/DdlNodes.epp 2013-12-17 15:52:30 UTC (rev 58947) +++ firebird/trunk/src/dsql/DdlNodes.epp 2013-12-17 16:24:49 UTC (rev 58948) @@ -9186,6 +9186,17 @@ Auth::DynamicUserData* userData = FB_NEW(*transaction->tra_pool) Auth::DynamicUserData; string text = name.c_str(); + if (text.isEmpty() && mode == USER_MOD) + { + // alter current user + UserId* usr = tdbb->getAttachment()->att_user; + fb_assert(usr); + if (!usr) + { + (Arg::Gds(isc_random) << "Missing user name for ALTER CURRENT USER").raise(); + } + text = usr->usr_user_name; + } text.upper(); userData->op = mode == USER_ADD ? Auth::ADD_OPER : mode == USER_MOD ? Modified: firebird/trunk/src/dsql/parse.y =================================================================== --- firebird/trunk/src/dsql/parse.y 2013-12-17 15:52:30 UTC (rev 58947) +++ firebird/trunk/src/dsql/parse.y 2013-12-17 16:24:49 UTC (rev 58948) @@ -3394,6 +3394,7 @@ | FUNCTION alter_function_clause { $$ = $2; } | ROLE alter_role_clause { $$ = $2; } | USER alter_user_clause { $$ = $2; } + | CURRENT USER alter_cur_user_clause { $$ = $3; } | CHARACTER SET alter_charset_clause { $$ = $3; } | GENERATOR alter_sequence_clause { $$ = $2; } | SEQUENCE alter_sequence_clause { $$ = $2; } @@ -5832,6 +5833,20 @@ } ; +%type <createAlterUserNode> alter_cur_user_clause +alter_cur_user_clause + : SET passwd_opt + { + $$ = newNode<CreateAlterUserNode>(CreateAlterUserNode::USER_MOD, ""); + $$->password = $2; + } + user_fixed_opts(NOTRIAL($3)) + user_var_opts(NOTRIAL($3)) + { + $$ = $3; + } + ; + %type <createAlterUserNode> replace_user_clause replace_user_clause : symbol_user_name SET passwd_opt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |