From 13d3a47461af24fbd4b2ddee71a7042168ed860f Mon Sep 17 00:00:00 2001 From: Mikhail Stepura Date: Wed, 16 Apr 2014 21:10:18 -0700 Subject: [PATCH] cqlsh: Updated CQL3 parser to support functions and BLOB literals patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for CASSANDRA-7018 --- CHANGES.txt | 1 + bin/cqlsh | 2 +- pylib/cqlshlib/cql3handling.py | 24 ++++++++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index bb08a3798785..bf80e1e240d2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/bin/cqlsh b/bin/cqlsh index 4bf1b7678fec..8e1e0e20b1fb 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -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' diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 50e201502c7a..b04ba1d2d31f 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -206,6 +206,7 @@ def dequote_any(cls, t): ::= /'([^']|'')*'/ ; ::= /"([^"]|"")*"/ ; ::= /-?[0-9]+\.[0-9]+/ ; + ::= /0x[0-9a-f]+/ ; ::= /[0-9]+/ ; ::= /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ ; ::= /[a-z][a-z0-9_]*/ ; @@ -230,10 +231,15 @@ def dequote_any(cls, t): | | | + | + | ; + ::= "(" ( ( "," )* )? ")" + ; + ::= token="TOKEN" "(" ( "," )* ")" - | + | ; ::= | @@ -255,6 +261,9 @@ def dequote_any(cls, t): ::= "{" ":" ( "," ":" )* "}" ; + ::= + ; + ::= | | @@ -739,13 +748,13 @@ def working_on_keyspace(ctxt): ; ::= "SELECT" "FROM" cf= - ("WHERE" )? - ("ORDER" "BY" ( "," )* )? - ("LIMIT" limit=)? + ( "WHERE" )? + ( "ORDER" "BY" ( "," )* )? + ( "LIMIT" limit= )? ; - ::= ("AND" )* + ::= ( "AND" )* ; - ::= [rel_lhs]= ("=" | "<" | ">" | "<=" | ">=") + ::= [rel_lhs]= ( "=" | "<" | ">" | "<=" | ">=" ) | token="TOKEN" "(" [rel_tokname]= ( "," [rel_tokname]= )* ")" ("=" | "<" | ">" | "<=" | ">=") @@ -758,7 +767,10 @@ def working_on_keyspace(ctxt): ::= [colname]= | "WRITETIME" "(" [colname]= ")" | "TTL" "(" [colname]= ")" + | ; + ::= "(" ( ( "," )* )? ")" + ; ::= [ordercol]= ( "ASC" | "DESC" )? ; '''