Updated Branches: refs/heads/trunk e431fb722 -> 2f3f620ed
Fix counter updates broken by 5443 patch Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2f3f620e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2f3f620e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2f3f620e Branch: refs/heads/trunk Commit: 2f3f620ed1bdd1bbcf5564b75885b9aaf02c0359 Parents: e431fb7 Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Tue Apr 30 14:46:37 2013 +0200 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Tue Apr 30 14:46:37 2013 +0200 ---------------------------------------------------------------------- .../cql3/statements/ModificationStatement.java | 84 ++++++++------- 1 files changed, 43 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2f3f620e/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java index 542b6d6..7ca0000 100644 --- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java @@ -476,54 +476,56 @@ public abstract class ModificationStatement implements CQLStatement ModificationStatement stmt = prepareInternal(cfDef, boundNames); - if (stmt.isCounter()) - throw new InvalidRequestException("Conditional updates are not supported on counter tables"); - - if (ifNotExists) - { - // To have both 'IF NOT EXISTS' and some other conditions doesn't make sense. - // So far this is enforced by the parser, but let's assert it for sanity if ever the parse changes. - assert conditions.isEmpty(); - stmt.setIfNotExistCondition(); - } - else + if (stmt.hasConditions()) { - for (Pair<ColumnIdentifier, Operation.RawUpdate> entry : conditions) - { - CFDefinition.Name name = cfDef.get(entry.left); - if (name == null) - throw new InvalidRequestException(String.format("Unknown identifier %s", entry.left)); - - /* - * Lists column names are based on a server-side generated timeuuid. So we can't allow lists - * operation or that would yield unexpected results (update that should apply wouldn't). So for - * now, we just refuse lists, which also save use from having to bother about the read that some - * list operation involve. - */ - if (name.type instanceof ListType) - throw new InvalidRequestException(String.format("List operation (%s) are not allowed in conditional updates", name)); + if (stmt.isCounter()) + throw new InvalidRequestException("Conditional updates are not supported on counter tables"); - Operation condition = entry.right.prepare(name); - assert !condition.requiresRead(); + if (attrs.timestamp != null) + throw new InvalidRequestException("Cannot provide custom timestamp for conditional update"); - condition.collectMarkerSpecification(boundNames); - - switch (name.kind) + if (ifNotExists) + { + // To have both 'IF NOT EXISTS' and some other conditions doesn't make sense. + // So far this is enforced by the parser, but let's assert it for sanity if ever the parse changes. + assert conditions.isEmpty(); + stmt.setIfNotExistCondition(); + } + else + { + for (Pair<ColumnIdentifier, Operation.RawUpdate> entry : conditions) { - case KEY_ALIAS: - case COLUMN_ALIAS: - throw new InvalidRequestException(String.format("PRIMARY KEY part %s found in SET part", entry.left)); - case VALUE_ALIAS: - case COLUMN_METADATA: - stmt.addCondition(condition); - break; + CFDefinition.Name name = cfDef.get(entry.left); + if (name == null) + throw new InvalidRequestException(String.format("Unknown identifier %s", entry.left)); + + /* + * Lists column names are based on a server-side generated timeuuid. So we can't allow lists + * operation or that would yield unexpected results (update that should apply wouldn't). So for + * now, we just refuse lists, which also save use from having to bother about the read that some + * list operation involve. + */ + if (name.type instanceof ListType) + throw new InvalidRequestException(String.format("List operation (%s) are not allowed in conditional updates", name)); + + Operation condition = entry.right.prepare(name); + assert !condition.requiresRead(); + + condition.collectMarkerSpecification(boundNames); + + switch (name.kind) + { + case KEY_ALIAS: + case COLUMN_ALIAS: + throw new InvalidRequestException(String.format("PRIMARY KEY part %s found in SET part", entry.left)); + case VALUE_ALIAS: + case COLUMN_METADATA: + stmt.addCondition(condition); + break; + } } } } - - if (stmt.hasConditions() && attrs.timestamp != null) - throw new InvalidRequestException("Cannot provide custom timestamp for conditional update"); - return stmt; }