CQL3: Reject 2ndary indexes on table with composite key

patch by slebresne; reviewed by jbellis for CASSANDRA-4328


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

Branch: refs/heads/cassandra-1.1
Commit: 2d0b14e9156a5dabc92c6e3835d97da661f38329
Parents: e4ce6b3
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Tue Jun 12 15:01:08 2012 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Tue Jun 12 15:01:08 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 ++
 .../cql3/statements/CreateIndexStatement.java      |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d0b14e9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ed9650c..ae102f4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,8 @@
  * Have DeletedColumn.isMFD always return true (CASSANDRA-4307)
  * ex msg for cql3 order by constraints says primary filter can be an IN 
clause 
    which is misleading (CASSANDRA-4319)
+ * (cql3) Reject (not yet supported) creation of 2ndardy indexes on tables with
+   composite primary keys (CASSANDRA-4328)
 Merged from 1.0:
  * Set gc_grace on index CF to 0 (CASSANDRA-4314)
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d0b14e9/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java 
b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
index 9fe6f5b..e548638 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@ -55,6 +55,11 @@ public class CreateIndexStatement extends 
SchemaAlteringStatement
         boolean columnExists = false;
         // Mutating oldCfm directly would be bad so cloning.
         CFMetaData cfm = oldCfm.clone();
+        CFDefinition cfDef = oldCfm.getCfDef();
+
+        if (cfDef.isComposite)
+            throw new InvalidRequestException("Secondary indexes are not (yet) 
supported on tables with composite PRIMARY KEY");
+
         for (ColumnDefinition cd : cfm.getColumn_metadata().values())
         {
             if (cd.name.equals(columnName.key))
@@ -71,7 +76,6 @@ public class CreateIndexStatement extends 
SchemaAlteringStatement
         }
         if (!columnExists)
         {
-            CFDefinition cfDef = oldCfm.getCfDef();
             CFDefinition.Name name = cfDef.get(columnName);
             if (name != null)
             {

Reply via email to