You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2014/09/03 19:55:00 UTC
[1/2] git commit: Don't allow mixed multi/single column relations
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.1.0 0de4135f9 -> 1908ae3bc
Don't allow mixed multi/single column relations
Patch by Benjamin Lerer; reviewed by Tyler Hobbs for CASSANDRA-7711
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/aae9b910
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/aae9b910
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/aae9b910
Branch: refs/heads/cassandra-2.1.0
Commit: aae9b9101c61d914e0ceb7e39f88d688c986af18
Parents: b22089d
Author: blerer <b_...@hotmail.com>
Authored: Wed Sep 3 10:38:58 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Sep 3 10:38:58 2014 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../cassandra/cql3/statements/SelectStatement.java | 14 ++++++++++++--
.../cassandra/cql3/MultiColumnRelationTest.java | 6 ++++++
3 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/aae9b910/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4954b7f..7be8979 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
2.0.11:
+ * Explicitly disallowing mixing multi-column and single-column
+ relations on clustering columns (CASSANDRA-7711)
* Better error message when condition is set on PK column (CASSANDRA-7804)
* Forbid re-adding dropped counter columns (CASSANDRA-7831)
* Fix CFMetaData#isThriftCompatible() for PK-only tables (CASSANDRA-7832)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/aae9b910/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 a360d49..ea1d8e9 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -28,6 +28,8 @@ import org.github.jamm.MemoryMeter;
import org.apache.cassandra.auth.Permission;
import org.apache.cassandra.cql3.*;
+import org.apache.cassandra.cql3.CFDefinition.Name;
+import org.apache.cassandra.cql3.CFDefinition.Name.Kind;
import org.apache.cassandra.transport.messages.ResultMessage;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.db.*;
@@ -1400,6 +1402,8 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
*/
boolean hasQueriableIndex = false;
boolean hasQueriableClusteringColumnIndex = false;
+ boolean hasSingleColumnRelations = false;
+ boolean hasMultiColumnRelations = false;
for (Relation relation : whereClause)
{
if (relation.isMultiColumn())
@@ -1411,7 +1415,9 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
boolean[] queriable = processRelationEntity(stmt, relation, entity, cfDef);
hasQueriableIndex |= queriable[0];
hasQueriableClusteringColumnIndex |= queriable[1];
- names.add(cfDef.get(entity));
+ Name name = cfDef.get(entity);
+ names.add(name);
+ hasMultiColumnRelations |= Kind.COLUMN_ALIAS.equals(name.kind);
}
updateRestrictionsForRelation(stmt, names, rel, boundNames);
}
@@ -1421,9 +1427,13 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
boolean[] queriable = processRelationEntity(stmt, relation, rel.getEntity(), cfDef);
hasQueriableIndex |= queriable[0];
hasQueriableClusteringColumnIndex |= queriable[1];
- updateRestrictionsForRelation(stmt, cfDef.get(rel.getEntity()), rel, boundNames);
+ Name name = cfDef.get(rel.getEntity());
+ hasSingleColumnRelations |= Kind.COLUMN_ALIAS.equals(name.kind);
+ updateRestrictionsForRelation(stmt, name, rel, boundNames);
}
}
+ if (hasSingleColumnRelations && hasMultiColumnRelations)
+ throw new InvalidRequestException("Mixing single column relations and multi column relations on clustering columns is not allowed");
// At this point, the select statement if fully constructed, but we still have a few things to validate
processPartitionKeyRestrictions(stmt, cfDef, hasQueriableIndex);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/aae9b910/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
index 121a8d3..498d332 100644
--- a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
@@ -112,6 +112,12 @@ public class MultiColumnRelationTest
return null;
}
+ @Test(expected=InvalidRequestException.class)
+ public void testMixMultiColumnRelationsAndSingleColumn() throws Throwable
+ {
+ execute("SELECT * FROM %s.multiple_clustering WHERE a = 1 AND (b) in ((2),(3)) AND c > 4");
+ }
+
@Test(expected=SyntaxException.class)
public void testEmptyIdentifierTuple() throws Throwable
{
[2/2] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1.0
Posted by ty...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1908ae3b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1908ae3b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1908ae3b
Branch: refs/heads/cassandra-2.1.0
Commit: 1908ae3bc5d03a3239daea61c09f69ba19921805
Parents: 0de4135 aae9b91
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Sep 3 12:53:56 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Sep 3 12:53:56 2014 -0500
----------------------------------------------------------------------
----------------------------------------------------------------------