cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject [2/3] cassandra git commit: Merge branch cassandra-3.0 into cassandra-3.11
Date Tue, 06 Feb 2018 03:42:16 GMT
Merge branch cassandra-3.0 into cassandra-3.11


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

Branch: refs/heads/trunk
Commit: de6c62dd6ce60d8493319deb05b71f90d85bc2b0
Parents: 28ee665 7df3605
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Mon Feb 5 22:40:56 2018 -0500
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Mon Feb 5 22:40:56 2018 -0500

----------------------------------------------------------------------
 .../apache/cassandra/cql3/statements/AlterTableStatement.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/de6c62dd/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index de42647,59c4e08..12abba7
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@@ -190,59 -192,54 +190,59 @@@ public class AlterTableStatement extend
                  if (!meta.isCQLTable())
                      throw new InvalidRequestException("Cannot drop columns from a non-CQL3
table");
  
 -                if (def == null)
 -                    throw new InvalidRequestException(String.format("Column %s was not found
in table %s", columnName, columnFamily()));
 -
                  cfm = meta.copy();
  
 -                switch (def.kind)
 +                for (AlterTableStatementColumn colData : colNameList)
                  {
 -                    case PARTITION_KEY:
 -                    case CLUSTERING:
 -                        throw new InvalidRequestException(String.format("Cannot drop PRIMARY
KEY part %s", columnName));
 -                    case REGULAR:
 -                    case STATIC:
 -                        ColumnDefinition toDelete = null;
 -                        for (ColumnDefinition columnDef : cfm.partitionColumns())
 -                        {
 -                            if (columnDef.name.equals(columnName))
 -                            {
 -                                toDelete = columnDef;
 -                                break;
 -                            }
 -                        }
 -                        assert toDelete != null;
 -                        cfm.removeColumnDefinition(toDelete);
 -                        cfm.recordColumnDrop(toDelete, deleteTimestamp == null ? queryState.getTimestamp()
: deleteTimestamp);
 -                        break;
 -                }
 +                    columnName = colData.getColumnName().getIdentifier(cfm);
 +                    def = cfm.getColumnDefinition(columnName);
  
 -                // If the dropped column is required by any secondary indexes
 -                // we reject the operation, as the indexes must be dropped first
 -                Indexes allIndexes = cfm.getIndexes();
 -                if (!allIndexes.isEmpty())
 -                {
 -                    ColumnFamilyStore store = Keyspace.openAndGetStore(cfm);
 -                    Set<IndexMetadata> dependentIndexes = store.indexManager.getDependentIndexes(def);
 -                    if (!dependentIndexes.isEmpty())
 -                        throw new InvalidRequestException(String.format("Cannot drop column
%s because it has " +
 -                                                                        "dependent secondary
indexes (%s)",
 -                                                                        def,
 -                                                                        dependentIndexes.stream()
 -                                                                                       
.map(i -> i.name)
 -                                                                                       
.collect(Collectors.joining(","))));
 -                }
 +                    if (def == null)
 +                        throw new InvalidRequestException(String.format("Column %s was not
found in table %s", columnName, columnFamily()));
  
 -                if (!Iterables.isEmpty(views))
 +                    switch (def.kind)
 +                    {
 +                         case PARTITION_KEY:
 +                         case CLUSTERING:
 +                              throw new InvalidRequestException(String.format("Cannot drop
PRIMARY KEY part %s", columnName));
 +                         case REGULAR:
 +                         case STATIC:
 +                              ColumnDefinition toDelete = null;
 +                              for (ColumnDefinition columnDef : cfm.partitionColumns())
 +                              {
 +                                   if (columnDef.name.equals(columnName))
 +                                   {
 +                                       toDelete = columnDef;
 +                                       break;
 +                                   }
 +                               }
 +                             assert toDelete != null;
 +                             cfm.removeColumnDefinition(toDelete);
 +                             cfm.recordColumnDrop(toDelete, deleteTimestamp  == null ? queryState.getTimestamp()
: deleteTimestamp);
 +                             break;
 +                    }
 +
 +                    // If the dropped column is required by any secondary indexes
 +                    // we reject the operation, as the indexes must be dropped first
 +                    Indexes allIndexes = cfm.getIndexes();
 +                    if (!allIndexes.isEmpty())
 +                    {
 +                        ColumnFamilyStore store = Keyspace.openAndGetStore(cfm);
 +                        Set<IndexMetadata> dependentIndexes = store.indexManager.getDependentIndexes(def);
 +                        if (!dependentIndexes.isEmpty())
 +                            throw new InvalidRequestException(String.format("Cannot drop
column %s because it has " +
 +                                                                            "dependent secondary
indexes (%s)",
 +                                                                            def,
 +                                                                            dependentIndexes.stream()
 +                                                                                       
    .map(i -> i.name)
 +                                                                                       
    .collect(Collectors.joining(","))));
 +                    }
 +
 +                    if (!Iterables.isEmpty(views))
-                         throw new InvalidRequestException(String.format("Cannot drop column
%s on base table with materialized views.",
+                     throw new InvalidRequestException(String.format("Cannot drop column
%s on base table %s with materialized views.",
 -                                                                    columnName.toString(),
 -                                                                    columnFamily()));
 +                                                                        columnName.toString(),
-                                                                         keyspace()));
++                                                                        columnFamily()));
 +                }
                  break;
              case DROP_COMPACT_STORAGE:
                  if (!meta.isCompactTable())


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message