cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix validation for IN queries with non-PK cols
Date Wed, 26 Sep 2012 14:08:59 GMT
Updated Branches:
  refs/heads/trunk 0dda10d76 -> 9c88ad16a


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/9c88ad16
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9c88ad16
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9c88ad16

Branch: refs/heads/trunk
Commit: 9c88ad16a69ccc8603c1be9d6253075549fb270f
Parents: 0dda10d
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 16:08:49 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/9c88ad16/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2b77d13..4d8eb91 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -87,6 +87,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/9c88ad16/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 4ae9e75..9ab0e3c 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1112,7 +1112,15 @@ public class SelectStatement implements CQLStatement
                 // have the indexed component.
                 for (Map.Entry<CFDefinition.Name, Restriction> entry : stmt.metadataRestrictions.entrySet())
                 {
-                    if (entry.getValue().isEquality() && indexedNames.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 (indexedNames.contains(entry.getKey().name.key))
                     {
                         hasEq = true;
                         break;


Mime
View raw message