cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Forbid compact clustering column type changes in ALTER TABLE
Date Tue, 17 Nov 2015 16:44:57 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 a8e8a6730 -> 5414950d6


Forbid compact clustering column type changes in ALTER TABLE

patch by Aleksey Yeschenko; reviewed by Sylvain Lebresne for
CASSANDRA-8879


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

Branch: refs/heads/cassandra-2.1
Commit: 5414950d6a42a2f7d41dec6427cbf210dd7d99af
Parents: a8e8a67
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Nov 11 18:45:50 2015 +0000
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Nov 17 16:44:37 2015 +0000

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 .../cassandra/cql3/statements/AlterTableStatement.java       | 3 +++
 .../cassandra/cql3/validation/operations/AlterTest.java      | 8 ++++++++
 3 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5414950d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b6b394a..eea14c8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.12
+ * Forbid compact clustering column type changes in ALTER TABLE (CASSANDRA-8879)
  * Reject incremental repair with subrange repair (CASSANDRA-10422)
  * Add a nodetool command to refresh size_estimates (CASSANDRA-9579)
  * Shutdown compaction in drain to prevent leak (CASSANDRA-10079)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5414950d/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index 9d07459..44bc2bc 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -182,6 +182,9 @@ public class AlterTableStatement extends SchemaAlteringStatement
                         }
                         break;
                     case CLUSTERING_COLUMN:
+                        if (!cfm.isCQL3Table())
+                            throw new InvalidRequestException(String.format("Cannot alter
clustering column %s in a non-CQL3 table", columnName));
+
                         AbstractType<?> oldType = cfm.comparator.subtype(def.position());
                         // Note that CFMetaData.validateCompatibility already validate the
change we're about to do. However, the error message it
                         // sends is a bit cryptic for a CQL3 user, so validating here for
a sake of returning a better error message

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5414950d/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
index cc7d2a4..a6aad87 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
@@ -21,6 +21,7 @@ import org.apache.cassandra.cql3.CQLTester;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.Keyspace;
 import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.SyntaxException;
 
 import org.junit.Test;
@@ -198,4 +199,11 @@ public class AlterTest extends CQLTester
             assertInvalidSyntaxMessage("no viable alternative at input 'WITH'", stmt);
         }
     }
+
+    @Test // tests CASSANDRA-8879
+    public void testAlterClusteringColumnTypeInCompactTable() throws Throwable
+    {
+        createTable("CREATE TABLE %s (key blob, column1 blob, value blob, PRIMARY KEY ((key),
column1)) WITH COMPACT STORAGE");
+        assertInvalidThrow(InvalidRequestException.class, "ALTER TABLE %s ALTER column1 TYPE
ascii");
+    }
 }


Mime
View raw message