Merge branch 'cassandra-2.0' into cassandra-2.1 Conflicts: CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7d7d529f Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7d7d529f Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7d7d529f Branch: refs/heads/trunk Commit: 7d7d529f6d20683c2a6d052189c63f0d6575e5f7 Parents: d4ac8d5 296903b Author: Tyler Hobbs <ty...@datastax.com> Authored: Tue Aug 19 11:20:24 2014 -0500 Committer: Tyler Hobbs <ty...@datastax.com> Committed: Tue Aug 19 11:20:24 2014 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 + pylib/cqlshlib/cql3handling.py | 10 ++-- .../cql3/statements/SelectStatement.java | 7 +++ .../cql3/SingleColumnRelationTest.java | 51 ++++++++++++++++++++ 4 files changed, 64 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d7d529f/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 186ef86,de45376..0763738 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,23 -1,13 +1,25 @@@ -2.0.10 +2.1.1 + * Support list index operations with conditions (CASSANDRA-7499) + * Add max live/tombstoned cells to nodetool cfstats output (CASSANDRA-7731) + * Validate IPv6 wildcard addresses properly (CASSANDRA-7680) + * (cqlsh) Error when tracing query (CASSANDRA-7613) + * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569) + * SSTableExport uses correct validator to create string representation of partition + keys (CASSANDRA-7498) + * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689) + * Add support for custom 2i validation (CASSANDRA-7575) + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454) + * Add listen_interface and rpc_interface options (CASSANDRA-7417) + * Improve schema merge performance (CASSANDRA-7444) + * Adjust MT depth based on # of partition validating (CASSANDRA-5263) + * Optimise NativeCell comparisons (CASSANDRA-6755) + * Configurable client timeout for cqlsh (CASSANDRA-7516) + * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111) +Merged from 2.0: + * Throw InvalidRequestException when queries contain relations on entire + collection columns (CASSANDRA-7506) - * Fix PRSI handling of CQL3 row markers for row cleanup (CASSANDRA-7787) * (cqlsh) enable CTRL-R history search with libedit (CASSANDRA-7577) - * Fix dropping collection when it's the last regular column (CASSANDRA-7744) - * 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) * (cqlsh) cqlsh should automatically disable tracing when selecting from system_traces (CASSANDRA-7641) * (Hadoop) Add CqlOutputFormat (CASSANDRA-6927) http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d7d529f/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --cc pylib/cqlshlib/cql3handling.py index 72461db,01818ca..bb08d01 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@@ -183,6 -203,6 +183,7 @@@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n | <uuid> | <boolean> | <blobLiteral> ++ | <collectionLiteral> | <functionName> <functionArguments> ; @@@ -192,9 -212,9 +193,6 @@@ <tokenDefinition> ::= token="TOKEN" "(" <term> ( "," <term> )* ")" | <term> ; --<value> ::= <term> -- | <collectionLiteral> -- ; <cident> ::= <quotedName> | <identifier> | <unreservedKeyword> @@@ -395,7 -408,7 +393,7 @@@ def ks_prop_val_mapval_completer(ctxt, currentkey = dequote_value(ctxt.get_binding('propmapkey')[-1]) if currentkey == 'class': return map(escape_value, CqlRuleSet.replication_strategies) -- return [Hint('<value>')] ++ return [Hint('<term>')] def ks_prop_val_mapender_completer(ctxt, cass): optname = ctxt.get_binding('propname')[-1] @@@ -673,8 -649,8 +671,8 @@@ syntax_rules += r'' <insertStatement> ::= "INSERT" "INTO" cf=<columnFamilyName> "(" [colname]=<cident> "," [colname]=<cident> ( "," [colname]=<cident> )* ")" -- "VALUES" "(" [newval]=<value> valcomma="," [newval]=<value> -- ( valcomma="," [newval]=<value> )* valcomma=")" ++ "VALUES" "(" [newval]=<term> valcomma="," [newval]=<term> ++ ( valcomma="," [newval]=<term> )* valcomma=")" ( "USING" [insertopt]=<usingOption> ( "AND" [insertopt]=<usingOption> )* )? ; http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d7d529f/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index 45dd77e,8145722..011419b --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@@ -1645,6 -1658,13 +1645,13 @@@ public class SelectStatement implement StorageService.getPartitioner().getTokenValidator()); } + // We don't support relations against entire collections, like "numbers = {1, 2, 3}" - if (receiver.type.isCollection()) ++ if (receiver.type.isCollection() && !(newRel.operator().equals(Relation.Type.CONTAINS_KEY) || newRel.operator() == Relation.Type.CONTAINS)) + { + throw new InvalidRequestException(String.format("Collection column '%s' (%s) cannot be restricted by a '%s' relation", - name, receiver.type.asCQL3Type(), newRel.operator())); ++ def.name, receiver.type.asCQL3Type(), newRel.operator())); + } + switch (newRel.operator()) { case EQ: http://git-wip-us.apache.org/repos/asf/cassandra/blob/7d7d529f/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java index 0000000,0000000..120c780 new file mode 100644 --- /dev/null +++ b/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java @@@ -1,0 -1,0 +1,51 @@@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++package org.apache.cassandra.cql3; ++ ++import org.junit.Test; ++ ++public class SingleColumnRelationTest extends CQLTester ++{ ++ @Test ++ public void testInvalidCollectionEqualityRelation() throws Throwable ++ { ++ createTable("CREATE TABLE %s (a int PRIMARY KEY, b set<int>, c list<int>, d map<int, int>)"); ++ createIndex("CREATE INDEX ON %s (b)"); ++ createIndex("CREATE INDEX ON %s (c)"); ++ createIndex("CREATE INDEX ON %s (d)"); ++ ++ assertInvalid("SELECT * FROM %s WHERE a = 0 AND b=?", set(0)); ++ assertInvalid("SELECT * FROM %s WHERE a = 0 AND c=?", list(0)); ++ assertInvalid("SELECT * FROM %s WHERE a = 0 AND d=?", map(0, 0)); ++ } ++ ++ @Test ++ public void testInvalidCollectionNonEQRelation() throws Throwable ++ { ++ createTable("CREATE TABLE %s (a int PRIMARY KEY, b set<int>, c int)"); ++ createIndex("CREATE INDEX ON %s (c)"); ++ execute("INSERT INTO %s (a, b, c) VALUES (0, {0}, 0)"); ++ ++ // non-EQ operators ++ assertInvalid("SELECT * FROM %s WHERE c = 0 AND b > ?", set(0)); ++ assertInvalid("SELECT * FROM %s WHERE c = 0 AND b >= ?", set(0)); ++ assertInvalid("SELECT * FROM %s WHERE c = 0 AND b < ?", set(0)); ++ assertInvalid("SELECT * FROM %s WHERE c = 0 AND b <= ?", set(0)); ++ assertInvalid("SELECT * FROM %s WHERE c = 0 AND b IN (?)", set(0)); ++ } ++}