Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 440824c1a -> 24e4210a4
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/cassandra-2.1 Commit: 6cabd252be8fd08faf500bf327f14270411af569 Parents: e916dff Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Fri Oct 17 11:29:34 2014 +0200 Committer: Sylvain Lebresne <sylv...@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()));