cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [3/3] git commit: Fix validation for IN queries with non-PK cols
Date Wed, 26 Sep 2012 15:05:37 GMT
Fix validation for IN queries with non-PK cols

patch by slebresne; reviewed by jbellis for CASSANDRA-4709


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

Branch: refs/heads/trunk
Commit: ee4a26d8659f4ab09d2646de0b68d39db958bdb9
Parents: 05a5ede
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Sep 26 14:12:20 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Sep 26 14:13:14 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cassandra/cql3/statements/SelectStatement.java |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee4a26d8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index cea2605..96e266a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,7 @@
  * Adds offline sstablescrub to debian packaging (CASSANDRA-4642)
  * Automatic fixing of overlapping leveled sstables (CASSANDRA-4644)
  * fix error when using ORDER BY with extended selections (CASSANDRA-4689)
+ * (CQL3) Fix validation for IN queries for non-PK cols (CASSANDRA-4709)
 Merged from 1.0:
  * Switch from NBHM to CHM in MessagingService's callback map, which
    prevents OOM in long-running instances (CASSANDRA-4708)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee4a26d8/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 4a013b1..bbddee3 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1063,7 +1063,15 @@ public class SelectStatement implements CQLStatement
 
                 for (Map.Entry<CFDefinition.Name, Restriction> entry : stmt.metadataRestrictions.entrySet())
                 {
-                    if (entry.getValue().isEquality() && indexed.contains(entry.getKey().name.key))
+                    Restriction restriction = entry.getValue();
+                    if (!restriction.isEquality())
+                        continue;
+
+                    // We don't support IN for indexed values (basically this would require
supporting a form of OR)
+                    if (restriction.eqValues.size() > 1)
+                        throw new InvalidRequestException("Cannot use IN operator on column
not part of the PRIMARY KEY");
+
+                    if (indexed.contains(entry.getKey().name.key))
                     {
                         hasEq = true;
                         break;


Mime
View raw message