Files
scylladb/test/cql/cassandra_batch_test.result
Avi Kivity fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00

446 lines
7.8 KiB
Plaintext

--
-- Modified by ScyllaDB
-- from cassandra/test/unit/org/apache/cassandra/cql3/validation/operations/BatchTest.java
--
--
--------------------------------------------------------------------------------
--
-- Copyright (C) 2016-present ScyllaDB
--
-- Modified by ScyllaDB
--
-- SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
-- setup
CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
{
"status" : "ok"
}
USE k;
{
"status" : "ok"
}
-- testBatch
CREATE TABLE t (userid text PRIMARY KEY, name text, password text);
{
"status" : "ok"
}
BEGIN BATCH
INSERT INTO t (userid, password, name) VALUES ('user2', 'ch@ngem3b', 'second user')
UPDATE t SET password = 'ps22dhds' WHERE userid = 'user3'
INSERT INTO t (userid, password) VALUES ('user4', 'ch@ngem3c')
DELETE name FROM t WHERE userid = 'user1'
APPLY BATCH;
{
"status" : "ok"
}
SELECT * FROM t;
{
"rows" :
[
{
"name" : "\"second user\"",
"password" : "\"ch@ngem3b\"",
"userid" : "\"user2\""
},
{
"password" : "\"ch@ngem3c\"",
"userid" : "\"user4\""
},
{
"password" : "\"ps22dhds\"",
"userid" : "\"user3\""
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
--
-- testBatchAndList
CREATE TABLE t (k int PRIMARY KEY, l list<int>);
{
"status" : "ok"
}
BEGIN BATCH
UPDATE t SET l = l + [ 1 ] WHERE k = 0
UPDATE t SET l = l + [ 2 ] WHERE k = 0
UPDATE t SET l = l + [ 3 ] WHERE k = 0
APPLY BATCH;
{
"status" : "ok"
}
SELECT l FROM t WHERE k = 0;
{
"rows" :
[
{
"l" : "[1, 2, 3]"
}
]
}
BEGIN BATCH
UPDATE t SET l = [ 1 ] + l WHERE k = 1
UPDATE t SET l = [ 2 ] + l WHERE k = 1
UPDATE t SET l = [ 3 ] + l WHERE k = 1
APPLY BATCH;
{
"status" : "ok"
}
SELECT l FROM t WHERE k = 1;
{
"rows" :
[
{
"l" : "[3, 2, 1]"
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
--
-- testBatchDeleteInsert
CREATE TABLE t (k int, v int, PRIMARY KEY (k, v));
{
"status" : "ok"
}
INSERT INTO t (k, v) VALUES (0, 1);
{
"status" : "ok"
}
BEGIN BATCH
DELETE FROM t WHERE k=0 AND v=1
INSERT INTO t (k, v) VALUES (0, 2)
APPLY BATCH;
{
"status" : "ok"
}
SELECT * FROM t;
{
"rows" :
[
{
"k" : "0",
"v" : "2"
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
-- testBatchWithUnset
CREATE TABLE t (k int PRIMARY KEY, s text, i int);
{
"status" : "ok"
}
BEGIN BATCH
INSERT INTO t JSON '{"k": 100, "s": null}' DEFAULT UNSET
INSERT INTO t JSON '{"k": 111, "i": null}' DEFAULT UNSET
APPLY BATCH;
{
"status" : "ok"
}
SELECT k, s, i FROM t where k in (100,111);
{
"rows" :
[
{
"k" : "100"
},
{
"k" : "111"
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
-- testBatchUpdate
CREATE TABLE t (partitionKey int, clustering_1 int, value int, PRIMARY KEY (partitionKey, clustering_1));
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 0, 0);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 1, 1);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 2, 2);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 3, 3);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 4, 4);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 5, 5);
{
"status" : "ok"
}
INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 6, 6);
{
"status" : "ok"
}
BEGIN BATCH
UPDATE t SET value = 7 WHERE partitionKey = 0 AND clustering_1 = 1
UPDATE t SET value = 8 WHERE partitionKey = 0 AND (clustering_1) = (2)
UPDATE t SET value = 10 WHERE partitionKey = 0 AND clustering_1 IN (3, 4)
UPDATE t SET value = 20 WHERE partitionKey = 0 AND (clustering_1) IN ((5), (6))
APPLY BATCH;
{
"status" : "ok"
}
SELECT * FROM t;
{
"rows" :
[
{
"clustering_1" : "0",
"partitionkey" : "0",
"value" : "0"
},
{
"clustering_1" : "1",
"partitionkey" : "0",
"value" : "7"
},
{
"clustering_1" : "2",
"partitionkey" : "0",
"value" : "8"
},
{
"clustering_1" : "3",
"partitionkey" : "0",
"value" : "10"
},
{
"clustering_1" : "4",
"partitionkey" : "0",
"value" : "10"
},
{
"clustering_1" : "5",
"partitionkey" : "0",
"value" : "20"
},
{
"clustering_1" : "6",
"partitionkey" : "0",
"value" : "20"
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
-- testBatchEmpty
BEGIN BATCH APPLY BATCH;
{
"status" : "ok"
}
-- testBatchMultipleTable
CREATE TABLE t1 (k1 int PRIMARY KEY, v11 int, v12 int);
{
"status" : "ok"
}
CREATE TABLE t2 (k2 int PRIMARY KEY, v21 int, v22 int);
{
"status" : "ok"
}
BEGIN BATCH
UPDATE t1 SET v11 = 1 WHERE k1 = 0
UPDATE t1 SET v12 = 2 WHERE k1 = 0
UPDATE t2 SET v21 = 3 WHERE k2 = 0
UPDATE t2 SET v22 = 4 WHERE k2 = 0
APPLY BATCH;
{
"status" : "ok"
}
SELECT * FROM t1;
{
"rows" :
[
{
"k1" : "0",
"v11" : "1",
"v12" : "2"
}
]
}
SELECT * FROM t2;
{
"rows" :
[
{
"k2" : "0",
"v21" : "3",
"v22" : "4"
}
]
}
SELECT * FROM t1;
{
"rows" :
[
{
"k1" : "0",
"v11" : "1",
"v12" : "2"
}
]
}
SELECT * FROM t2;
{
"rows" :
[
{
"k2" : "0",
"v21" : "3",
"v22" : "4"
}
]
}
DROP TABLE t1;
{
"status" : "ok"
}
DROP TABLE t2;
{
"status" : "ok"
}
-- testBatchWithInRestriction
CREATE TABLE t (a int, b int, c int, PRIMARY KEY (a,b));
{
"status" : "ok"
}
INSERT INTO t (a,b,c) VALUES (1, 1, 1);
{
"status" : "ok"
}
INSERT INTO t (a,b,c) VALUES (1, 2, 2);
{
"status" : "ok"
}
INSERT INTO t (a,b,c) VALUES (1, 3, 3);
{
"status" : "ok"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
UPDATE t SET c = 200 WHERE a = 1 AND b IN () IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the clustering key columns is not supported with conditional updates)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
DELETE FROM t WHERE a = 1 AND b IN () IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the clustering key columns is not supported with conditional deletions)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
UPDATE t SET c = 200 WHERE a IN () AND b = 1 IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the partition key is not supported with conditional updates)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
DELETE FROM t WHERE a IN () AND b = 1 IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the partition key is not supported with conditional deletions)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
UPDATE t SET c = 200 WHERE a = 1 AND b IN (1, 2) IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the clustering key columns is not supported with conditional updates)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
DELETE FROM t WHERE a = 1 AND b IN (1, 2) IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the clustering key columns is not supported with conditional deletions)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
UPDATE t SET c = 200 WHERE a IN (1, 2) AND b = 1 IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the partition key is not supported with conditional updates)",
"status" : "error"
}
BEGIN BATCH
UPDATE t SET c = 100 WHERE a = 1 AND b = 1 IF c = 1
DELETE FROM t WHERE a IN (1, 2) AND b = 1 IF c = 1
APPLY BATCH;
{
"message" : "exceptions::invalid_request_exception (IN on the partition key is not supported with conditional deletions)",
"status" : "error"
}
SELECT * FROM t;
{
"rows" :
[
{
"a" : "1",
"b" : "1",
"c" : "1"
},
{
"a" : "1",
"b" : "2",
"c" : "2"
},
{
"a" : "1",
"b" : "3",
"c" : "3"
}
]
}
DROP TABLE t;
{
"status" : "ok"
}
DROP KEYSPACE k;
{
"status" : "ok"
}