cqlsh: use python driver for CQL keyword list

Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for
CASSANDRA-9232
This commit is contained in:
Stefania Alborghetti 2015-08-25 09:54:16 -05:00 committed by Tyler Hobbs
parent 7d74563a25
commit 386f197da3
3 changed files with 13 additions and 39 deletions

View File

@ -1,4 +1,5 @@
2.1.9
* (cqlsh) update list of CQL keywords (CASSANDRA-9232)
* Avoid race condition during read repair (CASSANDRA-9460)
* (cqlsh) default load-from-file encoding to utf-8 (CASSANDRA-9898)
* Avoid returning Permission.NONE when failing to query users table (CASSANDRA-10168)

View File

@ -37,19 +37,6 @@ SYSTEM_KEYSPACES = ('system', 'system_traces', 'system_auth')
NONALTERBALE_KEYSPACES = ('system')
class Cql3ParsingRuleSet(CqlParsingRuleSet):
keywords = set((
'select', 'from', 'where', 'and', 'key', 'insert', 'update', 'with',
'limit', 'using', 'use', 'count', 'set',
'begin', 'apply', 'batch', 'truncate', 'delete', 'in', 'create',
'keyspace', 'schema', 'columnfamily', 'table', 'index', 'on', 'drop',
'primary', 'into', 'values', 'timestamp', 'ttl', 'alter', 'add', 'type',
'compact', 'storage', 'order', 'by', 'asc', 'desc', 'clustering',
'token', 'writetime', 'map', 'list', 'to', 'custom', 'if', 'not'
))
unreserved_keywords = set((
'key', 'clustering', 'ttl', 'compact', 'storage', 'type', 'values', 'custom', 'exists'
))
columnfamily_layout_options = (
('bloom_filter_fp_chance', None),
@ -89,10 +76,6 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
'SERIAL'
)
maybe_escape_name = staticmethod(maybe_escape_name)
escape_name = staticmethod(escape_name)
@classmethod
def escape_value(cls, value):
if value is None:
@ -132,8 +115,6 @@ explain_completion = CqlRuleSet.explain_completion
dequote_value = CqlRuleSet.dequote_value
dequote_name = CqlRuleSet.dequote_name
escape_value = CqlRuleSet.escape_value
maybe_escape_name = CqlRuleSet.maybe_escape_name
# BEGIN SYNTAX/COMPLETION RULE DEFINITIONS
@ -251,7 +232,7 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
;
# timestamp is included here, since it's also a keyword
<simpleStorageType> ::= typename=( <identifier> | <stringLiteral> | <K_TIMESTAMP> ) ;
<simpleStorageType> ::= typename=( <identifier> | <stringLiteral> | "timestamp" ) ;
<userType> ::= utname=<cfOrKsName> ;
@ -284,14 +265,14 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
| <unreservedKeyword>;
<unreservedKeyword> ::= nocomplete=
( <K_KEY>
| <K_CLUSTERING>
# | <K_COUNT> -- to get count(*) completion, treat count as reserved
| <K_TTL>
| <K_COMPACT>
| <K_STORAGE>
| <K_TYPE>
| <K_VALUES> )
( "key"
| "clustering"
# | "count" -- to get count(*) completion, treat count as reserved
| "ttl"
| "compact"
| "storage"
| "type"
| "values" )
;
<property> ::= [propname]=<cident> propeq="=" [propval]=<propertyValue>
@ -1172,7 +1153,7 @@ def username_name_completer(ctxt, cass):
return "'%s'" % name
# disable completion for CREATE USER.
if ctxt.matched[0][0] == 'K_CREATE':
if ctxt.matched[0][0] == 'create':
return [Hint('<username>')]
session = cass.session

View File

@ -24,7 +24,6 @@ Hint = pylexotron.Hint
class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
keywords = set()
available_compression_classes = (
'DeflateCompressor',
@ -56,7 +55,6 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
# note: commands_end_with_newline may be extended by callers.
self.commands_end_with_newline = set()
self.set_keywords_as_syntax()
def completer_for(self, rulename, symname):
def registrator(f):
@ -80,12 +78,6 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
return explainer
def set_keywords_as_syntax(self):
syntax = []
for k in self.keywords:
syntax.append('<K_%s> ::= "%s" ;' % (k.upper(), k))
self.append_rules('\n'.join(syntax))
def cql_massage_tokens(self, toklist):
curstmt = []
output = []
@ -146,9 +138,9 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
else:
output.append(stmt)
if len(stmt) > 2:
if stmt[-3][0] == 'K_APPLY':
if stmt[-3][0] == 'apply':
in_batch = False
elif stmt[0][0] == 'K_BEGIN':
elif stmt[0][0] == 'begin':
in_batch = True
return output, in_batch