CQL3: make some keywords unreserved patch by slebresne; reviewed by xedin for CASSANDRA-4186
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/13f3ba83 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/13f3ba83 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/13f3ba83 Branch: refs/heads/trunk Commit: 13f3ba838193d8ec7dc6ae0732c905951cb7f13e Parents: a75b708 Author: Sylvain Lebresne <[email protected]> Authored: Wed Apr 25 16:08:39 2012 +0200 Committer: Sylvain Lebresne <[email protected]> Committed: Thu May 3 10:56:44 2012 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/cql3/Cql.g | 61 +++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/13f3ba83/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index a655645..8097485 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -28,6 +28,7 @@ * (cql3) Add timeuuid type (CASSANDRA-4194) * (cql3) Minor fixes (CASSANDRA-4185) * (cql3) Fix prepared statement in BATCH (CASSANDRA-4202) + * (cql3) Reduce the list of reserved keywords (CASSANDRA-4186) Merged from 1.0: * Fix super columns bug where cache is not updated (CASSANDRA-4190) * fix maxTimestamp to include row tombstones (CASSANDRA-4116) http://git-wip-us.apache.org/repos/asf/cassandra/blob/13f3ba83/src/java/org/apache/cassandra/cql3/Cql.g ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g index 3220c1a..8d15a5b 100644 --- a/src/java/org/apache/cassandra/cql3/Cql.g +++ b/src/java/org/apache/cassandra/cql3/Cql.g @@ -433,8 +433,9 @@ truncateStatement returns [TruncateStatement stmt] // Column Identifiers cident returns [ColumnIdentifier id] - : t=IDENT { $id = new ColumnIdentifier($t.text, false); } - | t=QUOTED_NAME { $id = new ColumnIdentifier($t.text, true); } + : t=IDENT { $id = new ColumnIdentifier($t.text, false); } + | t=QUOTED_NAME { $id = new ColumnIdentifier($t.text, true); } + | k=unreserved_keyword { $id = new ColumnIdentifier(k, true); } ; // Keyspace & Column family names @@ -449,8 +450,9 @@ columnFamilyName returns [CFName name] ; cfOrKsName[CFName name, boolean isKs] - : t=IDENT { if (isKs) $name.setKeyspace($t.text, false); else $name.setColumnFamily($t.text, false); } - | t=QUOTED_NAME { if (isKs) $name.setKeyspace($t.text, true); else $name.setColumnFamily($t.text, true); } + : t=IDENT { if (isKs) $name.setKeyspace($t.text, false); else $name.setColumnFamily($t.text, false); } + | t=QUOTED_NAME { if (isKs) $name.setKeyspace($t.text, true); else $name.setColumnFamily($t.text, true); } + | k=unreserved_keyword { if (isKs) $name.setKeyspace(k, false); else $name.setColumnFamily(k, false); } ; cidentList returns [List<ColumnIdentifier> items] @@ -504,7 +506,41 @@ relation returns [Relation rel] ; comparatorType returns [String str] - : c=(IDENT | STRING_LITERAL | K_TIMESTAMP) { $str = $c.text; } + : c=native_type { $str=c; } + | s=STRING_LITERAL { $str = $s.text; } + ; + +native_type returns [String str] + : c=( K_ASCII + | K_BIGINT + | K_BLOB + | K_BOOLEAN + | K_COUNTER + | K_DECIMAL + | K_DOUBLE + | K_FLOAT + | K_INT + | K_TEXT + | K_TIMESTAMP + | K_UUID + | K_VARCHAR + | K_VARINT + | K_TIMEUUID + ) { return $c.text; } + ; + +unreserved_keyword returns [String str] + : k=( K_KEY + | K_CONSISTENCY + | K_LEVEL + | K_COUNT + | K_TTL + | K_COMPACT + | K_STORAGE + | K_TYPE + | K_VALUES + ) { $str = $k.text; } + | t=native_type { $str = t; } ; @@ -563,6 +599,21 @@ K_ASC: A S C; K_DESC: D E S C; K_CLUSTERING: C L U S T E R I N G; +K_ASCII: A S C I I; +K_BIGINT: B I G I N T; +K_BLOB: B L O B; +K_BOOLEAN: B O O L E A N; +K_COUNTER: C O U N T E R; +K_DECIMAL: D E C I M A L; +K_DOUBLE: D O U B L E; +K_FLOAT: F L O A T; +K_INT: I N T; +K_TEXT: T E X T; +K_UUID: U U I D; +K_VARCHAR: V A R C H A R; +K_VARINT: V A R I N T; +K_TIMEUUID: T I M E U U I D; + // Case-insensitive alpha characters fragment A: ('a'|'A'); fragment B: ('b'|'B');
