cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Better error message when trying to add a collection with the same name than a previously dropped one
Date Mon, 11 Aug 2014 16:12:27 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 73b02d67c -> bd0bb6df4


Better error message when trying to add a collection with the same name than a previously
dropped one


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

Branch: refs/heads/cassandra-2.0
Commit: bd0bb6df4613588967ab0c67c268a231c112b321
Parents: 73b02d6
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Aug 11 18:07:35 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Mon Aug 11 18:07:35 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                  | 2 ++
 .../cassandra/cql3/statements/AlterTableStatement.java       | 8 ++++++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd0bb6df/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4a3e086..cd51e04 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Better error message when adding a collection with the same name
+   than a previously dropped one (CASSANDRA-6276)
  * Fix validation when adding static columns (CASSANDRA-7730)
  * (Thrift) fix range deletion of supercolumns (CASSANDRA-7733)
  * Fix potential AssertionError in RangeTombstoneList (CASSANDRA-7700)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd0bb6df/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 88f0de8..136c430 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -121,6 +121,14 @@ public class AlterTableStatement extends SchemaAlteringStatement
                                                                 ? new HashMap<ByteBuffer,
CollectionType>(cfDef.getCollectionType().defined)
                                                                 : new HashMap<ByteBuffer,
CollectionType>();
 
+                    // If there used to be a collection column with the same name (that has
been dropped), it will
+                    // still be appear in the ColumnToCollectionType because or reasons explained
on #6276. The same
+                    // reason mean that we can't allow adding a new collection with that
name (see the ticket for details).
+                    CollectionType previous = collections.get(columnName.key);
+                    if (previous != null && !type.isCompatibleWith(previous))
+                        throw new InvalidRequestException(String.format("Cannot add a collection
with the name %s " +
+                                    "because a collection with the same name and a different
type has already been used in the past", columnName));
+
                     collections.put(columnName.key, (CollectionType)type);
                     ColumnToCollectionType newColType = ColumnToCollectionType.getInstance(collections);
                     List<AbstractType<?>> ctypes = new ArrayList<AbstractType<?>>(((CompositeType)cfm.comparator).types);


Mime
View raw message