mirror of https://github.com/apache/cassandra
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
This commit is contained in:
parent
1b823ec2c1
commit
106b1cdabe
Binary file not shown.
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue