From 67c0cfa4de4d4338776ffa8a28bddd2cb81a0111 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Thu, 5 Jul 2018 10:44:02 +0200 Subject: [PATCH] sql/parser: unreserve VIEW VIEW does not need to be a reserved keyword. In fact, it sounds innocuous enough for users to want to use it as a column name. So make it an unreserved keyword. Release note (sql change): CockroachDB now allows clients to use the word `view` as identifier like in PostgreSQL. --- docs/generated/sql/bnf/stmt_block.bnf | 2 +- pkg/sql/parser/parse_test.go | 1 + pkg/sql/parser/sql.y | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index b331bbdbf5c5..36b11d50bef8 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -840,6 +840,7 @@ unreserved_keyword ::= | 'VALIDATE' | 'VALUE' | 'VARYING' + | 'VIEW' | 'WITHIN' | 'WITHOUT' | 'WRITE' @@ -1551,7 +1552,6 @@ reserved_keyword ::= | 'USER' | 'USING' | 'VARIADIC' - | 'VIEW' | 'WHEN' | 'WHERE' | 'WINDOW' diff --git a/pkg/sql/parser/parse_test.go b/pkg/sql/parser/parse_test.go index 197ce6d03c87..4be657b18160 100644 --- a/pkg/sql/parser/parse_test.go +++ b/pkg/sql/parser/parse_test.go @@ -184,6 +184,7 @@ func TestParse(t *testing.T) { {`CREATE TABLE a.b (b INT)`}, {`CREATE TABLE IF NOT EXISTS a (b INT)`}, {`CREATE TABLE a (b INT AS (a + b) STORED)`}, + {`CREATE TABLE view (view INT)`}, {`CREATE TABLE a (b INT) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4)))`}, {`CREATE TABLE a (b INT) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (MINVALUE) TO (1), PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE))`}, diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 4e3f9e432c76..2deb0718c99e 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -8262,6 +8262,7 @@ unreserved_keyword: | VALIDATE | VALUE | VARYING +| VIEW | WITHIN | WITHOUT | WRITE @@ -8436,7 +8437,6 @@ reserved_keyword: | USER | USING | VARIADIC -| VIEW | WHEN | WHERE | WINDOW