From 6eaa6362453acc36fe07838009732846592e5e0d Mon Sep 17 00:00:00 2001 From: Oliver Tan Date: Thu, 12 Aug 2021 11:24:31 +1000 Subject: [PATCH 1/2] parser: accept SET ROLE without equal sign Release note (sql change): `SET ROLE user` now parses without an equal between `ROLE` and `=`. This functionality is not yet implemented. --- pkg/sql/logictest/testdata/logic_test/user | 8 ++++++++ pkg/sql/parser/sql.y | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/pkg/sql/logictest/testdata/logic_test/user b/pkg/sql/logictest/testdata/logic_test/user index 0351355f0128..cd334cc7d34a 100644 --- a/pkg/sql/logictest/testdata/logic_test/user +++ b/pkg/sql/logictest/testdata/logic_test/user @@ -184,3 +184,11 @@ 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 diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 07b3dbbad6d8..3d98b8e7dc3e 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -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: From bd4eaa6cf519d8cfcfcdbb78adb585507bb51ba7 Mon Sep 17 00:00:00 2001 From: Oliver Tan Date: Thu, 12 Aug 2021 11:31:34 +1000 Subject: [PATCH 2/2] parser: parse RESET ROLE Release note (sql change): Allow `RESET ROLE` to be parsed. This is not yet implemented. --- docs/generated/sql/bnf/stmt_block.bnf | 1 + pkg/sql/logictest/testdata/logic_test/user | 3 +++ pkg/sql/parser/sql.y | 1 + 3 files changed, 5 insertions(+) diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index db0d1896fed7..d4f531e7dde6 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -1515,6 +1515,7 @@ session_var ::= | 'ALL' | 'DATABASE' | 'NAMES' + | 'ROLE' | 'SESSION_USER' | 'TIME' 'ZONE' diff --git a/pkg/sql/logictest/testdata/logic_test/user b/pkg/sql/logictest/testdata/logic_test/user index cd334cc7d34a..fa0cad8f5258 100644 --- a/pkg/sql/logictest/testdata/logic_test/user +++ b/pkg/sql/logictest/testdata/logic_test/user @@ -192,3 +192,6 @@ SET ROLE = 'testuser' statement error unimplemented SET ROLE testuser + +statement error unimplemented +RESET ROLE diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 3d98b8e7dc3e..d41803092a21 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -4879,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" }