Updated Branches: refs/heads/cassandra-1.2 4460e2865 -> 8349fcebf
Fix exception when adding collection to table patch by slebresne; reviewed by dbrosius for CASSANDRA-5117 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8349fceb Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8349fceb Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8349fceb Branch: refs/heads/cassandra-1.2 Commit: 8349fcebfbba24f37f10e03e7580f0c062ca9de0 Parents: 4460e28 Author: Sylvain Lebresne <[email protected]> Authored: Tue Jan 8 09:48:21 2013 +0100 Committer: Sylvain Lebresne <[email protected]> Committed: Tue Jan 8 09:48:21 2013 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cql3/statements/AlterTableStatement.java | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8349fceb/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index e038599..733c3a3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,6 +23,7 @@ * Correctly gossip with nodes >= 1.1.7 (CASSANDRA-5102) * Ensure CL guarantees on digest mismatch (CASSANDRA-5113) * Validate correctly selects on composite partition key (CASSANDRA-5122) + * Fix exception when adding collection (CASSANDRA-5117) Merged from 1.1: * Pig: correctly decode row keys in widerow mode (CASSANDRA-5098) http://git-wip-us.apache.org/repos/asf/cassandra/blob/8349fceb/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 ee8c987..7381895 100644 --- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java @@ -87,15 +87,12 @@ public class AlterTableStatement extends SchemaAlteringStatement } } - Integer componentIndex = cfDef.isComposite ? ((CompositeType)meta.comparator).types.size() - 1 : null; AbstractType<?> type = validator.getType(); if (type instanceof CollectionType) { if (!cfDef.isComposite) throw new InvalidRequestException("Cannot use collection types with non-composite PRIMARY KEY"); - componentIndex--; - Map<ByteBuffer, CollectionType> collections = cfDef.hasCollections ? new HashMap<ByteBuffer, CollectionType>(cfDef.getCollectionType().defined) : new HashMap<ByteBuffer, CollectionType>(); @@ -109,11 +106,10 @@ public class AlterTableStatement extends SchemaAlteringStatement ctypes.add(newColType); cfm.comparator = CompositeType.getInstance(ctypes); } - else if (cfDef.hasCollections) - { - componentIndex--; - } + Integer componentIndex = cfDef.isComposite + ? ((CompositeType)meta.comparator).types.size() - (cfDef.hasCollections ? 2 : 1) + : null; cfm.addColumnDefinition(new ColumnDefinition(columnName.key, type, null,
