cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/3] git commit: Properly reject token function in DELETE statements
Date Fri, 17 Oct 2014 09:34:28 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 0ca6beb68 -> c183f5506


Properly reject token function in DELETE statements

patch by slebresne; reviewed by thobbs for CASSANDRA-7747


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

Branch: refs/heads/trunk
Commit: 6cabd252be8fd08faf500bf327f14270411af569
Parents: e916dff
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Oct 17 11:29:34 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Oct 17 11:29:34 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                     | 1 +
 src/java/org/apache/cassandra/cql3/SingleColumnRelation.java    | 2 ++
 .../apache/cassandra/cql3/statements/ModificationStatement.java | 5 ++++-
 3 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6cabd252/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 73aaab0..8c4fc15 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.11:
+ * Properly reject the token function DELETE (CASSANDRA-7747)
  * Force batchlog replay before decommissioning a node (CASSANDRA-7446)
  * Fix hint replay with many accumulated expired hints (CASSANDRA-6998)
  * Fix duplicate results in DISTINCT queries on static columns with query

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6cabd252/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
index 642be66..ee95da0 100644
--- a/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
+++ b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
@@ -99,6 +99,8 @@ public class SingleColumnRelation extends Relation
     {
         if (relationType == Type.IN)
             return String.format("%s IN %s", entity, inValues);
+        else if (onToken)
+            return String.format("token(%s) %s %s", entity, relationType, value);
         else
             return String.format("%s %s %s", entity, relationType, value);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6cabd252/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 b214e76..006873d 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -264,10 +264,13 @@ public abstract class ModificationStatement implements CQLStatement,
MeasurableF
             if (!(relation instanceof SingleColumnRelation))
             {
                 throw new InvalidRequestException(
-                        String.format("Multi-column relations cannot be used in WHERE clauses
for modification statements: %s", relation));
+                        String.format("Multi-column relations cannot be used in WHERE clauses
for UPDATE and DELETE statements: %s", relation));
             }
             SingleColumnRelation rel = (SingleColumnRelation) relation;
 
+            if (rel.onToken)
+                throw new InvalidRequestException(String.format("The token function cannot
be used in WHERE clauses for UPDATE and DELETE statements: %s", relation));
+
             CFDefinition.Name name = cfDef.get(rel.getEntity());
             if (name == null)
                 throw new InvalidRequestException(String.format("Unknown key identifier %s",
rel.getEntity()));


Mime
View raw message