cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/6] cassandra git commit: Properly pass CellPath when setting list element to null
Date Tue, 12 Jan 2016 15:52:19 GMT
Properly pass CellPath when setting list element to null

patch by slebresne; reviewed by blerer for CASSANDRA-10954


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4c7b06b0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4c7b06b0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4c7b06b0

Branch: refs/heads/cassandra-3.3
Commit: 4c7b06b0a87f88bfaff5d55e6b302a25e0391f57
Parents: f4037f9
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Jan 4 15:11:16 2016 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Jan 12 16:50:04 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/cql3/Lists.java           |  2 +-
 .../cql3/validation/entities/CollectionsTest.java       | 12 ++++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c7b06b0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index da5ed26..6daf7f9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.3
+ * Fix AssertionError when removing from list using UPDATE (CASSANDRA-10954)
  * Fix UnsupportedOperationException when reading old sstable with range
    tombstone (CASSANDRA-10743)
  * MV should use the maximum timestamp of the primary key (CASSANDRA-10910)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c7b06b0/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Lists.java b/src/java/org/apache/cassandra/cql3/Lists.java
index 4b41a9d..18b382b 100644
--- a/src/java/org/apache/cassandra/cql3/Lists.java
+++ b/src/java/org/apache/cassandra/cql3/Lists.java
@@ -359,7 +359,7 @@ public abstract class Lists
             CellPath elementPath = existingRow.getComplexColumnData(column).getCellByIndex(idx).path();
             if (value == null)
             {
-                params.addTombstone(column);
+                params.addTombstone(column, elementPath);
             }
             else if (value != ByteBufferUtil.UNSET_BYTE_BUFFER)
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c7b06b0/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
index 48e5ad3..a0a6e73 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@ -852,4 +852,16 @@ public class CollectionsTest extends CQLTester
 
         assertRows(execute("SELECT s FROM %s WHERE k = 0"), row(set(largeText, "v2")));
     }
+
+    @Test
+    public void testRemovalThroughUpdate() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<int>)");
+
+         execute("INSERT INTO %s(k, l) VALUES(?, ?)", 0, list(1, 2, 3));
+         assertRows(execute("SELECT * FROM %s"), row(0, list(1, 2, 3)));
+
+         execute("UPDATE %s SET l[0] = null WHERE k=0");
+         assertRows(execute("SELECT * FROM %s"), row(0, list(2, 3)));
+    }
 }


Mime
View raw message