Skip to content

Commit

Permalink
sql/parser: unreserve VIEW
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
knz committed Jul 5, 2018
1 parent bfdc5ee commit 67c0cfa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/generated/sql/bnf/stmt_block.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ unreserved_keyword ::=
| 'VALIDATE'
| 'VALUE'
| 'VARYING'
| 'VIEW'
| 'WITHIN'
| 'WITHOUT'
| 'WRITE'
Expand Down Expand Up @@ -1551,7 +1552,6 @@ reserved_keyword ::=
| 'USER'
| 'USING'
| 'VARIADIC'
| 'VIEW'
| 'WHEN'
| 'WHERE'
| 'WINDOW'
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))`},
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -8262,6 +8262,7 @@ unreserved_keyword:
| VALIDATE
| VALUE
| VARYING
| VIEW
| WITHIN
| WITHOUT
| WRITE
Expand Down Expand Up @@ -8436,7 +8437,6 @@ reserved_keyword:
| USER
| USING
| VARIADIC
| VIEW
| WHEN
| WHERE
| WINDOW
Expand Down

0 comments on commit 67c0cfa

Please sign in to comment.