Fix backward compatibility issues on SELECT DISTINCT queries

patch by Sylvain Lebresne; reviewed by Benjamin Lerer for CASSANDRA-11126

This fixes 2 problems:
- Broken logic for deciding if a query involve static columns when
  serializating range slice to old nodes.
- Invalid cellname in paging state when the "row marker" should be sent.


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

Branch: refs/heads/cassandra-3.9
Commit: 5847222d9b2428c201a534876f86a0ec6f6f436f
Parents: 1392893
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Thu Aug 4 15:38:39 2016 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Thu Sep 1 15:49:03 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 src/java/org/apache/cassandra/db/ReadCommand.java            | 2 +-
 src/java/org/apache/cassandra/service/pager/PagingState.java | 7 +++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5847222d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d111d11..e5e2b9c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.9
+ * select_distinct_with_deletions_test failing on non-vnode environments 
(CASSANDRA-11126)
  * Stack Overflow returned to queries while upgrading (CASSANDRA-12527)
  * Fix legacy regex for temporary files from 2.2 (CASSANDRA-12565)
  * Add option to state current gc_grace_seconds to tools/bin/sstablemetadata 
(CASSANDRA-12208)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5847222d/src/java/org/apache/cassandra/db/ReadCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java 
b/src/java/org/apache/cassandra/db/ReadCommand.java
index 36969f8..c1762f1 100644
--- a/src/java/org/apache/cassandra/db/ReadCommand.java
+++ b/src/java/org/apache/cassandra/db/ReadCommand.java
@@ -744,7 +744,7 @@ public abstract class ReadCommand implements ReadQuery
                     
out.writeInt(LegacyReadCommandSerializer.updateLimitForQuery(rangeCommand.limits().count(),
 filter.requestedSlices()));
 
                 int compositesToGroup;
-                boolean selectsStatics = 
!rangeCommand.columnFilter().fetchedColumns().statics.isEmpty() || 
filter.requestedSlices().selects(Clustering.STATIC_CLUSTERING);
+                boolean selectsStatics = 
!rangeCommand.columnFilter().fetchedColumns().statics.isEmpty() && 
filter.requestedSlices().selects(Clustering.STATIC_CLUSTERING);
                 if (limits.kind() == DataLimits.Kind.THRIFT_LIMIT)
                     compositesToGroup = -1;
                 else if (limits.isDistinct() && !selectsStatics)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5847222d/src/java/org/apache/cassandra/service/pager/PagingState.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/pager/PagingState.java 
b/src/java/org/apache/cassandra/service/pager/PagingState.java
index 611523f..30e14c3 100644
--- a/src/java/org/apache/cassandra/service/pager/PagingState.java
+++ b/src/java/org/apache/cassandra/service/pager/PagingState.java
@@ -213,7 +213,10 @@ public class PagingState
                 Iterator<Cell> cells = row.cellsInLegacyOrder(metadata, 
true).iterator();
                 if (!cells.hasNext())
                 {
-                    mark = LegacyLayout.encodeClustering(metadata, 
row.clustering());
+                    // If the last returned row has no cell, this means in 
2.1/2.2 terms that we stopped on the row
+                    // marker. Note that this shouldn't happen if the table is 
COMPACT.
+                    assert !metadata.isCompactTable();
+                    mark = LegacyLayout.encodeCellName(metadata, 
row.clustering(), ByteBufferUtil.EMPTY_BYTE_BUFFER, null);
                 }
                 else
                 {
@@ -258,7 +261,7 @@ public class PagingState
         @Override
         public String toString()
         {
-            return ByteBufferUtil.bytesToHex(mark);
+            return mark == null ? "null" : ByteBufferUtil.bytesToHex(mark);
         }
     }
 }

Reply via email to