You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sa...@apache.org on 2015/09/18 12:50:10 UTC

[2/3] cassandra git commit: Don't allow secondary indexes on materialized views

Don't allow secondary indexes on materialized views

This commit also fixes a problem with AlterViewStatement not updating
view options correctly.

Patch by Sam Tunnicliffe and Paulo Motta; reviewed by Aleksey Yeschenko
for CASSANDRA-9921


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

Branch: refs/heads/trunk
Commit: 106b1cdabe90bd28e8b6accac232746dc023987c
Parents: 1b823ec
Author: Sam Tunnicliffe <sa...@beobal.com>
Authored: Thu Sep 17 13:00:52 2015 +0100
Committer: Sam Tunnicliffe <sa...@beobal.com>
Committed: Fri Sep 18 11:47:02 2015 +0100

----------------------------------------------------------------------
 ...core-3.0.0-alpha3-7b60bed-SNAPSHOT-shaded.jar | Bin 2217129 -> 0 bytes
 ...core-3.0.0-alpha3-b6aa814-SNAPSHOT-shaded.jar | Bin 0 -> 2217119 bytes
 .../cql3/statements/AlterViewStatement.java      |   7 +++----
 .../cql3/statements/CreateIndexStatement.java    |   3 +++
 4 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b1cda/lib/cassandra-driver-core-3.0.0-alpha3-7b60bed-SNAPSHOT-shaded.jar
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-core-3.0.0-alpha3-7b60bed-SNAPSHOT-shaded.jar b/lib/cassandra-driver-core-3.0.0-alpha3-7b60bed-SNAPSHOT-shaded.jar
deleted file mode 100644
index 405919f..0000000
Binary files a/lib/cassandra-driver-core-3.0.0-alpha3-7b60bed-SNAPSHOT-shaded.jar and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b1cda/lib/cassandra-driver-core-3.0.0-alpha3-b6aa814-SNAPSHOT-shaded.jar
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-core-3.0.0-alpha3-b6aa814-SNAPSHOT-shaded.jar b/lib/cassandra-driver-core-3.0.0-alpha3-b6aa814-SNAPSHOT-shaded.jar
new file mode 100644
index 0000000..0f01a28
Binary files /dev/null and b/lib/cassandra-driver-core-3.0.0-alpha3-b6aa814-SNAPSHOT-shaded.jar differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b1cda/src/java/org/apache/cassandra/cql3/statements/AlterViewStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterViewStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterViewStatement.java
index e578c4f..e12ebd7 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterViewStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterViewStatement.java
@@ -61,22 +61,21 @@ public class AlterViewStatement extends SchemaAlteringStatement
         if (!meta.isView())
             throw new InvalidRequestException("Cannot use ALTER MATERIALIZED VIEW on Table");
 
-        ViewDefinition view = Schema.instance.getView(keyspace(), columnFamily());
-        ViewDefinition viewCopy = view.copy();
+        ViewDefinition viewCopy = Schema.instance.getView(keyspace(), columnFamily()).copy();
 
         if (attrs == null)
             throw new InvalidRequestException("ALTER MATERIALIZED VIEW WITH invoked, but no parameters found");
 
         attrs.validate();
 
-        TableParams params = attrs.asAlteredTableParams(view.metadata.params);
+        TableParams params = attrs.asAlteredTableParams(viewCopy.metadata.params);
         if (params.gcGraceSeconds == 0)
         {
             throw new InvalidRequestException("Cannot alter gc_grace_seconds of a materialized view to 0, since this " +
                                               "value is used to TTL undelivered updates. Setting gc_grace_seconds too " +
                                               "low might cause undelivered updates to expire before being replayed.");
         }
-        view.metadata.params(params);
+        viewCopy.metadata.params(params);
 
         MigrationManager.announceViewUpdate(viewCopy, isLocalOnly);
         return true;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/106b1cda/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 bd6f0c3..0735103 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@ -78,6 +78,9 @@ public class CreateIndexStatement extends SchemaAlteringStatement
         if (cfm.isCounter())
             throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
 
+        if (cfm.isView())
+            throw new InvalidRequestException("Secondary indexes are not supported on materialized views");
+
         if (cfm.isCompactTable() && !cfm.isStaticCompactTable())
             throw new InvalidRequestException("Secondary indexes are not supported on COMPACT STORAGE tables that have clustering columns");