You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/11/26 10:24:39 UTC

[2/2] git commit: Fix adding columns when table has collections

Fix adding columns when table has collections

patch by slebresne; reviewed by dbrosius for CASSANDRA-4982


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

Branch: refs/heads/cassandra-1.2.0
Commit: 3a097ccff5420cdb3aa853e3cbc272b2187ebd8a
Parents: 64bc335
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Mon Nov 26 10:21:55 2012 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Mon Nov 26 10:21:55 2012 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cql3/statements/AlterTableStatement.java       |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a097ccf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4ea42c1..5ce19d0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,7 @@
  * Fix Stress for CQL3 (CASSANDRA-4979)
  * Remove cassandra specific exceptions from JMX interface (CASSANDRA-4893)
  * (CQL3) Force using ALLOW FILTERING on potentially inefficient queries (CASSANDRA-4915)
+ * Fix adding column when the table has collections (CASSANDRA-4982)
 Merged from 1.1:
  * add basic authentication support for Pig CassandraStorage (CASSANDRA-3042)
  * fix CQL2 ALTER TABLE compaction_strategy_class altering (CASSANDRA-4965)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a097ccf/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 631ed75..ee8c987 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -99,6 +99,7 @@ public class AlterTableStatement extends SchemaAlteringStatement
                     Map<ByteBuffer, CollectionType> collections = cfDef.hasCollections
                                                                 ? new HashMap<ByteBuffer, CollectionType>(cfDef.getCollectionType().defined)
                                                                 : new HashMap<ByteBuffer, CollectionType>();
+
                     collections.put(columnName.key, (CollectionType)type);
                     ColumnToCollectionType newColType = ColumnToCollectionType.getInstance(collections);
                     List<AbstractType<?>> ctypes = new ArrayList<AbstractType<?>>(((CompositeType)cfm.comparator).types);
@@ -108,6 +109,11 @@ public class AlterTableStatement extends SchemaAlteringStatement
                         ctypes.add(newColType);
                     cfm.comparator = CompositeType.getInstance(ctypes);
                 }
+                else if (cfDef.hasCollections)
+                {
+                    componentIndex--;
+                }
+
                 cfm.addColumnDefinition(new ColumnDefinition(columnName.key,
                                                              type,
                                                              null,