Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AFC221069F for ; Mon, 8 Jul 2013 19:58:21 +0000 (UTC) Received: (qmail 56748 invoked by uid 500); 8 Jul 2013 19:58:21 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 56729 invoked by uid 500); 8 Jul 2013 19:58:21 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 56721 invoked by uid 99); 8 Jul 2013 19:58:21 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jul 2013 19:58:21 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4F9358885C0; Mon, 8 Jul 2013 19:58:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aleksey@apache.org To: commits@cassandra.apache.org Message-Id: <9db0332e4c7b4e059edf39bc5d9ede96@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: cqlsh: fix handling of semicolons inside BATCH queries Date: Mon, 8 Jul 2013 19:58:21 +0000 (UTC) Updated Branches: refs/heads/cassandra-1.2 909b2ed1a -> c1d71213b cqlsh: fix handling of semicolons inside BATCH queries patch by Aleksey Yeschenko; reviewed by Brandon Williams for CASSANDRA-5697 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c1d71213 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c1d71213 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c1d71213 Branch: refs/heads/cassandra-1.2 Commit: c1d71213bdb6f5d326f5cc5a55e645a8edf2e589 Parents: 909b2ed Author: Aleksey Yeschenko Authored: Mon Jul 8 22:57:35 2013 +0300 Committer: Aleksey Yeschenko Committed: Mon Jul 8 22:57:35 2013 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + pylib/cqlshlib/cql3handling.py | 4 ++-- pylib/cqlshlib/cqlhandling.py | 10 ++++------ 3 files changed, 7 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1d71213/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 7c16cd0..65dd404 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,7 @@ * Fix skipping range tombstones with reverse queries (CASSANDRA-5712) * Expire entries out of ThriftSessionManager (CASSANRDA-5719) * Don't keep ancestor information in memory (CASSANDRA-5342) + * cqlsh: fix handling of semicolons inside BATCH queries (CASSANDRA-5697) 1.2.6 http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1d71213/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 0e631ea..92701d6 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -986,8 +986,8 @@ syntax_rules += r''' ::= "BEGIN" ( "UNLOGGED" | "COUNTER" )? "BATCH" ( "USING" [batchopt]= ( "AND" [batchopt]= )* )? - [batchstmt]= ";" - ( [batchstmt]= ";" )* + [batchstmt]= ";"? + ( [batchstmt]= ";"? )* "APPLY" "BATCH" ; ::= http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1d71213/pylib/cqlshlib/cqlhandling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cqlhandling.py b/pylib/cqlshlib/cqlhandling.py index 83e1dc2..7d36301 100644 --- a/pylib/cqlshlib/cqlhandling.py +++ b/pylib/cqlshlib/cqlhandling.py @@ -189,13 +189,11 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet): output[-1].extend(stmt) else: output.append(stmt) - if len(stmt) > 1 \ - and stmt[0][0] == 'identifier' and stmt[1][0] == 'identifier' \ - and stmt[1][1].lower() == 'batch': - if stmt[0][1].lower() == 'begin': - in_batch = True - elif stmt[0][1].lower() == 'apply': + if len(stmt) > 2: + if stmt[-3][0] == 'K_APPLY': in_batch = False + elif stmt[0][0] == 'K_BEGIN': + in_batch = True return output, in_batch def cql_complete_single(self, text, partial, init_bindings={}, ignore_case=True,