Repository: cassandra Updated Branches: refs/heads/trunk a4e8e1656 -> 4e4761ccb
Reject counters inside user types patch by Aleksey Yeschenko; tested by Russ Hatch; reviewed by Jonathan Ellis for CASSANDRA-7672 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/fb3995ae Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/fb3995ae Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/fb3995ae Branch: refs/heads/trunk Commit: fb3995ae13683de598624f2d689e1fb2d88d51bf Parents: 85b7438 Author: Aleksey Yeschenko <alek...@apache.org> Authored: Sat Aug 2 13:40:00 2014 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Sat Aug 2 13:40:00 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/cql3/statements/CreateTypeStatement.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/fb3995ae/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index f4b3921..eaa3b43 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.0-final + * Reject counters inside user types (CASSANDRA-7672) * Switch to notification-based GCInspector (CASSANDRA-7638) * (cqlsh) Handle nulls in UDTs and tuples correctly (CASSANDRA-7656) * Don't use strict consistency when replacing (CASSANDRA-7568) http://git-wip-us.apache.org/repos/asf/cassandra/blob/fb3995ae/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java index 1ddc8e6..5224474 100644 --- a/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java @@ -68,8 +68,13 @@ public class CreateTypeStatement extends SchemaAlteringStatement KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace()); if (ksm == null) throw new InvalidRequestException(String.format("Cannot add type in unknown keyspace %s", name.getKeyspace())); + if (ksm.userTypes.getType(name.getUserTypeName()) != null && !ifNotExists) - throw new InvalidRequestException(String.format("A user type of name %s already exists.", name)); + throw new InvalidRequestException(String.format("A user type of name %s already exists", name)); + + for (CQL3Type.Raw type : columnTypes) + if (type.isCounter()) + throw new InvalidRequestException("A user type cannot contain counters"); } public static void checkForDuplicateNames(UserType type) throws InvalidRequestException