You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2014/08/25 16:34:51 UTC

git commit: Always reject inequality on the partition key without token()

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 5d4740c58 -> 20150727b


Always reject inequality on the partition key without token()

patch by blerer; reviewed by slebresne for CASSANDRA-7722


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

Branch: refs/heads/cassandra-2.0
Commit: 20150727b49b5c4f2c5b35fd17b908054a5fd2d5
Parents: 5d4740c
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Mon Aug 25 16:34:01 2014 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Mon Aug 25 16:34:01 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                     | 2 ++
 .../org/apache/cassandra/cql3/statements/SelectStatement.java   | 5 +++++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/20150727/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4d5d851..e716cb5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.11:
+ * Always reject inequality on the partition key without token()
+   (CASSANDRA-7722)
  * Always send Paxos commit to all replicas (CASSANDRA-7479)
 
 2.0.10

http://git-wip-us.apache.org/repos/asf/cassandra/blob/20150727/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 8145722..a360d49 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1709,6 +1709,11 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
                         existingRestriction = new SingleColumnRestriction.Slice(newRel.onToken);
                     else if (!existingRestriction.isSlice())
                         throw new InvalidRequestException(String.format("Column \"%s\" cannot be restricted by both an equality and an inequality relation", name));
+                    else if (existingRestriction.isOnToken() != newRel.onToken)
+                        // For partition keys, we shouldn't have slice restrictions without token(). And while this is rejected later by
+                        // processPartitionKeysRestrictions, we shouldn't update the existing restriction by the new one if the old one was using token()
+                        // and the new one isn't since that would bypass that later test.
+                        throw new InvalidRequestException("Only EQ and IN relation are supported on the partition key (unless you use the token() function)");
                     else if (existingRestriction.isMultiColumn())
                         throw new InvalidRequestException(String.format("Column \"%s\" cannot be restricted by both a tuple notation inequality and a single column inequality (%s)", name, newRel));
                     Term t = newRel.getValue().prepare(receiver);