You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2016/12/12 12:53:33 UTC
[1/4] cassandra git commit: Test bind parameters and unset parameters
in InsertUpdateIfConditionTest
Repository: cassandra
Updated Branches:
refs/heads/cassandra-3.X 84b2e73c6 -> 8883554a1
Test bind parameters and unset parameters in InsertUpdateIfConditionTest
patch by Benjamin Lerer; reviewed by Alex Petrov for CASSANDRA-12980
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9a5aef09
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9a5aef09
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9a5aef09
Branch: refs/heads/cassandra-3.X
Commit: 9a5aef09fe51592713d0fa38bfb9e42e21e7644d
Parents: dd41526
Author: Benjamin Lerer <b....@gmail.com>
Authored: Mon Dec 12 12:52:18 2016 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Mon Dec 12 12:52:18 2016 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../operations/InsertUpdateIfConditionTest.java | 147 ++++++++++++-------
2 files changed, 91 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a5aef09/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6b2a9c0..134a37d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.2.9
+ * Test bind parameters and unset parameters in InsertUpdateIfConditionTest (CASSANDRA-12980)
* Do not specify local address on outgoing connection when listen_on_broadcast_address is set (CASSANDRA-12673)
* Use saved tokens when setting local tokens on StorageService.joinRing (CASSANDRA-12935)
* cqlsh: fix DESC TYPES errors (CASSANDRA-12914)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a5aef09/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index fc6cc2e..4a209e6 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@ -41,8 +41,8 @@ public class InsertUpdateIfConditionTest extends CQLTester
{
execute("INSERT INTO %s (tkn, consumed) VALUES (?, FALSE)", i);
- assertRows(execute("UPDATE %s SET consumed = TRUE WHERE tkn = ? IF consumed = FALSE", i), row(true));
- assertRows(execute("UPDATE %s SET consumed = TRUE WHERE tkn = ? IF consumed = FALSE", i), row(false, true));
+ assertRows(execute("UPDATE %s SET consumed = TRUE WHERE tkn = ? IF consumed = ?", i, false), row(true));
+ assertRows(execute("UPDATE %s SET consumed = TRUE WHERE tkn = ? IF consumed = ?", i, false), row(false, true));
}
}
@@ -54,8 +54,11 @@ public class InsertUpdateIfConditionTest extends CQLTester
{
createTable(" CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 text, v3 int)");
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 = ?", unset());
+
// Shouldn't apply
- assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 = 4"), row(false));
+ assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 = ?", 4), row(false));
assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF EXISTS"), row(false));
// Should apply
@@ -66,50 +69,50 @@ public class InsertUpdateIfConditionTest extends CQLTester
assertRows(execute("SELECT * FROM %s"), row(0, 2, "foo", null));
// Shouldn't apply
- assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 = 4"), row(false, 2));
+ assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 = ?", 4), row(false, 2));
assertRows(execute("SELECT * FROM %s"), row(0, 2, "foo", null));
// Should apply (note: we want v2 before v1 in the statement order to exercise #5786)
- assertRows(execute("UPDATE %s SET v2 = 'bar', v1 = 3 WHERE k = 0 IF v1 = 2"), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar', v1 = 3 WHERE k = 0 IF v1 = ?", 2), row(true));
assertRows(execute("UPDATE %s SET v2 = 'bar', v1 = 3 WHERE k = 0 IF EXISTS"), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, 3, "bar", null));
// Shouldn't apply, only one condition is ok
- assertRows(execute("UPDATE %s SET v1 = 5, v2 = 'foobar' WHERE k = 0 IF v1 = 3 AND v2 = 'foo'"), row(false, 3, "bar"));
+ assertRows(execute("UPDATE %s SET v1 = 5, v2 = 'foobar' WHERE k = 0 IF v1 = ? AND v2 = ?", 3, "foo"), row(false, 3, "bar"));
assertRows(execute("SELECT * FROM %s"), row(0, 3, "bar", null));
// Should apply
- assertRows(execute("UPDATE %s SET v1 = 5, v2 = 'foobar' WHERE k = 0 IF v1 = 3 AND v2 = 'bar'"), row(true));
+ assertRows(execute("UPDATE %s SET v1 = 5, v2 = 'foobar' WHERE k = 0 IF v1 = ? AND v2 = ?", 3, "bar"), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, 5, "foobar", null));
// Shouldn't apply
- assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = 3"), row(false, 5));
+ assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = ?", 3), row(false, 5));
assertRows(execute("SELECT * FROM %s"), row(0, 5, "foobar", null));
// Shouldn't apply
- assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = null"), row(false, 5));
+ assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = ?", (Integer) null), row(false, 5));
assertRows(execute("SELECT * FROM %s"), row(0, 5, "foobar", null));
// Should apply
- assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = 5"), row(true));
+ assertRows(execute("DELETE v2 FROM %s WHERE k = 0 IF v1 = ?", 5), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, 5, null, null));
// Shouln't apply
- assertRows(execute("DELETE v1 FROM %s WHERE k = 0 IF v3 = 4"), row(false, null));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 0 IF v3 = ?", 4), row(false, null));
// Should apply
- assertRows(execute("DELETE v1 FROM %s WHERE k = 0 IF v3 = null"), row(true));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 0 IF v3 = ?", (Integer) null), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, null, null, null));
// Should apply
- assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 = null"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 = ?", (Integer) null), row(true));
assertEmpty(execute("SELECT * FROM %s"));
// Shouldn't apply
assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF EXISTS"), row(false));
// Should apply
- assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 IN (null)"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 IN (?)", (Integer) null), row(true));
}
/**
@@ -123,15 +126,28 @@ public class InsertUpdateIfConditionTest extends CQLTester
// non-EQ conditions
execute("INSERT INTO %s (k, v1, v2) VALUES (0, 2, 'foo')");
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 < 3"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 <= 3"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 > 1"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 >= 1"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 != 1"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 != 2"), row(false, 2));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 IN (0, 1, 2)"), row(true));
- assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 IN (142, 276)"), row(false, 2));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 < ?", 3), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 <= ?", 3), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 > ?", 1), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 >= ?", 1), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 != ?", 1), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 != ?", 2), row(false, 2));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 IN (?, ?, ?)", 0, 1, 2), row(true));
+ assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 IN ?", list(142, 276)), row(false, 2));
assertRows(execute("UPDATE %s SET v2 = 'bar' WHERE k = 0 IF v1 IN ()"), row(false, 2));
+
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 < ?", unset());
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 <= ?", unset());
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 > ?", unset());
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 >= ?", unset());
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 != ?", unset());
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF v1 IN (?, ?)", unset(), 1);
}
/**
@@ -175,20 +191,31 @@ public class InsertUpdateIfConditionTest extends CQLTester
assertRows(execute("DELETE FROM %s WHERE k='k' AND i=0 IF EXISTS"), row(false));
// CASSANDRA-6430
- assertInvalid("DELETE FROM %s WHERE k = 'k' IF EXISTS");
- assertInvalid("DELETE FROM %s WHERE k = 'k' IF v = 'foo'");
- assertInvalid("DELETE FROM %s WHERE i = 0 IF EXISTS");
- assertInvalid("DELETE FROM %s WHERE k = 0 AND i > 0 IF EXISTS");
- assertInvalid("DELETE FROM %s WHERE k = 0 AND i > 0 IF v = 'foo'");
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'i' is not restricted",
+ "DELETE FROM %s WHERE k = 'k' IF EXISTS");
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'i' is not restricted",
+ "DELETE FROM %s WHERE k = 'k' IF v = ?", "foo");
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'k' is not restricted",
+ "DELETE FROM %s WHERE i = 0 IF EXISTS");
+ assertInvalidMessage("Invalid INTEGER constant (0) for \"k\" of type text",
+ "DELETE FROM %s WHERE k = 0 AND i > 0 IF EXISTS");
+
+ assertInvalidMessage("Invalid operator > for PRIMARY KEY part i",
+ "DELETE FROM %s WHERE k = 'k' AND i > 0 IF EXISTS");
+ assertInvalidMessage("Invalid operator > for PRIMARY KEY part i",
+ "DELETE FROM %s WHERE k = 'k' AND i > 0 IF v = ?", "foo");
+
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "DELETE FROM %s WHERE k = 'k' AND i = 0 IF v = ?", unset());
createTable("CREATE TABLE %s(k int, s int static, i int, v text, PRIMARY KEY(k, i))");
execute("INSERT INTO %s (k, s, i, v) VALUES ( 1, 1, 2, '1')");
- assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
- assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s != ?", 1), row(false, 1));
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s = ?", 1), row(true));
assertRows(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"), row(1, 2, 1, null));
- assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
- assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s != ?", 1), row(false, 1));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s = ?", 1), row(true));
assertEmpty(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"));
assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, null, 1, null));
}
@@ -211,13 +238,13 @@ public class InsertUpdateIfConditionTest extends CQLTester
execute("INSERT INTO %s(id, version) VALUES (0, 0)");
- assertRows(execute("UPDATE %s SET v='foo', version=1 WHERE id=0 AND k='k1' IF version = 0"), row(true));
+ assertRows(execute("UPDATE %s SET v='foo', version=1 WHERE id=0 AND k='k1' IF version = ?", 0), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 1, "foo"));
- assertRows(execute("UPDATE %s SET v='bar', version=1 WHERE id=0 AND k='k2' IF version = 0"), row(false, 1));
+ assertRows(execute("UPDATE %s SET v='bar', version=1 WHERE id=0 AND k='k2' IF version = ?", 0), row(false, 1));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 1, "foo"));
- assertRows(execute("UPDATE %s SET v='bar', version=2 WHERE id=0 AND k='k2' IF version = 1"), row(true));
+ assertRows(execute("UPDATE %s SET v='bar', version=2 WHERE id=0 AND k='k2' IF version = ?", 1), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 2, "foo"), row(0, "k2", 2, "bar"));
// Testing batches
@@ -559,14 +586,16 @@ public class InsertUpdateIfConditionTest extends CQLTester
execute("INSERT INTO %s(k, l) VALUES (0, ['foo', 'bar', 'foobar'])");
- assertInvalid("DELETE FROM %s WHERE k=0 IF l[null] = 'foobar'");
- assertInvalid("DELETE FROM %s WHERE k=0 IF l[-2] = 'foobar'");
+ assertInvalidMessage("Invalid null value for list element access",
+ "DELETE FROM %s WHERE k=0 IF l[?] = ?", null, "foobar");
+ assertInvalidMessage("Invalid negative list index -2",
+ "DELETE FROM %s WHERE k=0 IF l[?] = ?", -2, "foobar");
- assertRows(execute("DELETE FROM %s WHERE k=0 IF l[1] = null"), row(false, list("foo", "bar", "foobar")));
- assertRows(execute("DELETE FROM %s WHERE k=0 IF l[1] = 'foobar'"), row(false, list("foo", "bar", "foobar")));
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF l[?] = ?", 1, null), row(false, list("foo", "bar", "foobar")));
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF l[?] = ?", 1, "foobar"), row(false, list("foo", "bar", "foobar")));
assertRows(execute("SELECT * FROM %s"), row(0, list("foo", "bar", "foobar")));
- assertRows(execute("DELETE FROM %s WHERE k=0 IF l[1] = 'bar'"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF l[?] = ?", 1, "bar"), row(true));
assertEmpty(execute("SELECT * FROM %s"));
}
}
@@ -766,19 +795,21 @@ public class InsertUpdateIfConditionTest extends CQLTester
: "map<text, text>"));
execute("INSERT INTO %s (k, m) VALUES (0, {'foo' : 'bar'})");
- assertInvalid("DELETE FROM %s WHERE k=0 IF m[null] = 'foo'");
- assertRows(execute("DELETE FROM %s WHERE k=0 IF m['foo'] = 'foo'"), row(false, map("foo", "bar")));
- assertRows(execute("DELETE FROM %s WHERE k=0 IF m['foo'] = null"), row(false, map("foo", "bar")));
+ assertInvalidMessage("Invalid null value for map element access",
+ "DELETE FROM %s WHERE k=0 IF m[?] = ?", null, "foo");
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF m[?] = ?", "foo", "foo"), row(false, map("foo", "bar")));
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF m[?] = ?", "foo", null), row(false, map("foo", "bar")));
assertRows(execute("SELECT * FROM %s"), row(0, map("foo", "bar")));
- assertRows(execute("DELETE FROM %s WHERE k=0 IF m['foo'] = 'bar'"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k=0 IF m[?] = ?", "foo", "bar"), row(true));
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s(k, m) VALUES (1, null)");
if (frozen)
- assertInvalid("UPDATE %s set m['foo'] = 'bar', m['bar'] = 'foo' WHERE k = 1 IF m['foo'] IN ('blah', null)");
+ assertInvalidMessage("Invalid operation (m['foo'] = 'bar') for frozen collection column m",
+ "UPDATE %s set m['foo'] = 'bar', m['bar'] = 'foo' WHERE k = 1 IF m[?] IN (?, ?)", "foo", "blah", null);
else
- assertRows(execute("UPDATE %s set m['foo'] = 'bar', m['bar'] = 'foo' WHERE k = 1 IF m['foo'] IN ('blah', null)"), row(true));
+ assertRows(execute("UPDATE %s set m['foo'] = 'bar', m['bar'] = 'foo' WHERE k = 1 IF m[?] IN (?, ?)", "foo", "blah", null), row(true));
}
}
@@ -987,6 +1018,8 @@ public class InsertUpdateIfConditionTest extends CQLTester
{
createTable("CREATE TABLE %s (a int, b int, s int static, d text, PRIMARY KEY (a, b))");
+ assertInvalidMessage("Invalid 'unset' value in condition", "UPDATE %s SET s = 6 WHERE a = 6 IF s = ?", unset());
+
// pre-existing row
execute("INSERT INTO %s (a, b, s, d) values (6, 6, 100, 'a')");
assertRows(execute("UPDATE %s SET s = 6 WHERE a = 6 IF s = 100"),
@@ -1021,7 +1054,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
conditionalUpdatesWithNonExistingOrNullValues();
// rejected: IN doesn't contain null
- assertRows(execute("UPDATE %s SET s = 30 WHERE a = 3 IF s IN (10,20,30)"),
+ assertRows(execute("UPDATE %s SET s = 30 WHERE a = 3 IF s IN ?", list(10,20,30)),
row(false));
assertRows(execute("SELECT * FROM %s WHERE a = 3"),
row(3, 3, null, null));
@@ -1029,7 +1062,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
// rejected: comparing number with NULL always returns false
for (String operator: new String[] { ">", "<", ">=", "<=", "="})
{
- assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " 3"),
+ assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " ?", 3),
row(false));
assertRows(execute("SELECT * FROM %s WHERE a = 5"),
row(5, 5, null, null));
@@ -1045,14 +1078,14 @@ public class InsertUpdateIfConditionTest extends CQLTester
conditionalUpdatesWithNonExistingOrNullValues();
// rejected: IN doesn't contain null
- assertRows(execute("UPDATE %s SET s = 3 WHERE a = 3 IF s IN (10,20,30)"),
+ assertRows(execute("UPDATE %s SET s = 3 WHERE a = 3 IF s IN ?", list(10,20,30)),
row(false));
assertEmpty(execute("SELECT a, s, d FROM %s WHERE a = 3"));
// rejected: comparing number with NULL always returns false
for (String operator : new String[]{ ">", "<", ">=", "<=", "=" })
{
- assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " 3"),
+ assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " ?", 3),
row(false));
assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
}
@@ -1060,17 +1093,17 @@ public class InsertUpdateIfConditionTest extends CQLTester
private void conditionalUpdatesWithNonExistingOrNullValues() throws Throwable
{
- assertRows(execute("UPDATE %s SET s = 1 WHERE a = 1 IF s = NULL"),
+ assertRows(execute("UPDATE %s SET s = 1 WHERE a = 1 IF s = ?", (Integer) null),
row(true));
assertRows(execute("SELECT a, s, d FROM %s WHERE a = 1"),
row(1, 1, null));
- assertRows(execute("UPDATE %s SET s = 2 WHERE a = 2 IF s IN (10,20,NULL)"),
+ assertRows(execute("UPDATE %s SET s = 2 WHERE a = 2 IF s IN (?, ?, ?)", 10,20,null),
row(true));
assertRows(execute("SELECT a, s, d FROM %s WHERE a = 2"),
row(2, 2, null));
- assertRows(execute("UPDATE %s SET s = 4 WHERE a = 4 IF s != 4"),
+ assertRows(execute("UPDATE %s SET s = 4 WHERE a = 4 IF s != ?", 4 ),
row(true));
assertRows(execute("SELECT a, s, d FROM %s WHERE a = 4"),
row(4, 4, null));
@@ -1182,23 +1215,23 @@ public class InsertUpdateIfConditionTest extends CQLTester
for (int i = 1; i <= 5; i++)
execute("INSERT INTO %s (a, b, s1, s2, v) VALUES (?, ?, ?, ?, ?)", i, i, i, null, i);
- assertRows(execute("DELETE s1 FROM %s WHERE a = 1 IF s2 = NULL"),
+ assertRows(execute("DELETE s1 FROM %s WHERE a = 1 IF s2 = ?", (Integer) null),
row(true));
assertRows(execute("SELECT * FROM %s WHERE a = 1"),
row(1, 1, null, null, 1));
// rejected: IN doesn't contain null
- assertRows(execute("DELETE s1 FROM %s WHERE a = 2 IF s2 IN (10,20,30)"),
+ assertRows(execute("DELETE s1 FROM %s WHERE a = 2 IF s2 IN ?", list(10,20,30)),
row(false, null));
assertRows(execute("SELECT * FROM %s WHERE a = 2"),
row(2, 2, 2, null, 2));
- assertRows(execute("DELETE s1 FROM %s WHERE a = 3 IF s2 IN (NULL,20,30)"),
+ assertRows(execute("DELETE s1 FROM %s WHERE a = 3 IF s2 IN (?, ?, ?)", null, 20, 30),
row(true));
assertRows(execute("SELECT * FROM %s WHERE a = 3"),
row(3, 3, null, null, 3));
- assertRows(execute("DELETE s1 FROM %s WHERE a = 4 IF s2 != 4"),
+ assertRows(execute("DELETE s1 FROM %s WHERE a = 4 IF s2 != ?", 4),
row(true));
assertRows(execute("SELECT * FROM %s WHERE a = 4"),
row(4, 4, null, null, 4));
@@ -1206,7 +1239,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
// rejected: comparing number with NULL always returns false
for (String operator : new String[]{ ">", "<", ">=", "<=", "=" })
{
- assertRows(execute("DELETE s1 FROM %s WHERE a = 5 IF s2 " + operator + " 3"),
+ assertRows(execute("DELETE s1 FROM %s WHERE a = 5 IF s2 " + operator + " ?", 3),
row(false, null));
assertRows(execute("SELECT * FROM %s WHERE a = 5"),
row(5, 5, 5, null, 5));
[4/4] cassandra git commit: Merge branch cassandra-3.11 into
cassandra-3.X
Posted by bl...@apache.org.
Merge branch cassandra-3.11 into cassandra-3.X
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8883554a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8883554a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8883554a
Branch: refs/heads/cassandra-3.X
Commit: 8883554a1d58cb4fcf96b7e3c42cd6feca773e8a
Parents: 84b2e73 c80b9fb
Author: Benjamin Lerer <b....@gmail.com>
Authored: Mon Dec 12 13:52:46 2016 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Mon Dec 12 13:52:55 2016 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../operations/InsertUpdateIfConditionTest.java | 125 +++++++++++--------
2 files changed, 76 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/8883554a/CHANGES.txt
----------------------------------------------------------------------
[2/4] cassandra git commit: Merge branch cassandra-2.2 into
cassandra-3.0
Posted by bl...@apache.org.
Merge branch cassandra-2.2 into cassandra-3.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/da94781a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/da94781a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/da94781a
Branch: refs/heads/cassandra-3.X
Commit: da94781a2c20394c1fc4f3d488a694ddad45228f
Parents: 6bd402d 9a5aef0
Author: Benjamin Lerer <b....@gmail.com>
Authored: Mon Dec 12 13:26:35 2016 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Mon Dec 12 13:46:24 2016 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../operations/InsertUpdateIfConditionTest.java | 126 +++++++++++--------
2 files changed, 76 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/da94781a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 266849a,134a37d..bbd47c1
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,14 -1,5 +1,15 @@@
-2.2.9
+3.0.11
+ * Set RPC_READY to false when draining or if a node is marked as shutdown (CASSANDRA-12781)
+ * CQL often queries static columns unnecessarily (CASSANDRA-12768)
+ * Make sure sstables only get committed when it's safe to discard commit log records (CASSANDRA-12956)
+ * Reject default_time_to_live option when creating or altering MVs (CASSANDRA-12868)
+ * Nodetool should use a more sane max heap size (CASSANDRA-12739)
+ * LocalToken ensures token values are cloned on heap (CASSANDRA-12651)
+ * AnticompactionRequestSerializer serializedSize is incorrect (CASSANDRA-12934)
+ * Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535)
+ * Reenable HeapPool (CASSANDRA-12900)
+Merged from 2.2:
+ * Test bind parameters and unset parameters in InsertUpdateIfConditionTest (CASSANDRA-12980)
* Do not specify local address on outgoing connection when listen_on_broadcast_address is set (CASSANDRA-12673)
* Use saved tokens when setting local tokens on StorageService.joinRing (CASSANDRA-12935)
* cqlsh: fix DESC TYPES errors (CASSANDRA-12914)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/da94781a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index ec81cf2,4a209e6..f1dc9a2
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@@ -23,11 -23,8 +23,10 @@@ import org.junit.Test
import org.apache.cassandra.cql3.CQLTester;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.exceptions.SyntaxException;
+import org.apache.cassandra.schema.SchemaKeyspace;
+import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class InsertUpdateIfConditionTest extends CQLTester
@@@ -111,13 -111,8 +113,13 @@@
// Shouldn't apply
assertRows(execute("UPDATE %s SET v1 = 3, v2 = 'bar' WHERE k = 0 IF EXISTS"), row(false));
- // Shouldn't apply
+ // Should apply
+ assertEmpty(execute("SELECT * FROM %s WHERE k = 0"));
- assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 IN (null)"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 0 IF v1 IN (?)", (Integer) null), row(true));
+
+ createTable(" CREATE TABLE %s (k int, c int, v1 text, PRIMARY KEY(k, c))");
+ assertInvalidMessage("IN on the clustering key columns is not supported with conditional updates",
+ "UPDATE %s SET v1 = 'A' WHERE k = 0 AND c IN (1, 2) IF EXISTS");
}
/**
@@@ -194,58 -191,33 +209,61 @@@
assertRows(execute("DELETE FROM %s WHERE k='k' AND i=0 IF EXISTS"), row(false));
// CASSANDRA-6430
- assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'i' is not restricted",
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to delete non static columns",
"DELETE FROM %s WHERE k = 'k' IF EXISTS");
- assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'i' is not restricted",
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to delete non static columns",
- "DELETE FROM %s WHERE k = 'k' IF v = 'foo'");
+ "DELETE FROM %s WHERE k = 'k' IF v = ?", "foo");
- assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to use IF conditions, but column 'k' is not restricted",
+ assertInvalidMessage("Some partition key parts are missing: k",
"DELETE FROM %s WHERE i = 0 IF EXISTS");
+
assertInvalidMessage("Invalid INTEGER constant (0) for \"k\" of type text",
"DELETE FROM %s WHERE k = 0 AND i > 0 IF EXISTS");
-
- assertInvalidMessage("Invalid operator > for PRIMARY KEY part i",
+ assertInvalidMessage("Invalid INTEGER constant (0) for \"k\" of type text",
+ "DELETE FROM %s WHERE k = 0 AND i > 0 IF v = 'foo'");
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to delete non static columns",
"DELETE FROM %s WHERE k = 'k' AND i > 0 IF EXISTS");
- assertInvalidMessage("Invalid operator > for PRIMARY KEY part i",
- "DELETE FROM %s WHERE k = 'k' AND i > 0 IF v = ?", "foo");
+ assertInvalidMessage("DELETE statements must restrict all PRIMARY KEY columns with equality relations in order to delete non static columns",
+ "DELETE FROM %s WHERE k = 'k' AND i > 0 IF v = 'foo'");
+ assertInvalidMessage("IN on the clustering key columns is not supported with conditional deletions",
+ "DELETE FROM %s WHERE k = 'k' AND i IN (0, 1) IF v = 'foo'");
+ assertInvalidMessage("IN on the clustering key columns is not supported with conditional deletions",
+ "DELETE FROM %s WHERE k = 'k' AND i IN (0, 1) IF EXISTS");
+ assertInvalidMessage("Invalid 'unset' value in condition",
+ "DELETE FROM %s WHERE k = 'k' AND i = 0 IF v = ?", unset());
+
createTable("CREATE TABLE %s(k int, s int static, i int, v text, PRIMARY KEY(k, i))");
execute("INSERT INTO %s (k, s, i, v) VALUES ( 1, 1, 2, '1')");
- assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
- assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s != ?", 1), row(false, 1));
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s = ?", 1), row(true));
assertRows(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"), row(1, 2, 1, null));
- assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
- assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s != ?", 1), row(false, 1));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s = ?", 1), row(true));
assertEmpty(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"));
assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, null, 1, null));
+
+ createTable("CREATE TABLE %s (k int, i int, v1 int, v2 int, s int static, PRIMARY KEY (k, i))");
+ execute("INSERT INTO %s (k, i, v1, v2, s) VALUES (?, ?, ?, ?, ?)",
+ 1, 1, 1, 1, 1);
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 1 IF EXISTS"),
+ row(true));
+ assertRows(execute("DELETE v2 FROM %s WHERE k = 1 AND i = 1 IF EXISTS"),
+ row(true));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 1 IF EXISTS"),
+ row(true));
+ assertRows(execute("select * from %s"),
+ row(1, null, 1, null, null));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 1 IF EXISTS"),
+ row(false));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 1 IF s = 5"),
+ row(false, 1));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 1 IF v1 = 1 AND v2 = 1"),
+ row(false));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 1 IF v1 = 1 AND v2 = 1 AND s = 1"),
+ row(false, null, null, 1));
+ assertRows(execute("DELETE v1 FROM %s WHERE k = 1 AND i = 5 IF s = 1"),
+ row(true));
}
/**
@@@ -266,19 -238,15 +284,19 @@@
execute("INSERT INTO %s(id, version) VALUES (0, 0)");
- assertRows(execute("UPDATE %s SET v='foo', version=1 WHERE id=0 AND k='k1' IF version = 0"), row(true));
+ assertRows(execute("UPDATE %s SET v='foo', version=1 WHERE id=0 AND k='k1' IF version = ?", 0), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 1, "foo"));
- assertRows(execute("UPDATE %s SET v='bar', version=1 WHERE id=0 AND k='k2' IF version = 0"), row(false, 1));
+ assertRows(execute("UPDATE %s SET v='bar', version=1 WHERE id=0 AND k='k2' IF version = ?", 0), row(false, 1));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 1, "foo"));
- assertRows(execute("UPDATE %s SET v='bar', version=2 WHERE id=0 AND k='k2' IF version = 1"), row(true));
+ assertRows(execute("UPDATE %s SET v='bar', version=2 WHERE id=0 AND k='k2' IF version = ?", 1), row(true));
assertRows(execute("SELECT * FROM %s"), row(0, "k1", 2, "foo"), row(0, "k2", 2, "bar"));
+ // Batch output is slightly different from non-batch CAS, since a full PK is included to disambiguate
+ // cases when conditions span across multiple rows.
+ assertRows(execute("UPDATE %1$s SET version=3 WHERE id=0 IF version=1; "),
+ row(false, 2));
// Testing batches
assertRows(execute("BEGIN BATCH " +
"UPDATE %1$s SET v='foobar' WHERE id=0 AND k='k1'; " +
@@@ -1095,147 -1047,66 +1119,147 @@@
{
createTable("CREATE TABLE %s (a int, b int, s int static, d text, PRIMARY KEY (a, b))");
- // pre-populate, leave out static column
- for (int i = 1; i <= 5; i++)
- execute("INSERT INTO %s (a, b) VALUES (?, ?)", i, i);
+ assertRows(execute("UPDATE %s SET s = 1 WHERE a = 1 IF s = NULL"),
+ row(true));
+ assertRows(execute("SELECT a, s, d FROM %s WHERE a = 1"),
+ row(1, 1, null));
- conditionalUpdatesWithNonExistingOrNullValues();
+ assertRows(execute("UPDATE %s SET s = 2 WHERE a = 2 IF s IN (10,20,NULL)"),
+ row(true));
+ assertRows(execute("SELECT a, s, d FROM %s WHERE a = 2"),
+ row(2, 2, null));
+
+ assertRows(execute("UPDATE %s SET s = 4 WHERE a = 4 IF s != 4"),
+ row(true));
+ assertRows(execute("SELECT a, s, d FROM %s WHERE a = 4"),
+ row(4, 4, null));
// rejected: IN doesn't contain null
- assertRows(execute("UPDATE %s SET s = 3 WHERE a = 3 IF s IN (10,20,30)"),
- assertRows(execute("UPDATE %s SET s = 30 WHERE a = 3 IF s IN ?", list(10,20,30)),
++ assertRows(execute("UPDATE %s SET s = 3 WHERE a = 3 IF s IN ?", list(10,20,30)),
row(false));
- assertRows(execute("SELECT * FROM %s WHERE a = 3"),
- row(3, 3, null, null));
+ assertEmpty(execute("SELECT a, s, d FROM %s WHERE a = 3"));
// rejected: comparing number with NULL always returns false
- for (String operator: new String[] { ">", "<", ">=", "<=", "="})
+ for (String operator : new String[]{ ">", "<", ">=", "<=", "=" })
{
- assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " 3"),
+ assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " ?", 3),
row(false));
- assertRows(execute("SELECT * FROM %s WHERE a = 5"),
- row(5, 5, null, null));
+ assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
}
-
}
@Test
- public void testConditionalUpdatesWithNonExistingValues() throws Throwable
+ public void testConditionalUpdatesWithNullValues() throws Throwable
{
- createTable("CREATE TABLE %s (a int, b int, s int static, d text, PRIMARY KEY (a, b))");
+ createTable("CREATE TABLE %s (a int, b int, s int static, d int, PRIMARY KEY (a, b))");
- conditionalUpdatesWithNonExistingOrNullValues();
+ // pre-populate, leave out static column
+ for (int i = 1; i <= 5; i++)
+ {
+ execute("INSERT INTO %s (a, b) VALUES (?, ?)", i, 1);
+ execute("INSERT INTO %s (a, b) VALUES (?, ?)", i, 2);
+ }
+
+ assertRows(execute("UPDATE %s SET s = 100 WHERE a = 1 IF s = NULL"),
+ row(true));
+ assertRows(execute("SELECT a, b, s, d FROM %s WHERE a = 1"),
+ row(1, 1, 100, null),
+ row(1, 2, 100, null));
+
+ assertRows(execute("UPDATE %s SET s = 200 WHERE a = 2 IF s IN (10,20,NULL)"),
+ row(true));
+ assertRows(execute("SELECT a, b, s, d FROM %s WHERE a = 2"),
+ row(2, 1, 200, null),
+ row(2, 2, 200, null));
// rejected: IN doesn't contain null
- assertRows(execute("UPDATE %s SET s = 30 WHERE a = 3 IF s IN (10,20,30)"),
- assertRows(execute("UPDATE %s SET s = 3 WHERE a = 3 IF s IN ?", list(10,20,30)),
- row(false));
- assertEmpty(execute("SELECT a, s, d FROM %s WHERE a = 3"));
++ assertRows(execute("UPDATE %s SET s = 30 WHERE a = 3 IF s IN ?", list(10,20,30)),
+ row(false, null));
+ assertRows(execute("SELECT * FROM %s WHERE a = 3"),
+ row(3, 1, null, null),
+ row(3, 2, null, null));
+
+ assertRows(execute("UPDATE %s SET s = 400 WHERE a = 4 IF s IN (10,20,NULL)"),
+ row(true));
+ assertRows(execute("SELECT * FROM %s WHERE a = 4"),
+ row(4, 1, 400, null),
+ row(4, 2, 400, null));
// rejected: comparing number with NULL always returns false
- for (String operator : new String[]{ ">", "<", ">=", "<=", "=" })
+ for (String operator: new String[] { ">", "<", ">=", "<=", "="})
{
- assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " ?", 3),
- row(false));
- assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
+ assertRows(execute("UPDATE %s SET s = 50 WHERE a = 5 IF s " + operator + " 3"),
+ row(false, null));
+ assertRows(execute("SELECT * FROM %s WHERE a = 5"),
+ row(5, 1, null, null),
+ row(5, 2, null, null));
}
+
+ assertRows(execute("UPDATE %s SET s = 500 WHERE a = 5 IF s != 5"),
+ row(true));
+ assertRows(execute("SELECT a, b, s, d FROM %s WHERE a = 5"),
+ row(5, 1, 500, null),
+ row(5, 2, 500, null));
+
+ // Similar test, although with two static columns to test limits
+ createTable("CREATE TABLE %s (a int, b int, s1 int static, s2 int static, d int, PRIMARY KEY (a, b))");
+
+ for (int i = 1; i <= 5; i++)
+ for (int j = 0; j < 5; j++)
+ execute("INSERT INTO %s (a, b, d) VALUES (?, ?, ?)", i, j, i + j);
+
+ assertRows(execute("UPDATE %s SET s2 = 100 WHERE a = 1 IF s1 = NULL"),
+ row(true));
+
+ execute("INSERT INTO %s (a, b, s1) VALUES (?, ?, ?)", 2, 2, 2);
+ assertRows(execute("UPDATE %s SET s1 = 100 WHERE a = 2 IF s2 = NULL"),
+ row(true));
+
+ execute("INSERT INTO %s (a, b, s1) VALUES (?, ?, ?)", 2, 2, 2);
+ assertRows(execute("UPDATE %s SET s1 = 100 WHERE a = 2 IF s2 = NULL"),
+ row(true));
}
- private void conditionalUpdatesWithNonExistingOrNullValues() throws Throwable
+ @Test
+ public void testStaticsWithMultipleConditions() throws Throwable
{
- assertRows(execute("UPDATE %s SET s = 1 WHERE a = 1 IF s = ?", (Integer) null),
- row(true));
- assertRows(execute("SELECT a, s, d FROM %s WHERE a = 1"),
- row(1, 1, null));
+ createTable("CREATE TABLE %s (a int, b int, s1 int static, s2 int static, d int, PRIMARY KEY (a, b))");
- assertRows(execute("UPDATE %s SET s = 2 WHERE a = 2 IF s IN (?, ?, ?)", 10,20,null),
+ for (int i = 1; i <= 5; i++)
+ {
+ execute("INSERT INTO %s (a, b, d) VALUES (?, ?, ?)", i, 1, 5);
+ execute("INSERT INTO %s (a, b, d) VALUES (?, ?, ?)", i, 2, 6);
+ }
+
+ assertRows(execute("BEGIN BATCH\n"
+ + "UPDATE %1$s SET s2 = 102 WHERE a = 1 IF s1 = null;\n"
+ + "UPDATE %1$s SET s1 = 101 WHERE a = 1 IF s2 = null;\n"
+ + "APPLY BATCH"),
row(true));
- assertRows(execute("SELECT a, s, d FROM %s WHERE a = 2"),
- row(2, 2, null));
+ assertRows(execute("SELECT * FROM %s WHERE a = 1"),
+ row(1, 1, 101, 102, 5),
+ row(1, 2, 101, 102, 6));
- assertRows(execute("UPDATE %s SET s = 4 WHERE a = 4 IF s != ?", 4 ),
+
+ assertRows(execute("BEGIN BATCH\n"
+ + "UPDATE %1$s SET s2 = 202 WHERE a = 2 IF s1 = null;\n"
+ + "UPDATE %1$s SET s1 = 201 WHERE a = 2 IF s2 = null;\n"
+ + "UPDATE %1$s SET d = 203 WHERE a = 2 AND b = 1 IF d = 5;\n"
+ + "UPDATE %1$s SET d = 204 WHERE a = 2 AND b = 2 IF d = 6;\n"
+ + "APPLY BATCH"),
row(true));
- assertRows(execute("SELECT a, s, d FROM %s WHERE a = 4"),
- row(4, 4, null));
+
+ assertRows(execute("SELECT * FROM %s WHERE a = 2"),
+ row(2, 1, 201, 202, 203),
+ row(2, 2, 201, 202, 204));
+
+ assertRows(execute("BEGIN BATCH\n"
+ + "UPDATE %1$s SET s2 = 202 WHERE a = 20 IF s1 = null;\n"
+ + "UPDATE %1$s SET s1 = 201 WHERE a = 20 IF s2 = null;\n"
+ + "UPDATE %1$s SET d = 203 WHERE a = 20 AND b = 1 IF d = 5;\n"
+ + "UPDATE %1$s SET d = 204 WHERE a = 20 AND b = 2 IF d = 6;\n"
+ + "APPLY BATCH"),
+ row(false));
}
@Test
[3/4] cassandra git commit: Merge branch cassandra-3.0 into
cassandra-3.11
Posted by bl...@apache.org.
Merge branch cassandra-3.0 into cassandra-3.11
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c80b9fb3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c80b9fb3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c80b9fb3
Branch: refs/heads/cassandra-3.X
Commit: c80b9fb395671411f1be53b607d7c384f4b37798
Parents: 4626b4c da94781
Author: Benjamin Lerer <b....@gmail.com>
Authored: Mon Dec 12 13:51:25 2016 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Mon Dec 12 13:51:25 2016 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../operations/InsertUpdateIfConditionTest.java | 125 +++++++++++--------
2 files changed, 76 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c80b9fb3/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 7b017bb,bbd47c1..d056492
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -164,10 -53,6 +164,11 @@@ Merged from 3.0
* Correct log message for statistics of offheap memtable flush (CASSANDRA-12776)
* Explicitly set locale for string validation (CASSANDRA-12541,CASSANDRA-12542,CASSANDRA-12543,CASSANDRA-12545)
Merged from 2.2:
++ * Test bind parameters and unset parameters in InsertUpdateIfConditionTest (CASSANDRA-12980)
+ * Use saved tokens when setting local tokens on StorageService.joinRing (CASSANDRA-12935)
+ * cqlsh: fix DESC TYPES errors (CASSANDRA-12914)
+ * Fix leak on skipped SSTables in sstableupgrade (CASSANDRA-12899)
+ * Avoid blocking gossip during pending range calculation (CASSANDRA-12281)
* Fix purgeability of tombstones with max timestamp (CASSANDRA-12792)
* Fail repair if participant dies during sync or anticompaction (CASSANDRA-12901)
* cqlsh COPY: unprotected pk values before converting them if not using prepared statements (CASSANDRA-12863)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c80b9fb3/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------