Updated Branches: refs/heads/cassandra-2.0 c1cc50f69 -> e7c96c438 refs/heads/trunk 29605aedd -> 873ce0cb3
clarify error messages for zero/multiple PKs patch by Lyben Todorov; reviewed by jbellis for CASSANDRA-5875 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e7c96c43 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e7c96c43 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e7c96c43 Branch: refs/heads/cassandra-2.0 Commit: e7c96c438ca9d4ac43030306127a8698659ac033 Parents: c1cc50f Author: Jonathan Ellis <jbel...@apache.org> Authored: Wed Aug 14 21:07:18 2013 -0500 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Wed Aug 14 21:07:27 2013 -0500 ---------------------------------------------------------------------- .../apache/cassandra/cql3/statements/CreateTableStatement.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/e7c96c43/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java index 4037f40..a220366 100644 --- a/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java @@ -212,8 +212,10 @@ public class CreateTableStatement extends SchemaAlteringStatement stmt.columns.put(id, pt.getType()); // we'll remove what is not a column below } - if (keyAliases.size() != 1) - throw new InvalidRequestException("You must specify one and only one PRIMARY KEY"); + if (keyAliases.isEmpty()) + throw new InvalidRequestException("No PRIMARY KEY specifed (exactly one required)"); + else if (keyAliases.size() > 1) + throw new InvalidRequestException("Multiple PRIMARY KEYs specifed (exactly one required)"); List<ColumnIdentifier> kAliases = keyAliases.get(0);