You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2020/06/04 18:18:15 UTC

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

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

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

commit 056c9eff4b0311d9bde526e0bc9f39e5fad21e39
Merge: ebfd052 c4064dd
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Thu Jun 4 20:17:31 2020 +0200

    Merge branch 'cassandra-3.0' into cassandra-3.11

 .../org/apache/cassandra/config/CFMetaData.java    |  21 ++++++++++++
 .../cql3/statements/AlterTableStatement.java       |  30 ++++++++++++++++-
 .../apache/cassandra/db/marshal/AbstractType.java  |  12 +++++--
 .../cassandra/schema/LegacySchemaMigrator.java     |   9 +++--
 .../cassandra/serializers/EmptySerializer.java     |   6 +++-
 ..._dense_table_with_bytes-ka-1-CompressionInfo.db | Bin 0 -> 43 bytes
 ...cql_created_dense_table_with_bytes-ka-1-Data.db | Bin 0 -> 56 bytes
 ...created_dense_table_with_bytes-ka-1-Digest.sha1 |   1 +
 ...l_created_dense_table_with_bytes-ka-1-Filter.db | Bin 0 -> 16 bytes
 ...ql_created_dense_table_with_bytes-ka-1-Index.db | Bin 0 -> 19 bytes
 ...eated_dense_table_with_bytes-ka-1-Statistics.db | Bin 0 -> 4450 bytes
 ..._created_dense_table_with_bytes-ka-1-Summary.db | Bin 0 -> 95 bytes
 ...cql_created_dense_table_with_bytes-ka-1-TOC.txt |   8 +++++
 ...ed_dense_table_with_int-ka-1-CompressionInfo.db | Bin 0 -> 43 bytes
 ...a_cql_created_dense_table_with_int-ka-1-Data.db | Bin 0 -> 49 bytes
 ...l_created_dense_table_with_int-ka-1-Digest.sha1 |   1 +
 ...cql_created_dense_table_with_int-ka-1-Filter.db | Bin 0 -> 16 bytes
 ..._cql_created_dense_table_with_int-ka-1-Index.db | Bin 0 -> 19 bytes
 ...created_dense_table_with_int-ka-1-Statistics.db | Bin 0 -> 4450 bytes
 ...ql_created_dense_table_with_int-ka-1-Summary.db | Bin 0 -> 95 bytes
 ...a_cql_created_dense_table_with_int-ka-1-TOC.txt |   8 +++++
 .../cql3/validation/operations/AlterTest.java      |  22 ++++++++++++
 test/unit/org/apache/cassandra/db/ScrubTest.java   |   3 +-
 .../apache/cassandra/db/marshal/EmptyTypeTest.java |   2 +-
 .../cassandra/io/sstable/LegacySSTableTest.java    |  37 +++++++++++++++++++++
 25 files changed, 151 insertions(+), 9 deletions(-)

diff --cc src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index 5017fe3,193c24c..3e0674a
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@@ -97,8 -111,28 +99,34 @@@ public class AlterTableStatement extend
          switch (oType)
          {
              case ALTER:
-                 throw new InvalidRequestException("Altering of types is not allowed");
 -                // We do not support altering of types and only allow this to for people who have already one
 -                // through the upgrade of 2.x CQL-created SSTables with Thrift writes, affected by CASSANDRA-15778.
 -                if (meta.isDense()
 -                    && meta.compactValueColumn().equals(def)
 -                    && meta.compactValueColumn().type instanceof EmptyType
 -                    && validator != null)
++                cfm = null;
++                for (AlterTableStatementColumn colData : colNameList)
+                 {
 -                    if (validator.getType() instanceof BytesType)
++                    columnName = colData.getColumnName().getIdentifier(meta);
++                    def = meta.getColumnDefinition(columnName);
++                    dataType = colData.getColumnType();
++                    validator = dataType.prepare(keyspace());
++
++                    // We do not support altering of types and only allow this to for people who have already one
++                    // through the upgrade of 2.x CQL-created SSTables with Thrift writes, affected by CASSANDRA-15778.
++                    if (meta.isDense()
++                        && meta.compactValueColumn().equals(def)
++                        && meta.compactValueColumn().type instanceof EmptyType
++                        && validator != null)
+                     {
 -                        cfm = meta.copyWithNewCompactValueType(validator.getType());
 -                        break;
++                        if (validator.getType() instanceof BytesType)
++                            cfm = meta.copyWithNewCompactValueType(validator.getType());
++                        else
++                            throw new InvalidRequestException(String.format("Compact value type can only be changed to BytesType, but %s was given.",
++                                                                            validator.getType()));
+                     }
 -
 -                    throw new InvalidRequestException(String.format("Compact value type can only be changed to BytesType, but %s was given.",
 -                                                                    validator.getType()));
+                 }
 -                else
 -                {
++
++                if (cfm == null)
+                     throw new InvalidRequestException("Altering of types is not allowed");
 -                }
++                else
++                    break;
              case ADD:
 -                assert columnName != null;
                  if (meta.isDense())
                      throw new InvalidRequestException("Cannot add new column to a COMPACT STORAGE table");
  


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