cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Disallow incompatible type change in CQL3
Date Mon, 26 Aug 2013 16:00:59 GMT
Updated Branches:
  refs/heads/cassandra-1.2 775dcbb50 -> a606c6c5e


Disallow incompatible type change in CQL3

patch by slebresne; reviewed by iamaleksey for CASSANDRA-5882


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

Branch: refs/heads/cassandra-1.2
Commit: a606c6c5ed25ddb87ffc3f6ca5dfa18d34a46a25
Parents: 775dcbb
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Aug 21 16:09:20 2013 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Aug 26 18:00:00 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../cql3/statements/AlterTableStatement.java         | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a606c6c5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4246c30..afb0836 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -28,6 +28,7 @@
  * Fix LCS L0 compaction may overlap in L1 (CASSANDRA-5907)
  * New sstablesplit tool to split large sstables offline (CASSANDRA-4766)
  * Fix potential deadlock in native protocol server (CASSANDRA-5926)
+ * Disallow incompatible type change in CQL3 (CASSANDRA-5882)
 Merged from 1.1:
  * Correctly validate sparse composite cells in scrub (CASSANDRA-5855)
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a606c6c5/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 c6af2a0..a247a4d 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -150,10 +150,25 @@ public class AlterTableStatement extends SchemaAlteringStatement
                         cfm.comparator = CompositeType.getInstance(newTypes);
                         break;
                     case VALUE_ALIAS:
+                        // See below
+                        if (!validator.getType().isCompatibleWith(cfm.getDefaultValidator()))
+                            throw new ConfigurationException(String.format("Cannot change
%s from type %s to type %s: types are incompatible.",
+                                                                           columnName,
+                                                                           cfm.getDefaultValidator().asCQL3Type(),
+                                                                           validator));
                         cfm.defaultValidator(validator.getType());
                         break;
                     case COLUMN_METADATA:
                         ColumnDefinition column = cfm.getColumnDefinition(columnName.key);
+                        // Thrift allows to change a column validator so CFMetaData.validateCompatility
will let it slide
+                        // if we change to an incompatible type (contrarily to the comparator
case). But we don't want to
+                        // allow it for CQL3 (see #5882) so validating it explicitly here
+                        if (!validator.getType().isCompatibleWith(column.getValidator()))
+                            throw new ConfigurationException(String.format("Cannot change
%s from type %s to type %s: types are incompatible.",
+                                                                           columnName,
+                                                                           column.getValidator().asCQL3Type(),
+                                                                           validator));
+
                         column.setValidator(validator.getType());
                         cfm.addColumnDefinition(column);
                         break;


Mime
View raw message