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 2013/01/08 09:49:39 UTC
[1/2] git commit: Fix exception when adding collection to table
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/trunk
Commit: 8349fcebfbba24f37f10e03e7580f0c062ca9de0
Parents: 4460e28
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Tue Jan 8 09:48:21 2013 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
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,