From fa2fa602d989ed911b60247e3dd8f2d580188782 Mon Sep 17 00:00:00 2001 From: Benjamin Lerer Date: Wed, 27 Jan 2016 17:21:22 +0100 Subject: [PATCH 1/2] Fix paging on DISTINCT queries repeats result when first row in partition changes patch by Benjamin Lerer; reviewed by Sylvain Lebresne for CASSANDRA-10010 --- CHANGES.txt | 2 ++ .../cassandra/service/pager/RangeSliceQueryPager.java | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index cdc3b34bba..98473719f6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,5 @@ +2.2.6 + * Fix paging on DISTINCT queries repeats result when first row in partition changes (CASSANDRA-10010) 2.2.5 * maxPurgeableTimestamp needs to check memtables too (CASSANDRA-9949) * Apply change to compaction throughput in real time (CASSANDRA-10025) diff --git a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java index 10e470b788..8ec9f4c584 100644 --- a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java +++ b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java @@ -97,6 +97,10 @@ public class RangeSliceQueryPager extends AbstractQueryPager if (lastReturnedKey == null || !lastReturnedKey.equals(first.key)) return false; + // If the query is a DISTINCT one we can stop there + if (isDistinct()) + return true; + // Same as SliceQueryPager, we ignore a deleted column Cell firstCell = isReversed() ? lastCell(first.cf) : firstNonStaticCell(first.cf); // If the row was containing only static columns it has already been returned and we can skip it. @@ -109,6 +113,12 @@ public class RangeSliceQueryPager extends AbstractQueryPager && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturnedName); } + private boolean isDistinct() + { + // As this pager is never used for Thrift queries, checking the countCQL3Rows is enough. + return !command.countCQL3Rows; + } + protected boolean recordLast(Row last) { lastReturnedKey = last.key; From 414c1c5771ca05c23c8c1279dbdb90a673dda040 Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Fri, 22 Jan 2016 15:49:11 -0600 Subject: [PATCH 2/2] cqlsh: Fix INSERT and UPDATE LWT handling Patch by Eduard Tudenhoefner; reviewed by Tyler Hobbs for CASSANDRA-11003 --- CHANGES.txt | 2 ++ bin/cqlsh.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8daeb2dd76..1a1abc03cc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 3.0.3 + * (cqlsh) handle INSERT and UPDATE statements with LWT conditions correctly + (CASSANDRA-11003) * Fix DISTINCT queries in mixed version clusters (CASSANDRA-10762) * Migrate build status for indexes along with legacy schema (CASSANDRA-11046) * Ensure SSTables for legacy KEYS indexes can be read (CASSANDRA-11045) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 5d7d9e70fb..74e7103c8d 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -1269,7 +1269,7 @@ class Shell(cmd.Cmd): elif result: # CAS INSERT/UPDATE self.writeresult("") - self.print_static_result(result.column_names, list(result), self.parse_for_table_meta(statement.query_string)) + self.print_static_result(result.column_names, list(result), self.parse_for_update_meta(statement.query_string)) self.flush_output() return True, future