Skip to content

Commit

Permalink
cqlsh: Updated CQL3 parser to support functions and BLOB literals
Browse files Browse the repository at this point in the history
patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for CASSANDRA-7018
  • Loading branch information
Mishail committed Apr 19, 2014
1 parent 8709706 commit 13d3a47
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -6,6 +6,7 @@
* Non-droppable verbs shouldn't be dropped from OTC (CASSANDRA-6980)
* Shutdown batchlog executor in SS#drain() (CASSANDRA-7025)
* Fix batchlog to account for CF truncation records (CASSANDRA-6999)
* Fix CQLSH parsing of functions and BLOB literals (CASSANDRA-7018)


1.2.16
Expand Down
2 changes: 1 addition & 1 deletion bin/cqlsh
Expand Up @@ -133,7 +133,7 @@ if os.path.exists(OLD_HISTORY):

DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 9160
DEFAULT_CQLVER = '3'
DEFAULT_CQLVER = '3.0.5'
DEFAULT_TRANSPORT_FACTORY = 'cqlshlib.tfactory.regular_transport_factory'

DEFAULT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S%z'
Expand Down
24 changes: 18 additions & 6 deletions pylib/cqlshlib/cql3handling.py
Expand Up @@ -206,6 +206,7 @@ def dequote_any(cls, t):
<stringLiteral> ::= /'([^']|'')*'/ ;
<quotedName> ::= /"([^"]|"")*"/ ;
<float> ::= /-?[0-9]+\.[0-9]+/ ;
<blobLiteral> ::= /0x[0-9a-f]+/ ;
<wholenumber> ::= /[0-9]+/ ;
<uuid> ::= /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ ;
<identifier> ::= /[a-z][a-z0-9_]*/ ;
Expand All @@ -230,10 +231,15 @@ def dequote_any(cls, t):
| <float>
| <uuid>
| <boolean>
| <blobLiteral>
| <functionName> <functionArguments>
;
<functionArguments> ::= "(" ( <term> ( "," <term> )* )? ")"
;
<tokenDefinition> ::= token="TOKEN" "(" <term> ( "," <term> )* ")"
| <stringLiteral>
| <term>
;
<value> ::= <term>
| <collectionLiteral>
Expand All @@ -255,6 +261,9 @@ def dequote_any(cls, t):
<mapLiteral> ::= "{" <term> ":" <term> ( "," <term> ":" <term> )* "}"
;
<functionName> ::= <identifier>
;
<statementBody> ::= <useStatement>
| <selectStatement>
| <dataChangeStatement>
Expand Down Expand Up @@ -739,13 +748,13 @@ def working_on_keyspace(ctxt):
;
<selectStatement> ::= "SELECT" <selectClause>
"FROM" cf=<columnFamilyName>
("WHERE" <whereClause>)?
("ORDER" "BY" <orderByClause> ( "," <orderByClause> )* )?
("LIMIT" limit=<wholenumber>)?
( "WHERE" <whereClause> )?
( "ORDER" "BY" <orderByClause> ( "," <orderByClause> )* )?
( "LIMIT" limit=<wholenumber> )?
;
<whereClause> ::= <relation> ("AND" <relation>)*
<whereClause> ::= <relation> ( "AND" <relation> )*
;
<relation> ::= [rel_lhs]=<cident> ("=" | "<" | ">" | "<=" | ">=") <term>
<relation> ::= [rel_lhs]=<cident> ( "=" | "<" | ">" | "<=" | ">=" ) <term>
| token="TOKEN" "(" [rel_tokname]=<cident>
( "," [rel_tokname]=<cident> )*
")" ("=" | "<" | ">" | "<=" | ">=") <tokenDefinition>
Expand All @@ -758,7 +767,10 @@ def working_on_keyspace(ctxt):
<selector> ::= [colname]=<cident>
| "WRITETIME" "(" [colname]=<cident> ")"
| "TTL" "(" [colname]=<cident> ")"
| <functionName> <selectionFunctionArguments>
;
<selectionFunctionArguments> ::= "(" ( <selector> ( "," <selector> )* )? ")"
;
<orderByClause> ::= [ordercol]=<cident> ( "ASC" | "DESC" )?
;
'''
Expand Down

0 comments on commit 13d3a47

Please sign in to comment.