You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sn...@apache.org on 2016/02/17 13:44:36 UTC

[2/6] cassandra git commit: cqlsh pg-style-strings broken if line ends with '; '

cqlsh pg-style-strings broken if line ends with ';'

patch by Robert Stupp; reviewed by Stefania for CASSANDRA-11123


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/97f3aa68
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/97f3aa68
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/97f3aa68

Branch: refs/heads/cassandra-3.0
Commit: 97f3aa681d83a46b83593f79a7c2d15fb89be3c2
Parents: f7c7585
Author: Robert Stupp <sn...@snazy.de>
Authored: Wed Feb 17 13:42:02 2016 +0100
Committer: Robert Stupp <sn...@snazy.de>
Committed: Wed Feb 17 13:42:02 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                        | 1 +
 bin/cqlsh.py                       | 4 ++--
 pylib/cqlshlib/cqlhandling.py      | 3 ++-
 pylib/cqlshlib/test/cassconnect.py | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/97f3aa68/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5c912a1..288f204 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.6
+ * cqlsh pg-style-strings broken if line ends with ';' (CASSANDRA-11123)
  * Use cloned TokenMetadata in size estimates to avoid race against membership check
    (CASSANDRA-10736)
  * Always persist upsampled index summaries (CASSANDRA-10512)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/97f3aa68/bin/cqlsh.py
----------------------------------------------------------------------
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index 630c92b..08cc6f4 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -1108,7 +1108,7 @@ class Shell(cmd.Cmd):
         """
 
         try:
-            statements, in_batch = cqlruleset.cql_split_statements(statementtext)
+            statements, endtoken_escaped = cqlruleset.cql_split_statements(statementtext)
         except pylexotron.LexingError, e:
             if self.show_line_nums:
                 self.printerr('Invalid syntax at char %d' % (e.charnum,))
@@ -1124,7 +1124,7 @@ class Shell(cmd.Cmd):
             statements = statements[:-1]
         if not statements:
             return True
-        if in_batch or statements[-1][-1][0] != 'endtoken':
+        if endtoken_escaped or statements[-1][-1][0] != 'endtoken':
             self.set_continue_prompt()
             return
         for st in statements:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/97f3aa68/pylib/cqlshlib/cqlhandling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cqlhandling.py b/pylib/cqlshlib/cqlhandling.py
index c17dc6b..a8a0ba8 100644
--- a/pylib/cqlshlib/cqlhandling.py
+++ b/pylib/cqlshlib/cqlhandling.py
@@ -142,6 +142,7 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
         stmts = util.split_list(tokens, lambda t: t[0] == 'endtoken')
         output = []
         in_batch = False
+        in_pg_string = len([st for st in tokens if len(st) > 0 and st[0] == 'unclosedPgString']) == 1
         for stmt in stmts:
             if in_batch:
                 output[-1].extend(stmt)
@@ -152,7 +153,7 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
                     in_batch = False
                 elif stmt[0][1].upper() == 'BEGIN':
                     in_batch = True
-        return output, in_batch
+        return output, in_batch or in_pg_string
 
     def cql_complete_single(self, text, partial, init_bindings={}, ignore_case=True,
                             startsymbol='Start'):

http://git-wip-us.apache.org/repos/asf/cassandra/blob/97f3aa68/pylib/cqlshlib/test/cassconnect.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/test/cassconnect.py b/pylib/cqlshlib/test/cassconnect.py
index a93647a..94910a6 100644
--- a/pylib/cqlshlib/test/cassconnect.py
+++ b/pylib/cqlshlib/test/cassconnect.py
@@ -57,8 +57,8 @@ def create_test_keyspace(cursor):
 
 def split_cql_commands(source):
     ruleset = cql_rule_set()
-    statements, in_batch = ruleset.cql_split_statements(source)
-    if in_batch:
+    statements, endtoken_escaped = ruleset.cql_split_statements(source)
+    if endtoken_escaped:
         raise ValueError("CQL source ends unexpectedly")
 
     return [ruleset.cql_extract_orig(toks, source) for toks in statements if toks]