Updated Branches: refs/heads/cassandra-1.2 9ba0ff03e -> 41f418a09
Never allow partition range queries in CQL3 without token() patch by slebresne; reviewed by jbellis for CASSANDRA-5666 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/41f418a0 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/41f418a0 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/41f418a0 Branch: refs/heads/cassandra-1.2 Commit: 41f418a09e03e36911b404ff01c96adefc75b988 Parents: 9ba0ff0 Author: Sylvain Lebresne <[email protected]> Authored: Thu Jun 20 19:10:24 2013 +0200 Committer: Sylvain Lebresne <[email protected]> Committed: Thu Jun 20 19:10:24 2013 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + doc/cql3/CQL.textile | 5 +++-- .../org/apache/cassandra/cql3/statements/SelectStatement.java | 6 +----- 3 files changed, 5 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/41f418a0/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index e1282aa..bd52eab 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,6 +29,7 @@ * Suppress custom exceptions thru jmx (CASSANDRA-5652) * Update CREATE CUSTOM INDEX syntax (CASSANDRA-5639) * Fix PermissionDetails.equals() method (CASSANDRA-5655) + * Never allow partition key ranges in CQL3 without token() (CASSANDRA-5666) Merged from 1.1: * Remove buggy thrift max message length option (CASSANDRA-5529) * Fix NPE in Pig's widerow mode (CASSANDRA-5488) http://git-wip-us.apache.org/repos/asf/cassandra/blob/41f418a0/doc/cql3/CQL.textile ---------------------------------------------------------------------- diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile index 5fa36ab..f7d2dda 100644 --- a/doc/cql3/CQL.textile +++ b/doc/cql3/CQL.textile @@ -626,7 +626,7 @@ h4(#selectWhere). @<where-clause>@ The @<where-clause>@ specifies which rows must be queried. It is composed of relations on the columns that are part of the @PRIMARY KEY@ and/or have a "secondary index":#createIndexStmt defined on them. -Not all relations are allowed in a query. For instance, non-equal relations (where @IN@ is considered as an equal relation) on a partition key is only supported if the partitioner for the keyspace is an ordered one. Moreover, for a given partition key, the clustering keys induce an ordering of rows and relations on them is restricted to the relations that allow to select a *contiguous* (for the ordering) set of rows. For instance, given +Not all relations are allowed in a query. For instance, non-equal relations (where @IN@ is considered as an equal relation) on a partition key are not supported (but see the use of the @TOKEN@ method below to do non-equal queries on the partition key). Moreover, for a given partition key, the clustering keys induce an ordering of rows and relations on them is restricted to the relations that allow to select a *contiguous* (for the ordering) set of rows. For instance, given bc(sample). CREATE TABLE posts ( @@ -650,7 +650,7 @@ bc(sample). // Needs a blog_title to be set to select ranges of posted_at SELECT entry_title, content FROM posts WHERE userid='john doe' AND posted_at >= 2012-01-01 AND posted_at < 2012-01-31 -When specifying relations, the @TOKEN@ function can be used on the @PARTITION KEY@ column to query. In that case, rows will be selected based on the token of their @PARTITION_KEY@ rather than on the value (note that the token of a key depends on the partitioner in use, and that in particular the RandomPartitioner won't yeld a meaningful order). Example: +When specifying relations, the @TOKEN@ function can be used on the @PARTITION KEY@ column to query. In that case, rows will be selected based on the token of their @PARTITION_KEY@ rather than on the value. Note that the token of a key depends on the partitioner in use, and that in particular the RandomPartitioner won't yeld a meaningful order. Also note that ordering partitioners always order token values by bytes (so even if the partition key is of type int, @token(-1) > token(0)@ in particular). Example: bc(sample). SELECT * FROM posts WHERE token(userid) > token('tom') AND token(userid) < token('bob') @@ -1051,6 +1051,7 @@ The following describes the addition/changes brought for each version of CQL. h3. 3.0.4 * Updated the syntax for custom "secondary indexes":#createIndexStmt. +* Non-equal condition on the partition key are now never supported, even for ordering partitioner as this was not correct (the order was *not* the one of the type of the partition key). Instead, the @token@ method should always be used for range queries on the partition key (see "WHERE clauses":#selectWhere). h3. 3.0.3 http://git-wip-us.apache.org/repos/asf/cassandra/blob/41f418a0/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 57913fe..03f222b 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@ -1046,11 +1046,7 @@ public class SelectStatement implements CQLStatement } else { - if (!partitioner.preservesOrder()) - throw new InvalidRequestException("Only EQ and IN relation are supported on the partition key for random partitioners (unless you use the token() function)"); - - stmt.isKeyRange = true; - shouldBeDone = true; + throw new InvalidRequestException("Only EQ and IN relation are supported on the partition key (you will need to use the token() function for non equality based relation)"); } previous = cname; }
