You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2019/07/10 14:27:02 UTC

[cassandra] branch cassandra-3.11 updated (da6268d -> 824d25a)

This is an automated email from the ASF dual-hosted git repository.

aleksey pushed a change to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from da6268d  Merge branch 'cassandra-3.0' into cassandra-3.11
     add 855fc91  Toughen up column drop/recreate type validations
     new 824d25a  Merge branch 'cassandra-3.0' into cassandra-3.11

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.txt                                        |  2 +-
 .../cql3/statements/AlterTableStatement.java       | 28 ++++-----
 .../cql3/validation/entities/CollectionsTest.java  |  4 +-
 .../cql3/validation/operations/AlterTest.java      | 67 +++++++++++++++++++---
 .../org/apache/cassandra/db/LegacyLayoutTest.java  |  2 +-
 5 files changed, 76 insertions(+), 27 deletions(-)


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


[cassandra] 01/01: Merge branch 'cassandra-3.0' into cassandra-3.11

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aleksey pushed a commit to branch cassandra-3.11
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 824d25a18b258f54bff69f415d9984fa04fda298
Merge: da6268d 855fc91
Author: Aleksey Yeshchenko <al...@apache.org>
AuthorDate: Wed Jul 10 15:26:29 2019 +0100

    Merge branch 'cassandra-3.0' into cassandra-3.11

 CHANGES.txt                                        |  2 +-
 .../cql3/statements/AlterTableStatement.java       | 28 ++++-----
 .../cql3/validation/entities/CollectionsTest.java  |  4 +-
 .../cql3/validation/operations/AlterTest.java      | 67 +++++++++++++++++++---
 .../org/apache/cassandra/db/LegacyLayoutTest.java  |  2 +-
 5 files changed, 76 insertions(+), 27 deletions(-)

diff --cc CHANGES.txt
index 57e07e7,c8bd30d..406246e
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,9 -1,5 +1,9 @@@
- <<<<<<< HEAD
 -3.0.19
 +3.11.5
 + * Fix cassandra-env.sh to use $CASSANDRA_CONF to find cassandra-jaas.config (CASSANDRA-14305)
 + * Fixed nodetool cfstats printing index name twice (CASSANDRA-14903)
 + * Add flag to disable SASI indexes, and warnings on creation (CASSANDRA-14866)
 +Merged from 3.0:
+  * Toughen up column drop/recreate type validations (CASSANDRA-15204)
   * LegacyLayout should handle paging states that cross a collection column (CASSANDRA-15201)
   * Prevent RuntimeException when username or password is empty/null (CASSANDRA-15198)
   * Multiget thrift query returns null records after digest mismatch (CASSANDRA-14812)
diff --cc src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index 12abba7,9474fb0..dd3201d
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@@ -105,82 -117,72 +104,83 @@@ public class AlterTableStatement extend
  
                  cfm = meta.copy();
  
 -                if (isStatic)
 +                for (AlterTableStatementColumn colData : colNameList)
                  {
 -                    if (!cfm.isCompound())
 -                        throw new InvalidRequestException("Static columns are not allowed in COMPACT STORAGE tables");
 -                    if (cfm.clusteringColumns().isEmpty())
 -                        throw new InvalidRequestException("Static columns are only useful (and thus allowed) if the table has at least one clustering column");
 -                }
 +                    columnName = colData.getColumnName().getIdentifier(cfm);
 +                    def = cfm.getColumnDefinition(columnName);
 +                    dataType = colData.getColumnType();
 +                    assert dataType != null;
 +                    isStatic = colData.getStaticType();
 +                    validator = dataType.prepare(keyspace());
  
 -                if (def != null)
 -                {
 -                    switch (def.kind)
 +
 +                    if (isStatic)
                      {
 -                        case PARTITION_KEY:
 -                        case CLUSTERING:
 -                            throw new InvalidRequestException(String.format("Invalid column name %s because it conflicts with a PRIMARY KEY part", columnName));
 -                        default:
 -                            throw new InvalidRequestException(String.format("Invalid column name %s because it conflicts with an existing column", columnName));
 +                        if (!cfm.isCompound())
 +                            throw new InvalidRequestException("Static columns are not allowed in COMPACT STORAGE tables");
 +                        if (cfm.clusteringColumns().isEmpty())
 +                            throw new InvalidRequestException("Static columns are only useful (and thus allowed) if the table has at least one clustering column");
                      }
 -                }
  
 -                AbstractType<?> type = validator.getType();
 -                if (type.isCollection() && type.isMultiCell())
 -                {
 -                    if (!cfm.isCompound())
 -                        throw new InvalidRequestException("Cannot use non-frozen collections in COMPACT STORAGE tables");
 -                    if (cfm.isSuper())
 -                        throw new InvalidRequestException("Cannot use non-frozen collections with super column families");
 -                }
 +                    if (def != null)
 +                    {
 +                        switch (def.kind)
 +                        {
 +                            case PARTITION_KEY:
 +                            case CLUSTERING:
 +                                throw new InvalidRequestException(String.format("Invalid column name %s because it conflicts with a PRIMARY KEY part", columnName));
 +                            default:
 +                                throw new InvalidRequestException(String.format("Invalid column name %s because it conflicts with an existing column", columnName));
 +                        }
 +                    }
  
-                     // Cannot re-add a dropped counter column. See #7831.
-                     if (meta.isCounter() && meta.getDroppedColumns().containsKey(columnName.bytes))
-                         throw new InvalidRequestException(String.format("Cannot re-add previously dropped counter column %s", columnName));
- 
 -                CFMetaData.DroppedColumn droppedColumn = meta.getDroppedColumns().get(columnName.bytes);
 -                if (null != droppedColumn)
 -                {
 -                    // After #8099, not safe to re-add columns of incompatible types - until *maybe* deser logic with dropped
 -                    // columns is pushed deeper down the line. The latter would still be problematic in cases of schema races.
 -                    if (!type.isValueCompatibleWith(droppedColumn.type))
 +                    AbstractType<?> type = validator.getType();
 +                    if (type.isCollection() && type.isMultiCell())
                      {
 -                        String message =
 -                            String.format("Cannot re-add previously dropped column '%s' of type %s, incompatible with previous type %s",
 -                                          columnName,
 -                                          type.asCQL3Type(),
 -                                          droppedColumn.type.asCQL3Type());
 -                        throw new InvalidRequestException(message);
 +                        if (!cfm.isCompound())
 +                            throw new InvalidRequestException("Cannot use non-frozen collections in COMPACT STORAGE tables");
 +                        if (cfm.isSuper())
 +                            throw new InvalidRequestException("Cannot use non-frozen collections with super column families");
+                     }
  
-                         // If there used to be a non-frozen collection column with the same name (that has been dropped),
-                         // we could still have some data using the old type, and so we can't allow adding a collection
-                         // with the same name unless the types are compatible (see #6276).
-                         CFMetaData.DroppedColumn dropped = cfm.getDroppedColumns().get(columnName.bytes);
-                         if (dropped != null && dropped.type instanceof CollectionType
-                             && dropped.type.isMultiCell() && !type.isCompatibleWith(dropped.type))
 -                    // Cannot re-add a dropped counter column. See #7831.
 -                    if (meta.isCounter())
 -                        throw new InvalidRequestException(String.format("Cannot re-add previously dropped counter column %s", columnName));
 -                }
++                    CFMetaData.DroppedColumn droppedColumn = meta.getDroppedColumns().get(columnName.bytes);
++                    if (null != droppedColumn)
++                    {
++                        // After #8099, not safe to re-add columns of incompatible types - until *maybe* deser logic with dropped
++                        // columns is pushed deeper down the line. The latter would still be problematic in cases of schema races.
++                        if (!type.isValueCompatibleWith(droppedColumn.type))
 +                        {
 +                            String message =
-                                 String.format("Cannot add a collection with the name %s because a collection with the same name"
-                                               + " and a different type (%s) has already been used in the past",
++                                String.format("Cannot re-add previously dropped column '%s' of type %s, incompatible with previous type %s",
 +                                              columnName,
-                                               dropped.type.asCQL3Type());
++                                              type.asCQL3Type(),
++                                              droppedColumn.type.asCQL3Type());
 +                            throw new InvalidRequestException(message);
 +                        }
+ 
 -                cfm.addColumnDefinition(isStatic
 -                                        ? ColumnDefinition.staticDef(cfm, columnName.bytes, type)
 -                                        : ColumnDefinition.regularDef(cfm, columnName.bytes, type));
++                        // Cannot re-add a dropped counter column. See #7831.
++                        if (meta.isCounter())
++                            throw new InvalidRequestException(String.format("Cannot re-add previously dropped counter column %s", columnName));
 +                    }
  
 -                // Adding a column to a table which has an include all view requires the column to be added to the view
 -                // as well
 -                if (!isStatic)
 -                {
 -                    for (ViewDefinition view : views)
 +                    cfm.addColumnDefinition(isStatic
 +                                            ? ColumnDefinition.staticDef(cfm, columnName.bytes, type)
 +                                            : ColumnDefinition.regularDef(cfm, columnName.bytes, type));
 +
 +                    // Adding a column to a table which has an include all view requires the column to be added to the view
 +                    // as well
 +                    if (!isStatic)
                      {
 -                        if (view.includeAllColumns)
 +                        for (ViewDefinition view : views)
                          {
 -                            ViewDefinition viewCopy = view.copy();
 -                            viewCopy.metadata.addColumnDefinition(ColumnDefinition.regularDef(viewCopy.metadata, columnName.bytes, type));
 -                            if (viewUpdates == null)
 -                                viewUpdates = new ArrayList<>();
 -                            viewUpdates.add(viewCopy);
 +                            if (view.includeAllColumns)
 +                            {
 +                                ViewDefinition viewCopy = view.copy();
 +                                viewCopy.metadata.addColumnDefinition(ColumnDefinition.regularDef(viewCopy.metadata, columnName.bytes, type));
 +                                if (viewUpdates == null)
 +                                    viewUpdates = new ArrayList<>();
 +                                viewUpdates.add(viewCopy);
 +                            }
                          }
                      }
                  }
diff --cc test/unit/org/apache/cassandra/db/LegacyLayoutTest.java
index 87de227,580a0e7..a119b29
--- a/test/unit/org/apache/cassandra/db/LegacyLayoutTest.java
+++ b/test/unit/org/apache/cassandra/db/LegacyLayoutTest.java
@@@ -330,7 -318,7 +330,7 @@@ public class LegacyLayoutTes
           }
           */
  
--        DatabaseDescriptor.setDaemonInitialized();
++        DatabaseDescriptor.daemonInitialization();
          Keyspace.setInitialized();
          CFMetaData table = CFMetaData.Builder.create("ks", "cf")
                                               .addPartitionKey("k", Int32Type.instance)


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