Repository: cassandra Updated Branches: refs/heads/trunk db6b563f1 -> 21c7252d6
Fix UPDATE updating PRIMARY KEY columns implicitely patch by slebresne; reviewed by iamaleksey for CASSANDRA-6782 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6137b381 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6137b381 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6137b381 Branch: refs/heads/trunk Commit: 6137b381d2d619ff094395ea32cc4730b9969682 Parents: ef20671 Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Tue Mar 4 11:16:37 2014 +0100 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Tue Mar 4 11:16:37 2014 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/cql3/statements/UpdateStatement.java | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/6137b381/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 6de11c5..41c89e1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,6 +29,7 @@ * Fix potential paging bug with deleted columns (CASSANDRA-6748) * Fix NPE on BulkLoader caused by losing StreamEvent (CASSANDRA-6636) * Fix truncating compression metadata (CASSANDRA-6791) + * Fix UPDATE updating PRIMARY KEY columns implicitly (CASSANDRA-6782) Merged from 1.2: * Add CMSClassUnloadingEnabled JVM option (CASSANDRA-6541) * Catch memtable flush exceptions during shutdown (CASSANDRA-6735) http://git-wip-us.apache.org/repos/asf/cassandra/blob/6137b381/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java index dcf22ef..fc9bb66 100644 --- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java @@ -51,17 +51,19 @@ public class UpdateStatement extends ModificationStatement CFDefinition cfDef = cfm.getCfDef(); // Inserting the CQL row marker (see #4361) - // We always need to insert a marker, because of the following situation: + // We always need to insert a marker for INSERT, because of the following situation: // CREATE TABLE t ( k int PRIMARY KEY, c text ); // INSERT INTO t(k, c) VALUES (1, 1) // DELETE c FROM t WHERE k = 1; // SELECT * FROM t; - // The last query should return one row (but with c == null). Adding - // the marker with the insert make sure the semantic is correct (while making sure a - // 'DELETE FROM t WHERE k = 1' does remove the row entirely) + // The last query should return one row (but with c == null). Adding the marker with the insert make sure + // the semantic is correct (while making sure a 'DELETE FROM t WHERE k = 1' does remove the row entirely) + // + // We do not insert the marker for UPDATE however, as this amount to updating the columns in the WHERE + // clause which is inintuitive (#6782) // // We never insert markers for Super CF as this would confuse the thrift side. - if (cfDef.isComposite && !cfDef.isCompact && !cfm.isSuper()) + if (type == StatementType.INSERT && cfDef.isComposite && !cfDef.isCompact && !cfm.isSuper()) { ByteBuffer name = builder.copy().add(ByteBufferUtil.EMPTY_BYTE_BUFFER).build(); cf.addColumn(params.makeColumn(name, ByteBufferUtil.EMPTY_BYTE_BUFFER));