Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
        CHANGES.txt
        src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
        test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java


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

Branch: refs/heads/trunk
Commit: e4980b3b8df0d15aef0f9f24159064c7be86d111
Parents: 6065f2c ee160a9
Author: Tyler Hobbs <[email protected]>
Authored: Thu Feb 19 13:21:02 2015 -0600
Committer: Tyler Hobbs <[email protected]>
Committed: Thu Feb 19 13:21:02 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 src/java/org/apache/cassandra/cql3/Relation.java         |  5 +++++
 .../org/apache/cassandra/cql3/SingleColumnRelation.java  |  5 +++++
 .../cassandra/cql3/statements/SelectStatement.java       |  6 +++++-
 .../cassandra/cql3/SelectWithTokenFunctionTest.java      | 11 +++++++++++
 5 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 9458627,f2b4469..3b6ce5d
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,19 -1,6 +1,21 @@@
 -2.0.13:
 +2.1.4
 + * Fix CommitLog.forceRecycleAllSegments() memory access error 
(CASSANDRA-8812)
 + * Improve assertions in Memory (CASSANDRA-8792)
 + * Fix SSTableRewriter cleanup (CASSANDRA-8802)
 + * Introduce SafeMemory for CompressionMetadata.Writer (CASSANDRA-8758)
 + * 'nodetool info' prints exception against older node (CASSANDRA-8796)
 + * Ensure SSTableReader.last corresponds exactly with the file end 
(CASSANDRA-8750)
 + * Make SSTableWriter.openEarly more robust and obvious (CASSANDRA-8747)
 + * Enforce SSTableReader.first/last (CASSANDRA-8744)
 + * Cleanup SegmentedFile API (CASSANDRA-8749)
 + * Avoid overlap with early compaction replacement (CASSANDRA-8683)
 + * Safer Resource Management++ (CASSANDRA-8707)
 + * Write partition size estimates into a system table (CASSANDRA-7688)
 + * cqlsh: Fix keys() and full() collection indexes in DESCRIBE output
 +   (CASSANDRA-8154)
 +Merged from 2.0:
+  * Fix combining token() function with multi-column relations on
+    clustering columns (CASSANDRA-8797)
   * Make CFS.markReferenced() resistant to bad refcounting (CASSANDRA-8829)
   * Fix StreamTransferTask abort/complete bad refcounting (CASSANDRA-8815)
   * Fix AssertionError when querying a DESC clustering ordered

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/Relation.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 08777c7,59ed6e1..9099ba7
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@@ -1933,18 -1898,22 +1933,22 @@@ public class SelectStatement implement
          /**
           * Checks that the column identifiers used as argument for the token 
function have been specified in the
           * partition key order.
 -         * @param cfDef the Column Family Definition
 +         * @param cfm the Column Family MetaData
           * @throws InvalidRequestException if the arguments have not been 
provided in the proper order.
           */
 -        private void checkTokenFunctionArgumentsOrder(CFDefinition cfDef) 
throws InvalidRequestException
 +        private void checkTokenFunctionArgumentsOrder(CFMetaData cfm) throws 
InvalidRequestException
          {
 -            Iterator<Name> iter = Iterators.cycle(cfDef.partitionKeys());
 +            Iterator<ColumnDefinition> iter = 
Iterators.cycle(cfm.partitionKeyColumns());
              for (Relation relation : whereClause)
              {
+                 if (!relation.isOnToken())
+                     continue;
+ 
+                 assert !relation.isMultiColumn() : "Unexpectedly got 
multi-column token relation";
                  SingleColumnRelation singleColumnRelation = 
(SingleColumnRelation) relation;
-                 if (singleColumnRelation.onToken && 
!cfm.getColumnDefinition(singleColumnRelation.getEntity().prepare(cfm)).equals(iter.next()))
 -                if 
(!cfDef.get(singleColumnRelation.getEntity().prepare(cfDef.cfm)).equals(iter.next()))
++                if 
(!cfm.getColumnDefinition(singleColumnRelation.getEntity().prepare(cfm)).equals(iter.next()))
                      throw new InvalidRequestException(String.format("The 
token function arguments must be in the partition key order: %s",
 -                                                                    
Joiner.on(',').join(cfDef.partitionKeys())));
 +                                                                    
Joiner.on(',').join(cfm.partitionKeyColumns())));
              }
          }
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
index 6f9f5e2,c222f35..b2a972b
--- a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
@@@ -44,23 -138,45 +44,34 @@@ public class SelectWithTokenFunctionTes
      }
  
      @Test
 -    public void testTokenFunctionWithCompoundPartition() throws Throwable
 -    {
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'a')");
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'b')");
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'c')");
 -
 -        try
 -        {
 -            UntypedResultSet results = execute("SELECT * FROM 
%s.compound_partition WHERE token(a, b) > token(0, 'a')");
 -            assertEquals(2, results.size());
 -            results = execute("SELECT * FROM %s.compound_partition WHERE 
token(a, b) > token(0, 'a') "
 -                    + "and token(a, b) < token(0, 'd')");
 -            assertEquals(2, results.size());
 -        }
 -        finally
 -        {
 -            execute("DELETE FROM %s.compound_partition WHERE a = 0 and b in 
('a', 'b', 'c')");
 -        }
 -    }
 -
 -    @Test(expected = InvalidRequestException.class)
 -    public void 
testTokenFunctionWithCompoundPartitionKeyAndColumnIdentifierInWrongOrder() 
throws Throwable
 -    {
 -        execute("SELECT * FROM %s.compound_partition WHERE token(b, a) > 
token(0, 'c')");
 -    }
 -
 -    @Test(expected = InvalidRequestException.class)
 -    public void testTokenFunctionOnEachPartitionKeyColumns() throws Throwable
 +    public void testTokenFunctionWithMultiColumnPartitionKey() throws 
Throwable
      {
 -        execute("SELECT * FROM %s.compound_partition WHERE token(a) > 
token(0) and token(b) > token('c')");
 +        createTable("CREATE TABLE IF NOT EXISTS %s (a int, b text, PRIMARY 
KEY ((a, b)))");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'a')");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'b')");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'c')");
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, 
?)", 0, "a"),
 +                   row(0, "b"),
 +                   row(0, "c"));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?) 
and token(a, b) < token(?, ?)",
 +                           0, "a",
 +                           0, "d"),
 +                   row(0, "b"),
 +                   row(0, "c"));
 +        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?) and 
token(b) > token(?)", 0, "a");
 +        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?, ?) and 
token(a) < token(?, ?) and token(b) > token(?, ?) ", 0, "a", 0, "d", 0, "a");
 +        assertInvalid("SELECT * FROM %s WHERE token(b, a) > token(0, 'c')");
      }
+ 
+     @Test
+     public void testTokenFunctionWithCompoundPartitionAndClusteringCols() 
throws Throwable
+     {
++        createTable("CREATE TABLE IF NOT EXISTS %s (a int, b int, c int, d 
int, PRIMARY KEY ((a, b), c, d))");
+         // just test that the queries don't error
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) 
> token(0, 0) AND c > 10 ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE c > 10 AND 
token(a, b) > token(0, 0) ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) 
> token(0, 0) AND (c, d) > (0, 0) ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE (c, d) > (0, 
0) AND token(a, b) > token(0, 0) ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND c > 10 
ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE c > 10 AND token(a, b) > token(0, 0) 
ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND (c, d) 
> (0, 0) ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE (c, d) > (0, 0) AND token(a, b) > 
token(0, 0) ALLOW FILTERING;");
+     }
  }

Reply via email to