mirror of https://github.com/apache/cassandra
Never allow partition range queries in CQL3 without token()
patch by slebresne; reviewed by jbellis for CASSANDRA-5666
This commit is contained in:
parent
9ba0ff03e2
commit
41f418a09e
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue