diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index a091739d23f0..8d45e20e3a6c 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -3426,6 +3426,7 @@ bare_label_keywords ::= | 'INVOKER' | 'LEAKPROOF' | 'PARALLEL' + | 'QUERY' | 'RETURN' | 'RETURNS' | 'SECURITY' diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index eb3a743c4f76..ba35bdc4a8e4 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -15904,13 +15904,13 @@ unrestricted_name: | reserved_keyword // Keyword category lists. Generally, every keyword present in the Postgres -// grammar should appear in exactly one of these lists. +// grammar should appear in exactly one of these "x_keyword" lists. // // Put a new keyword into the first list that it can go into without causing // shift or reduce conflicts. The earlier lists define "less reserved" // categories of keywords. // -// Note: also add the new keyword to `bare_label` list to not break +// Note: also add the **new** keyword to `bare_label_keywords` list to not break // user queries using column label without `AS`. // "Unreserved" keywords --- available for use as any kind of name. unreserved_keyword: @@ -16374,6 +16374,7 @@ bare_label_keywords: | INVOKER | LEAKPROOF | PARALLEL +| QUERY | RETURN | RETURNS | SECURITY diff --git a/pkg/sql/parser/testdata/select_clauses b/pkg/sql/parser/testdata/select_clauses index 787eea3adf91..33b90402fe53 100644 --- a/pkg/sql/parser/testdata/select_clauses +++ b/pkg/sql/parser/testdata/select_clauses @@ -3051,3 +3051,11 @@ SELECT * FROM ROWS FROM (json_to_record('')) AS t (a INT8, b STRING, c foo) -- n SELECT (*) FROM ROWS FROM ((json_to_record(('')))) AS t (a INT8, b STRING, c foo) -- fully parenthesized SELECT * FROM ROWS FROM (json_to_record('_')) AS t (a INT8, b STRING, c foo) -- literals removed SELECT * FROM ROWS FROM (json_to_record('')) AS _ (_ INT8, _ STRING, _ foo) -- identifiers removed + +parse +SELECT substring('stringstringstring',1,10) QUERY +---- +SELECT substring('stringstringstring', 1, 10) AS query -- normalized! +SELECT (substring(('stringstringstring'), (1), (10))) AS query -- fully parenthesized +SELECT substring('_', _, _) AS query -- literals removed +SELECT substring('stringstringstring', 1, 10) AS _ -- identifiers removed