Merge branch 'cassandra-2.1' into trunk

This commit is contained in:
Tyler Hobbs 2014-11-19 11:38:17 -06:00
commit 1bd5c64ba1
4 changed files with 67 additions and 7 deletions

View File

@ -33,6 +33,9 @@
* improve concurrency of repair (CASSANDRA-6455, 8208)
2.1.3
* Fix filtering for CONTAINS (KEY) relations on frozen collection
clustering columns when the query is restricted to a single
partition (CASSANDRA-8203)
* Do more aggressive entire-sstable TTL expiry checks (CASSANDRA-8243)
* Add more log info if readMeter is null (CASSANDRA-8238)
* add check of the system wall clock time at startup (CASSANDRA-8305)

View File

@ -1947,12 +1947,12 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
if (stmt.selectACollection())
throw new InvalidRequestException(String.format("Cannot restrict column \"%s\" by IN relation as a collection is selected by the query", cdef.name));
}
/*
else if (restriction.isContains() && !hasQueriableIndex)
else if (restriction.isContains())
{
throw new InvalidRequestException(String.format("Cannot restrict column \"%s\" by a CONTAINS relation without a secondary index", cdef.name));
if (!hasQueriableIndex)
throw new InvalidRequestException(String.format("Cannot restrict column \"%s\" by a CONTAINS relation without a secondary index", cdef.name));
stmt.usesSecondaryIndexing = true;
}
*/
previous = cdef;
}

View File

@ -263,6 +263,13 @@ public abstract class CQLTester
}
}
protected void dropIndex(String query) throws Throwable
{
String fullQuery = String.format(query, KEYSPACE);
logger.info(fullQuery);
schemaChange(fullQuery);
}
private static void schemaChange(String query)
{
try

View File

@ -615,10 +615,10 @@ public class FrozenCollectionsTest extends CQLTester
"SELECT * FROM %s WHERE c CONTAINS KEY ?", 1);
// normal indexes on frozen collections don't support CONTAINS or CONTAINS KEY
assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator",
assertInvalidMessage("Cannot restrict column \"b\" by a CONTAINS relation without a secondary index",
"SELECT * FROM %s WHERE b CONTAINS ?", 1);
assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator",
assertInvalidMessage("Cannot restrict column \"b\" by a CONTAINS relation without a secondary index",
"SELECT * FROM %s WHERE b CONTAINS ? ALLOW FILTERING", 1);
assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator",
@ -627,7 +627,7 @@ public class FrozenCollectionsTest extends CQLTester
assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator",
"SELECT * FROM %s WHERE d CONTAINS KEY ? ALLOW FILTERING", 1);
assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator",
assertInvalidMessage("Cannot restrict column \"b\" by a CONTAINS relation without a secondary index",
"SELECT * FROM %s WHERE b CONTAINS ? AND d CONTAINS KEY ? ALLOW FILTERING", 1, 1);
// index lookup on b
@ -743,6 +743,56 @@ public class FrozenCollectionsTest extends CQLTester
);
}
/** Test for CASSANDRA-8302 */
@Test
public void testClusteringColumnFiltering() throws Throwable
{
createTable("CREATE TABLE %s (a int, b frozen<map<int, int>>, c int, d int, PRIMARY KEY (a, b, c))");
createIndex("CREATE INDEX c_index ON %s (c)");
createIndex("CREATE INDEX d_index ON %s (d)");
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, map(0, 0, 1, 1), 0, 0);
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, map(1, 1, 2, 2), 0, 0);
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, map(0, 0, 1, 1), 0, 0);
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, map(1, 1, 2, 2), 0, 0);
assertRows(execute("SELECT * FROM %s WHERE d=? AND b CONTAINS ? ALLOW FILTERING", 0, 0),
row(0, map(0, 0, 1, 1), 0, 0),
row(1, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE d=? AND b CONTAINS KEY ? ALLOW FILTERING", 0, 0),
row(0, map(0, 0, 1, 1), 0, 0),
row(1, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE a=? AND d=? AND b CONTAINS ? ALLOW FILTERING", 0, 0, 0),
row(0, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE a=? AND d=? AND b CONTAINS KEY ? ALLOW FILTERING", 0, 0, 0),
row(0, map(0, 0, 1, 1), 0, 0)
);
dropIndex("DROP INDEX %s.d_index");
assertRows(execute("SELECT * FROM %s WHERE c=? AND b CONTAINS ? ALLOW FILTERING", 0, 0),
row(0, map(0, 0, 1, 1), 0, 0),
row(1, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE c=? AND b CONTAINS KEY ? ALLOW FILTERING", 0, 0),
row(0, map(0, 0, 1, 1), 0, 0),
row(1, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE a=? AND c=? AND b CONTAINS ? ALLOW FILTERING", 0, 0, 0),
row(0, map(0, 0, 1, 1), 0, 0)
);
assertRows(execute("SELECT * FROM %s WHERE a=? AND c=? AND b CONTAINS KEY ? ALLOW FILTERING", 0, 0, 0),
row(0, map(0, 0, 1, 1), 0, 0)
);
}
@Test
public void testUserDefinedTypes() throws Throwable
{