cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/5] git commit: Properly reject operations on list index
Date Mon, 18 Aug 2014 08:24:08 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 4e334ab82 -> 9aea917b2


Properly reject operations on list index

patch by slebresne; reviewed by thobbs for CASSANDRA-7499


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

Branch: refs/heads/trunk
Commit: 700e81634de3dde2d9c43bdb78716a7bb994c2ae
Parents: b87741c
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Aug 18 10:01:58 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Aug 18 10:01:58 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |  1 +
 .../cassandra/cql3/statements/BatchStatement.java |  3 +++
 .../cql3/statements/ModificationStatement.java    | 18 ++++++++++++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/700e8163/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 94169c1..f489702 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.10
+ * Properly reject operations on list index with conditions (CASSANDRA-7499)
  * (Hadoop) allow ACFRW to limit nodes to local DC (CASSANDRA-7252)
  * (cqlsh) Wait up to 10 sec for a tracing session (CASSANDRA-7222)
  * Fix NPE in FileCacheService.sizeInBytes (CASSANDRA-7756)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/700e8163/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 8fc1ecc..cbe3016 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -125,6 +125,9 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache
                 throw new InvalidRequestException("Timestamp must be set either on BATCH
or individual statements");
 
             statement.validate(state);
+
+            if (hasConditions && statement.requiresRead())
+                throw new InvalidRequestException("Operations using list indexes are not
allowed with IF conditions");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/700e8163/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index 11aa0b1..99dd9d9 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -151,8 +151,14 @@ public abstract class ModificationStatement implements CQLStatement,
MeasurableF
 
     public void validate(ClientState state) throws InvalidRequestException
     {
-        if (hasConditions() && attrs.isTimestampSet())
-            throw new InvalidRequestException("Cannot provide custom timestamp for conditional
update");
+        if (hasConditions())
+        {
+            if (attrs.isTimestampSet())
+                throw new InvalidRequestException("Cannot provide custom timestamp for conditional
update");
+
+            if (requiresRead())
+                throw new InvalidRequestException("Operations using list indexes are not
allowed with IF conditions");
+        }
 
         if (isCounter())
         {
@@ -439,6 +445,14 @@ public abstract class ModificationStatement implements CQLStatement,
MeasurableF
         return null;
     }
 
+    public boolean requiresRead()
+    {
+        for (Operation op : columnOperations)
+            if (op.requiresRead())
+                return true;
+        return false;
+    }
+
     protected Map<ByteBuffer, ColumnGroupMap> readRequiredRows(Collection<ByteBuffer>
partitionKeys, ColumnNameBuilder clusteringPrefix, boolean local, ConsistencyLevel cl)
     throws RequestExecutionException, RequestValidationException
     {


Mime
View raw message