Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8D878200C41 for ; Thu, 9 Mar 2017 12:00:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8C338160B64; Thu, 9 Mar 2017 11:00:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D3BEB160B67 for ; Thu, 9 Mar 2017 12:00:56 +0100 (CET) Received: (qmail 95503 invoked by uid 500); 9 Mar 2017 11:00:50 -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 95475 invoked by uid 99); 9 Mar 2017 11:00:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Mar 2017 11:00:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A3332DFF56; Thu, 9 Mar 2017 11:00:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: slebresne@apache.org To: commits@cassandra.apache.org Date: Thu, 09 Mar 2017 11:00:51 -0000 Message-Id: <166df8af23f646489c89d1f1d218abb4@git.apache.org> In-Reply-To: <58d8ec93281f40a7baf2b775413da648@git.apache.org> References: <58d8ec93281f40a7baf2b775413da648@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/6] cassandra git commit: Slice.isEmpty() returns false for some empty slices archived-at: Thu, 09 Mar 2017 11:00:57 -0000 Slice.isEmpty() returns false for some empty slices patch by Sylvain Lebresne; reviewed by Branimir Lambov for CASSANDRA-13305 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/31dec3d5 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/31dec3d5 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/31dec3d5 Branch: refs/heads/cassandra-3.11 Commit: 31dec3d548ae2c76d7c8bf4bffa9d506f670f756 Parents: 60d3292 Author: Sylvain Lebresne Authored: Thu Mar 9 11:58:40 2017 +0100 Committer: Sylvain Lebresne Committed: Thu Mar 9 11:58:40 2017 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/db/Slice.java | 2 +- .../cql3/validation/operations/DeleteTest.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/31dec3d5/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 0979852..1876922 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.13 + * Slice.isEmpty() returns false for some empty slices (CASSANDRA-13305) * Add formatted row output to assertEmpty in CQL Tester (CASSANDRA-13238) Merged from 2.2: * Fix GRANT/REVOKE when keyspace isn't specified (CASSANDRA-13053) http://git-wip-us.apache.org/repos/asf/cassandra/blob/31dec3d5/src/java/org/apache/cassandra/db/Slice.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/Slice.java b/src/java/org/apache/cassandra/db/Slice.java index 7fde45e..3c645dc 100644 --- a/src/java/org/apache/cassandra/db/Slice.java +++ b/src/java/org/apache/cassandra/db/Slice.java @@ -160,7 +160,7 @@ public class Slice public static boolean isEmpty(ClusteringComparator comparator, Slice.Bound start, Slice.Bound end) { assert start.isStart() && end.isEnd(); - return comparator.compare(end, start) < 0; + return comparator.compare(end, start) <= 0; } /** http://git-wip-us.apache.org/repos/asf/cassandra/blob/31dec3d5/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java index 09098ac..9d7d4a3 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java @@ -1292,6 +1292,24 @@ public class DeleteTest extends CQLTester } /** + * Test for CASSANDRA-13305 + */ + @Test + public void testWithEmptyRange() throws Throwable + { + createTable("CREATE TABLE %s (k text, a int, b int, PRIMARY KEY (k, a, b))"); + + // Both of the following should be doing nothing, but before #13305 this inserted broken ranges. We do it twice + // and the follow-up delete mainly as a way to show the bug as the combination of this will trigger an assertion + // in RangeTombstoneList pre-#13305 showing that something wrong happened. + execute("DELETE FROM %s WHERE k = ? AND a >= ? AND a < ?", "a", 1, 1); + execute("DELETE FROM %s WHERE k = ? AND a >= ? AND a < ?", "a", 1, 1); + + execute("DELETE FROM %s WHERE k = ? AND a >= ? AND a < ?", "a", 0, 2); + } + + + /** * Checks if the memtable is empty or not * @return {@code true} if the memtable is empty, {@code false} otherwise. */