Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: SET ROLE syntax preparation #68750

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,7 @@ session_var ::=
| 'ALL'
| 'DATABASE'
| 'NAMES'
| 'ROLE'
| 'SESSION_USER'
| 'TIME' 'ZONE'

Expand Down
11 changes: 11 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/user
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,14 @@ ALTER USER userlongpassword WITH PASSWORD '987654321021'

statement ok
DROP USER userlongpassword

subtest set_role

statement error unimplemented
SET ROLE = 'testuser'

statement error unimplemented
SET ROLE testuser

statement error unimplemented
RESET ROLE
6 changes: 6 additions & 0 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -4618,6 +4618,11 @@ set_rest:
/* SKIP DOC */
$$.val = &tree.SetVar{Name: "search_path", Values: tree.Exprs{$2.expr()}}
}
| ROLE var_value
{
/* SKIP DOC */
$$.val = &tree.SetVar{Name: "role", Values: tree.Exprs{$2.expr()}}
}

set_rest_more:
// SET syntaxes supported as a clause of other statements:
Expand Down Expand Up @@ -4874,6 +4879,7 @@ session_var:
// SET NAMES is standard SQL for SET client_encoding.
// See https://www.postgresql.org/docs/9.6/static/multibyte.html#AEN39236
| NAMES { $$ = "client_encoding" }
| ROLE
| SESSION_USER
// TIME ZONE is special: it is two tokens, but is really the identifier "TIME ZONE".
| TIME ZONE { $$ = "timezone" }
Expand Down