test.py: switch cql/ suite to pytest/tabular output
This commit is contained in:
@@ -1,445 +1,257 @@
|
||||
--
|
||||
-- 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"
|
||||
}
|
||||
> --
|
||||
> -- 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};
|
||||
OK
|
||||
> USE k;
|
||||
OK
|
||||
>
|
||||
> -- testBatch
|
||||
> CREATE TABLE t (userid text PRIMARY KEY, name text, password text);
|
||||
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;
|
||||
OK
|
||||
> SELECT * FROM t;
|
||||
+----------+-------------+------------+
|
||||
| userid | name | password |
|
||||
|----------+-------------+------------|
|
||||
| user2 | second user | ch@ngem3b |
|
||||
| user4 | null | ch@ngem3c |
|
||||
| user3 | null | ps22dhds |
|
||||
+----------+-------------+------------+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
> --
|
||||
> -- testBatchAndList
|
||||
> CREATE TABLE t (k int PRIMARY KEY, l list<int>);
|
||||
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;
|
||||
OK
|
||||
> SELECT l FROM t WHERE k = 0;
|
||||
+-----------+
|
||||
| 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;
|
||||
OK
|
||||
> SELECT l FROM t WHERE k = 1;
|
||||
+-----------+
|
||||
| l |
|
||||
|-----------|
|
||||
| [3, 2, 1] |
|
||||
+-----------+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
> --
|
||||
> -- testBatchDeleteInsert
|
||||
> CREATE TABLE t (k int, v int, PRIMARY KEY (k, v));
|
||||
OK
|
||||
> INSERT INTO t (k, v) VALUES (0, 1);
|
||||
OK
|
||||
> BEGIN BATCH
|
||||
> DELETE FROM t WHERE k=0 AND v=1
|
||||
> INSERT INTO t (k, v) VALUES (0, 2)
|
||||
> APPLY BATCH;
|
||||
OK
|
||||
> SELECT * FROM t;
|
||||
+-----+-----+
|
||||
| k | v |
|
||||
|-----+-----|
|
||||
| 0 | 2 |
|
||||
+-----+-----+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
>
|
||||
> -- testBatchWithUnset
|
||||
> CREATE TABLE t (k int PRIMARY KEY, s text, i int);
|
||||
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;
|
||||
OK
|
||||
> SELECT k, s, i FROM t where k in (100,111);
|
||||
+-----+------+------+
|
||||
| k | s | i |
|
||||
|-----+------+------|
|
||||
| 100 | null | null |
|
||||
| 111 | null | null |
|
||||
+-----+------+------+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
>
|
||||
> -- testBatchUpdate
|
||||
> CREATE TABLE t (partitionKey int, clustering_1 int, value int, PRIMARY KEY (partitionKey, clustering_1));
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 0, 0);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 1, 1);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 2, 2);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 3, 3);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 4, 4);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 5, 5);
|
||||
OK
|
||||
> INSERT INTO t (partitionKey, clustering_1, value) VALUES (0, 6, 6);
|
||||
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;
|
||||
OK
|
||||
> SELECT * FROM t;
|
||||
+----------------+----------------+---------+
|
||||
| partitionkey | clustering_1 | value |
|
||||
|----------------+----------------+---------|
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 7 |
|
||||
| 0 | 2 | 8 |
|
||||
| 0 | 3 | 10 |
|
||||
| 0 | 4 | 10 |
|
||||
| 0 | 5 | 20 |
|
||||
| 0 | 6 | 20 |
|
||||
+----------------+----------------+---------+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
>
|
||||
> -- testBatchEmpty
|
||||
> BEGIN BATCH APPLY BATCH;
|
||||
OK
|
||||
>
|
||||
> -- testBatchMultipleTable
|
||||
> CREATE TABLE t1 (k1 int PRIMARY KEY, v11 int, v12 int);
|
||||
OK
|
||||
> CREATE TABLE t2 (k2 int PRIMARY KEY, v21 int, v22 int);
|
||||
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;
|
||||
OK
|
||||
> SELECT * FROM t1;
|
||||
+------+-------+-------+
|
||||
| k1 | v11 | v12 |
|
||||
|------+-------+-------|
|
||||
| 0 | 1 | 2 |
|
||||
+------+-------+-------+
|
||||
> SELECT * FROM t2;
|
||||
+------+-------+-------+
|
||||
| k2 | v21 | v22 |
|
||||
|------+-------+-------|
|
||||
| 0 | 3 | 4 |
|
||||
+------+-------+-------+
|
||||
> SELECT * FROM t1;
|
||||
+------+-------+-------+
|
||||
| k1 | v11 | v12 |
|
||||
|------+-------+-------|
|
||||
| 0 | 1 | 2 |
|
||||
+------+-------+-------+
|
||||
> SELECT * FROM t2;
|
||||
+------+-------+-------+
|
||||
| k2 | v21 | v22 |
|
||||
|------+-------+-------|
|
||||
| 0 | 3 | 4 |
|
||||
+------+-------+-------+
|
||||
> DROP TABLE t1;
|
||||
OK
|
||||
> DROP TABLE t2;
|
||||
OK
|
||||
>
|
||||
> -- testBatchWithInRestriction
|
||||
> CREATE TABLE t (a int, b int, c int, PRIMARY KEY (a,b));
|
||||
OK
|
||||
> INSERT INTO t (a,b,c) VALUES (1, 1, 1);
|
||||
OK
|
||||
> INSERT INTO t (a,b,c) VALUES (1, 2, 2);
|
||||
OK
|
||||
> INSERT INTO t (a,b,c) VALUES (1, 3, 3);
|
||||
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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the clustering key columns is not supported with conditional updates"
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the clustering key columns is not supported with conditional deletions"
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the partition key is not supported with conditional updates"
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the partition key is not supported with conditional deletions"
|
||||
>
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the clustering key columns is not supported with conditional updates"
|
||||
>
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the clustering key columns is not supported with conditional deletions"
|
||||
>
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the partition key is not supported with conditional updates"
|
||||
> 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;
|
||||
Error from server: code=2200 [Invalid query] message="IN on the partition key is not supported with conditional deletions"
|
||||
>
|
||||
> SELECT * FROM t;
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | 2 | 2 |
|
||||
| 1 | 3 | 3 |
|
||||
+-----+-----+-----+
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
> DROP KEYSPACE k;
|
||||
OK
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,6 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create table ks.test_scylla_cdc_log (pk int primary key);
|
||||
-- Should be possible to drop it
|
||||
drop table ks.test_scylla_cdc_log;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
create table ks.test_scylla_cdc_log (pk int primary key);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- Should be possible to drop it
|
||||
drop table ks.test_scylla_cdc_log;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.test_scylla_cdc_log (pk int primary key);
|
||||
OK
|
||||
> -- Should be possible to drop it
|
||||
> drop table ks.test_scylla_cdc_log;
|
||||
OK
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
-- do range delete in batch
|
||||
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
|
||||
begin batch insert into ks.t (pk, ck, v) values (1, 1, 100); delete from t where pk = 1 and ck >= 1 and ck <= 2; apply batch;
|
||||
begin batch insert into ks.t (pk, ck, v) values (1, 1, 100); delete from ks.t where pk = 1 and ck >= 1 and ck <= 2; apply batch;
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t_scylla_cdc_log;
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t_scylla_cdc_log;
|
||||
|
||||
-- do pk delete in batch
|
||||
create table ks.t2 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
|
||||
begin batch insert into ks.t2 (pk, ck, v) values (1, 1, 100); delete from t2 where pk = 1; apply batch;
|
||||
begin batch insert into ks.t2 (pk, ck, v) values (1, 1, 100); delete from ks.t2 where pk = 1; apply batch;
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t2_scylla_cdc_log;
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t2_scylla_cdc_log;
|
||||
|
||||
-- do range delete in batch, but not matcing ck
|
||||
create table ks.t3 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
|
||||
-- do range delete in batch
|
||||
begin batch insert into ks.t3 (pk, ck, v) values (1, 1, 100); delete from t3 where pk = 1 and ck >= 2 and ck <= 3; apply batch;
|
||||
begin batch insert into ks.t3 (pk, ck, v) values (1, 1, 100); delete from ks.t3 where pk = 1 and ck >= 2 and ck <= 3; apply batch;
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t3_scylla_cdc_log;
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t3_scylla_cdc_log;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,111 +1,53 @@
|
||||
-- do range delete in batch
|
||||
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
begin batch insert into ks.t (pk, ck, v) values (1, 1, 100); delete from t where pk = 1 and ck >= 1 and ck <= 2; apply batch;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"v" : "100"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "5",
|
||||
"ck" : "1",
|
||||
"pk" : "1"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "7",
|
||||
"ck" : "2",
|
||||
"pk" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- do pk delete in batch
|
||||
create table ks.t2 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
begin batch insert into ks.t2 (pk, ck, v) values (1, 1, 100); delete from t2 where pk = 1; apply batch;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t2_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"v" : "100"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "4",
|
||||
"pk" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- do range delete in batch, but not matcing ck
|
||||
create table ks.t3 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- do range delete in batch
|
||||
begin batch insert into ks.t3 (pk, ck, v) values (1, 1, 100); delete from t3 where pk = 1 and ck >= 2 and ck <= 3; apply batch;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from t3_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"v" : "100"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "5",
|
||||
"ck" : "2",
|
||||
"pk" : "1"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "7",
|
||||
"ck" : "3",
|
||||
"pk" : "1"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "3",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"v" : "100"
|
||||
}
|
||||
]
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> -- do range delete in batch
|
||||
> create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
OK
|
||||
>
|
||||
> begin batch insert into ks.t (pk, ck, v) values (1, 1, 100); delete from ks.t where pk = 1 and ck >= 1 and ck <= 2; apply batch;
|
||||
OK
|
||||
>
|
||||
> select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t_scylla_cdc_log;
|
||||
+--------------------+-----------------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | pk | ck | v |
|
||||
|--------------------+-----------------+------+------+------|
|
||||
| 0 | 2 | 1 | 1 | 100 |
|
||||
| 1 | 5 | 1 | 1 | null |
|
||||
| 2 | 7 | 1 | 2 | null |
|
||||
+--------------------+-----------------+------+------+------+
|
||||
>
|
||||
> -- do pk delete in batch
|
||||
> create table ks.t2 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
OK
|
||||
>
|
||||
> begin batch insert into ks.t2 (pk, ck, v) values (1, 1, 100); delete from ks.t2 where pk = 1; apply batch;
|
||||
OK
|
||||
>
|
||||
> select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t2_scylla_cdc_log;
|
||||
+--------------------+-----------------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | pk | ck | v |
|
||||
|--------------------+-----------------+------+------+------|
|
||||
| 0 | 2 | 1 | 1 | 100 |
|
||||
| 1 | 4 | 1 | null | null |
|
||||
+--------------------+-----------------+------+------+------+
|
||||
>
|
||||
> -- do range delete in batch, but not matcing ck
|
||||
> create table ks.t3 (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
OK
|
||||
>
|
||||
> -- do range delete in batch
|
||||
> begin batch insert into ks.t3 (pk, ck, v) values (1, 1, 100); delete from ks.t3 where pk = 1 and ck >= 2 and ck <= 3; apply batch;
|
||||
OK
|
||||
>
|
||||
> select "cdc$batch_seq_no", "cdc$operation", pk, ck, v from ks.t3_scylla_cdc_log;
|
||||
+--------------------+-----------------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | pk | ck | v |
|
||||
|--------------------+-----------------+------+------+------|
|
||||
| 0 | 2 | 1 | 1 | 100 |
|
||||
| 1 | 5 | 1 | 2 | null |
|
||||
| 2 | 7 | 1 | 3 | null |
|
||||
| 3 | 9 | 1 | 1 | 100 |
|
||||
+--------------------+-----------------+------+------+------+
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -12,3 +12,5 @@ select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cd
|
||||
-- Should add 3 rows (preimage + postimage + delta).
|
||||
insert into tb3 (pk, ck) VALUES (2, 22) USING TTL 2223;
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cdc_log;
|
||||
drop table tb2;
|
||||
drop table tb3;
|
||||
|
||||
@@ -1,149 +1,54 @@
|
||||
create table tb2 (pk int, ck int, v int, PRIMARY KEY (pk, ck)) with compact storage and cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- Should add 2 rows (postimage + delta).
|
||||
insert into tb2 (pk, ck, v) VALUES (2, 22, 111) USING TTL 2222;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from tb2_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2222",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "111"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- Should add 3 rows (preimage + postimage + delta).
|
||||
insert into tb2 (pk, ck, v) VALUES (2, 22, 1111) USING TTL 2223;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from tb2_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2222",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2223",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "1111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2",
|
||||
"v" : "1111"
|
||||
}
|
||||
]
|
||||
}
|
||||
create table tb3 (pk int, ck int, PRIMARY KEY (pk, ck)) with compact storage and cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- Should add 2 rows (postimage + delta).
|
||||
insert into tb3 (pk, ck) VALUES (2, 22) USING TTL 2222;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2222",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- Should add 3 rows (preimage + postimage + delta).
|
||||
insert into tb3 (pk, ck) VALUES (2, 22) USING TTL 2223;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2222",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"cdc$ttl" : "2223",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
> create table tb2 (pk int, ck int, v int, PRIMARY KEY (pk, ck)) with compact storage and cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
OK
|
||||
> -- Should add 2 rows (postimage + delta).
|
||||
> insert into tb2 (pk, ck, v) VALUES (2, 22, 111) USING TTL 2222;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from tb2_scylla_cdc_log;
|
||||
+--------------------+-----------------+-----------+------+------+-----+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v |
|
||||
|--------------------+-----------------+-----------+------+------+-----|
|
||||
| 0 | 1 | 2222 | 2 | 22 | 111 |
|
||||
| 1 | 9 | null | 2 | 22 | 111 |
|
||||
+--------------------+-----------------+-----------+------+------+-----+
|
||||
> -- Should add 3 rows (preimage + postimage + delta).
|
||||
> insert into tb2 (pk, ck, v) VALUES (2, 22, 1111) USING TTL 2223;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from tb2_scylla_cdc_log;
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v |
|
||||
|--------------------+-----------------+-----------+------+------+------|
|
||||
| 0 | 1 | 2222 | 2 | 22 | 111 |
|
||||
| 1 | 9 | null | 2 | 22 | 111 |
|
||||
| 0 | 0 | null | 2 | 22 | 111 |
|
||||
| 1 | 1 | 2223 | 2 | 22 | 1111 |
|
||||
| 2 | 9 | null | 2 | 22 | 1111 |
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
> create table tb3 (pk int, ck int, PRIMARY KEY (pk, ck)) with compact storage and cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
OK
|
||||
> -- Should add 2 rows (postimage + delta).
|
||||
> insert into tb3 (pk, ck) VALUES (2, 22) USING TTL 2222;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cdc_log;
|
||||
+--------------------+-----------------+-----------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck |
|
||||
|--------------------+-----------------+-----------+------+------|
|
||||
| 0 | 1 | 2222 | 2 | 22 |
|
||||
| 1 | 9 | null | 2 | 22 |
|
||||
+--------------------+-----------------+-----------+------+------+
|
||||
> -- Should add 3 rows (preimage + postimage + delta).
|
||||
> insert into tb3 (pk, ck) VALUES (2, 22) USING TTL 2223;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck from tb3_scylla_cdc_log;
|
||||
+--------------------+-----------------+-----------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck |
|
||||
|--------------------+-----------------+-----------+------+------|
|
||||
| 0 | 1 | 2222 | 2 | 22 |
|
||||
| 1 | 9 | null | 2 | 22 |
|
||||
| 0 | 0 | null | 2 | 22 |
|
||||
| 1 | 1 | 2223 | 2 | 22 |
|
||||
| 2 | 9 | null | 2 | 22 |
|
||||
+--------------------+-----------------+-----------+------+------+
|
||||
> drop table tb2;
|
||||
OK
|
||||
> drop table tb3;
|
||||
OK
|
||||
|
||||
@@ -7,3 +7,4 @@ alter table tb2 with cdc = {'enabled': true, 'preimage': true, 'postimage': true
|
||||
-- Should add 3 rows (preimage + postimage + delta)
|
||||
insert into tb2 (pk, ck, i1) VALUES (3, 33, 333) USING TTL 3333;
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, i1 from tb2_scylla_cdc_log where pk = 3 and ck = 33 allow filtering;
|
||||
drop table tb2;
|
||||
|
||||
@@ -1,60 +1,27 @@
|
||||
create table tb2 (pk int, ck int, i1 int, PRIMARY KEY (pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true, 'delta': 'keys'};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- Should add 3 rows (preimage + postimage + delta). Delta has only key columns and "pk" + "ck"
|
||||
insert into tb2 (pk, ck, i1) VALUES (2, 22, 222) USING TTL 2222;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, i1 from tb2_scylla_cdc_log where pk = 2 and ck = 22 allow filtering;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"cdc$ttl" : "2222",
|
||||
"ck" : "22",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "22",
|
||||
"i1" : "222",
|
||||
"pk" : "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
alter table tb2 with cdc = {'enabled': true, 'preimage': true, 'postimage': true, 'delta': 'full'};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- Should add 3 rows (preimage + postimage + delta)
|
||||
insert into tb2 (pk, ck, i1) VALUES (3, 33, 333) USING TTL 3333;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, i1 from tb2_scylla_cdc_log where pk = 3 and ck = 33 allow filtering;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"cdc$ttl" : "3333",
|
||||
"ck" : "33",
|
||||
"i1" : "333",
|
||||
"pk" : "3"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "9",
|
||||
"ck" : "33",
|
||||
"i1" : "333",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
> create table tb2 (pk int, ck int, i1 int, PRIMARY KEY (pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true, 'delta': 'keys'};
|
||||
OK
|
||||
> -- Should add 3 rows (preimage + postimage + delta). Delta has only key columns and "pk" + "ck"
|
||||
> insert into tb2 (pk, ck, i1) VALUES (2, 22, 222) USING TTL 2222;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, i1 from tb2_scylla_cdc_log where pk = 2 and ck = 22 allow filtering;
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | i1 |
|
||||
|--------------------+-----------------+-----------+------+------+------|
|
||||
| 0 | 2 | 2222 | 2 | 22 | null |
|
||||
| 1 | 9 | null | 2 | 22 | 222 |
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
>
|
||||
> alter table tb2 with cdc = {'enabled': true, 'preimage': true, 'postimage': true, 'delta': 'full'};
|
||||
OK
|
||||
> -- Should add 3 rows (preimage + postimage + delta)
|
||||
> insert into tb2 (pk, ck, i1) VALUES (3, 33, 333) USING TTL 3333;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, i1 from tb2_scylla_cdc_log where pk = 3 and ck = 33 allow filtering;
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | i1 |
|
||||
|--------------------+-----------------+-----------+------+------+------|
|
||||
| 0 | 2 | 3333 | 3 | 33 | 333 |
|
||||
| 1 | 9 | null | 3 | 33 | 333 |
|
||||
+--------------------+-----------------+-----------+------+------+------+
|
||||
> drop table tb2;
|
||||
OK
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
create table tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create table ks.tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
|
||||
create table tb2 (pk int primary key, c1 counter);
|
||||
alter table tb2 with cdc = {'enabled': true};
|
||||
create table ks.tb2 (pk int primary key, c1 counter);
|
||||
alter table ks.tb2 with cdc = {'enabled': true};
|
||||
|
||||
create table tb3 (pk int primary key) with cdc = {'enabled': true};
|
||||
alter table tb3 add (c1 counter);
|
||||
create table ks.tb3 (pk int primary key) with cdc = {'enabled': true};
|
||||
alter table ks.tb3 add (c1 counter);
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
create table tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot create CDC log for table ks.tb1. Counter support not implemented)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
create table tb2 (pk int primary key, c1 counter);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter table tb2 with cdc = {'enabled': true};
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot create CDC log for table ks.tb2. Counter support not implemented)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
create table tb3 (pk int primary key) with cdc = {'enabled': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter table tb3 add (c1 counter);
|
||||
{
|
||||
"message" : "exceptions::configuration_exception (Cannot add a counter column (c1) in a non counter column family)",
|
||||
"status" : "error"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
Error from server: code=2200 [Invalid query] message="Cannot create CDC log for table ks.tb1. Counter support not implemented"
|
||||
>
|
||||
> create table ks.tb2 (pk int primary key, c1 counter);
|
||||
OK
|
||||
> alter table ks.tb2 with cdc = {'enabled': true};
|
||||
Error from server: code=2200 [Invalid query] message="Cannot create CDC log for table ks.tb2. Counter support not implemented"
|
||||
>
|
||||
> create table ks.tb3 (pk int primary key) with cdc = {'enabled': true};
|
||||
OK
|
||||
> alter table ks.tb3 add (c1 counter);
|
||||
<Error from server: code=2300 [Query invalid because of configuration issue] message="Cannot add a counter column (c1) in a non counter column family">
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
create table tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create table ks.tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
|
||||
create materialized view tb1_mv as select * from tb1_scylla_cdc_log where v is not null primary key (v);
|
||||
create materialized view ks.tb1_mv as select * from ks.tb1_scylla_cdc_log where v is not null primary key (v);
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
create table tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
create materialized view tb1_mv as select * from tb1_scylla_cdc_log where v is not null primary key (v);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Materialized views cannot be created on CDC Log tables)",
|
||||
"status" : "error"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
OK
|
||||
>
|
||||
> create materialized view ks.tb1_mv as select * from ks.tb1_scylla_cdc_log where v is not null primary key (v);
|
||||
Error from server: code=2200 [Invalid query] message="Materialized views cannot be created on CDC Log tables"
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
create table tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
alter table tbl_scylla_cdc_log with cdc = {'enabled': true};
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create table ks.tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
alter table ks.tbl_scylla_cdc_log with cdc = {'enabled': true};
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
create table tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter table tbl_scylla_cdc_log with cdc = {'enabled': true};
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot create a CDC log for a table ks.tbl_scylla_cdc_log, because creating nested CDC logs is not allowed)",
|
||||
"status" : "error"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
OK
|
||||
> alter table ks.tbl_scylla_cdc_log with cdc = {'enabled': true};
|
||||
Error from server: code=2200 [Invalid query] message="Cannot create a CDC log for a table ks.tbl_scylla_cdc_log, because creating nested CDC logs is not allowed"
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create table ks.t (pk int, ck int, vs int static, vc int, primary key (pk, ck)) with cdc = {'enabled': true, 'preimage': true};
|
||||
|
||||
-- generates 2 rows: preimage(static), delta(static)
|
||||
@@ -17,5 +19,6 @@ update ks.t set vc = 4 where pk = 1 and ck = 0;
|
||||
update ks.t set vc = 5 where pk = 1 and ck = 0;
|
||||
select "cdc$batch_seq_no", "cdc$operation", ck, vs, vc from ks.t_scylla_cdc_log where pk = 1 and ck = 0 allow filtering;
|
||||
|
||||
-- there should be 16 rows in total
|
||||
-- there should be 13 rows in total
|
||||
select count(*) from ks.t_scylla_cdc_log;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,144 +1,59 @@
|
||||
create table ks.t (pk int, ck int, vs int static, vc int, primary key (pk, ck)) with cdc = {'enabled': true, 'preimage': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- generates 2 rows: preimage(static), delta(static)
|
||||
update ks.t set vs = 0 where pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- generates 2 rows: preimage(static), delta(static)
|
||||
update ks.t set vs = 1 where pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- generates 4 rows: preimage(static), preimage(clustering), delta(static), delta(clustering)
|
||||
update ks.t set vs = 2, vc = 2 where pk = 0 and ck = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- generates 4 rows: preimage(static), preimage(clustering), delta(static), delta(clustering)
|
||||
update ks.t set vs = 3, vc = 3 where pk = 0 and ck = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", ck, vs, vc from ks.t_scylla_cdc_log where pk = 0 allow filtering;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"pk" : "0",
|
||||
"vs" : "0"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"pk" : "0",
|
||||
"vs" : "0"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"pk" : "0",
|
||||
"vs" : "1"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"pk" : "0",
|
||||
"vs" : "1"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"pk" : "0",
|
||||
"vs" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "1",
|
||||
"ck" : "0",
|
||||
"pk" : "0",
|
||||
"vc" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"pk" : "0",
|
||||
"vs" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "0",
|
||||
"pk" : "0",
|
||||
"vc" : "2"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "2",
|
||||
"cdc$operation" : "1",
|
||||
"pk" : "0",
|
||||
"vs" : "3"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "3",
|
||||
"cdc$operation" : "1",
|
||||
"ck" : "0",
|
||||
"pk" : "0",
|
||||
"vc" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- generates 2 rows: preimage(clustering), delta(clustering)
|
||||
update ks.t set vc = 4 where pk = 1 and ck = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- generates 2 rows: preimage(clustering), delta(clustering)
|
||||
update ks.t set vc = 5 where pk = 1 and ck = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select "cdc$batch_seq_no", "cdc$operation", ck, vs, vc from ks.t_scylla_cdc_log where pk = 1 and ck = 0 allow filtering;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "1",
|
||||
"ck" : "0",
|
||||
"pk" : "1",
|
||||
"vc" : "4"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "0",
|
||||
"pk" : "1",
|
||||
"vc" : "4"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"ck" : "0",
|
||||
"pk" : "1",
|
||||
"vc" : "5"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- there should be 16 rows in total
|
||||
select count(*) from ks.t_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"count" : "13"
|
||||
}
|
||||
]
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.t (pk int, ck int, vs int static, vc int, primary key (pk, ck)) with cdc = {'enabled': true, 'preimage': true};
|
||||
OK
|
||||
>
|
||||
> -- generates 2 rows: preimage(static), delta(static)
|
||||
> update ks.t set vs = 0 where pk = 0;
|
||||
OK
|
||||
> -- generates 2 rows: preimage(static), delta(static)
|
||||
> update ks.t set vs = 1 where pk = 0;
|
||||
OK
|
||||
>
|
||||
> -- generates 4 rows: preimage(static), preimage(clustering), delta(static), delta(clustering)
|
||||
> update ks.t set vs = 2, vc = 2 where pk = 0 and ck = 0;
|
||||
OK
|
||||
> -- generates 4 rows: preimage(static), preimage(clustering), delta(static), delta(clustering)
|
||||
> update ks.t set vs = 3, vc = 3 where pk = 0 and ck = 0;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", ck, vs, vc from ks.t_scylla_cdc_log where pk = 0 allow filtering;
|
||||
+--------------------+-----------------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | ck | vs | vc |
|
||||
|--------------------+-----------------+------+------+------|
|
||||
| 0 | 1 | null | 0 | null |
|
||||
| 0 | 0 | null | 0 | null |
|
||||
| 1 | 1 | null | 1 | null |
|
||||
| 0 | 0 | null | 1 | null |
|
||||
| 1 | 1 | null | 2 | null |
|
||||
| 2 | 1 | 0 | null | 2 |
|
||||
| 0 | 0 | null | 2 | null |
|
||||
| 1 | 0 | 0 | null | 2 |
|
||||
| 2 | 1 | null | 3 | null |
|
||||
| 3 | 1 | 0 | null | 3 |
|
||||
+--------------------+-----------------+------+------+------+
|
||||
>
|
||||
> -- generates 2 rows: preimage(clustering), delta(clustering)
|
||||
> update ks.t set vc = 4 where pk = 1 and ck = 0;
|
||||
OK
|
||||
> -- generates 2 rows: preimage(clustering), delta(clustering)
|
||||
> update ks.t set vc = 5 where pk = 1 and ck = 0;
|
||||
OK
|
||||
> select "cdc$batch_seq_no", "cdc$operation", ck, vs, vc from ks.t_scylla_cdc_log where pk = 1 and ck = 0 allow filtering;
|
||||
+--------------------+-----------------+------+------+------+
|
||||
| cdc$batch_seq_no | cdc$operation | ck | vs | vc |
|
||||
|--------------------+-----------------+------+------+------|
|
||||
| 0 | 1 | 0 | null | 4 |
|
||||
| 0 | 0 | 0 | null | 4 |
|
||||
| 1 | 1 | 0 | null | 5 |
|
||||
+--------------------+-----------------+------+------+------+
|
||||
>
|
||||
> -- there should be 13 rows in total
|
||||
> select count(*) from ks.t_scylla_cdc_log;
|
||||
+---------+
|
||||
| count |
|
||||
|---------|
|
||||
| 13 |
|
||||
+---------+
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
create table tb (pk int primary key) with cdc = {'enabled': true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into tb (pk) VALUES (0);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- Key of length != 128 b should return empty result set (issue #6570)
|
||||
select * from tb_scylla_cdc_log where "cdc$stream_id" = 0x00;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
select * from tb_scylla_cdc_log where "cdc$stream_id" = 0x;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
> create table tb (pk int primary key) with cdc = {'enabled': true};
|
||||
OK
|
||||
> insert into tb (pk) VALUES (0);
|
||||
OK
|
||||
>
|
||||
> -- Key of length != 128 b should return empty result set (issue #6570)
|
||||
> select * from tb_scylla_cdc_log where "cdc$stream_id" = 0x00;
|
||||
+-----------------+------------+--------------------+--------------------+-----------------+-----------+------+
|
||||
| cdc$stream_id | cdc$time | cdc$batch_seq_no | cdc$end_of_batch | cdc$operation | cdc$ttl | pk |
|
||||
|-----------------+------------+--------------------+--------------------+-----------------+-----------+------|
|
||||
+-----------------+------------+--------------------+--------------------+-----------------+-----------+------+
|
||||
>
|
||||
> select * from tb_scylla_cdc_log where "cdc$stream_id" = 0x;
|
||||
+-----------------+------------+--------------------+--------------------+-----------------+-----------+------+
|
||||
| cdc$stream_id | cdc$time | cdc$batch_seq_no | cdc$end_of_batch | cdc$operation | cdc$ttl | pk |
|
||||
|-----------------+------------+--------------------+--------------------+-----------------+-----------+------|
|
||||
+-----------------+------------+--------------------+--------------------+-----------------+-----------+------+
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE ks.tbl_cdc_lwt (pk int, ck int, val int, PRIMARY KEY(pk, ck)) WITH cdc = {'enabled':true, 'preimage':true};
|
||||
|
||||
-- (0) successful insert
|
||||
@@ -17,3 +19,4 @@ SELECT "cdc$batch_seq_no", "cdc$operation", ck, pk, val FROM ks.tbl_cdc_lwt_scyl
|
||||
|
||||
-- there should be 6 rows in total: (0) + preimg(0) + (2) + preimg(2) + (4) + preimg(4)
|
||||
SELECT count(*) FROM ks.tbl_cdc_lwt_scylla_cdc_log;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,126 +1,69 @@
|
||||
CREATE TABLE ks.tbl_cdc_lwt (pk int, ck int, val int, PRIMARY KEY(pk, ck)) WITH cdc = {'enabled':true, 'preimage':true};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- (0) successful insert
|
||||
INSERT INTO ks.tbl_cdc_lwt (pk, ck, val) VALUES (1, 1, 111) IF NOT EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- (1) unsuccessful insert
|
||||
INSERT INTO ks.tbl_cdc_lwt (pk, ck, val) VALUES (1, 1, 222) IF NOT EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "111"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- (2) successful update
|
||||
UPDATE ks.tbl_cdc_lwt set val = 333 WHERE pk = 1 and ck = 1 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "111"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- (3) unsuccessful update
|
||||
UPDATE ks.tbl_cdc_lwt set val = 444 WHERE pk = 888 and ck = 777 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- (4) successful row delete
|
||||
DELETE FROM ks.tbl_cdc_lwt WHERE pk = 1 AND ck = 1 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "333"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- (5) unsuccessful row delete
|
||||
DELETE FROM ks.tbl_cdc_lwt WHERE pk = 1 AND ck = 1 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT "cdc$batch_seq_no", "cdc$operation", ck, pk, val FROM ks.tbl_cdc_lwt_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "2",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "111"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "1",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "333"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "0",
|
||||
"cdc$operation" : "0",
|
||||
"ck" : "1",
|
||||
"pk" : "1",
|
||||
"val" : "333"
|
||||
},
|
||||
{
|
||||
"cdc$batch_seq_no" : "1",
|
||||
"cdc$operation" : "3",
|
||||
"ck" : "1",
|
||||
"pk" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- there should be 6 rows in total: (0) + preimg(0) + (2) + preimg(2) + (4) + preimg(4)
|
||||
SELECT count(*) FROM ks.tbl_cdc_lwt_scylla_cdc_log;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"count" : "5"
|
||||
}
|
||||
]
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE ks.tbl_cdc_lwt (pk int, ck int, val int, PRIMARY KEY(pk, ck)) WITH cdc = {'enabled':true, 'preimage':true};
|
||||
OK
|
||||
>
|
||||
> -- (0) successful insert
|
||||
> INSERT INTO ks.tbl_cdc_lwt (pk, ck, val) VALUES (1, 1, 111) IF NOT EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| True | null | null | null |
|
||||
+-------------+------+------+-------+
|
||||
> -- (1) unsuccessful insert
|
||||
> INSERT INTO ks.tbl_cdc_lwt (pk, ck, val) VALUES (1, 1, 222) IF NOT EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| False | 1 | 1 | 111 |
|
||||
+-------------+------+------+-------+
|
||||
> -- (2) successful update
|
||||
> UPDATE ks.tbl_cdc_lwt set val = 333 WHERE pk = 1 and ck = 1 IF EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| True | 1 | 1 | 111 |
|
||||
+-------------+------+------+-------+
|
||||
> -- (3) unsuccessful update
|
||||
> UPDATE ks.tbl_cdc_lwt set val = 444 WHERE pk = 888 and ck = 777 IF EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| False | null | null | null |
|
||||
+-------------+------+------+-------+
|
||||
> -- (4) successful row delete
|
||||
> DELETE FROM ks.tbl_cdc_lwt WHERE pk = 1 AND ck = 1 IF EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| True | 1 | 1 | 333 |
|
||||
+-------------+------+------+-------+
|
||||
> -- (5) unsuccessful row delete
|
||||
> DELETE FROM ks.tbl_cdc_lwt WHERE pk = 1 AND ck = 1 IF EXISTS;
|
||||
+-------------+------+------+-------+
|
||||
| [applied] | pk | ck | val |
|
||||
|-------------+------+------+-------|
|
||||
| False | null | null | null |
|
||||
+-------------+------+------+-------+
|
||||
>
|
||||
> SELECT "cdc$batch_seq_no", "cdc$operation", ck, pk, val FROM ks.tbl_cdc_lwt_scylla_cdc_log;
|
||||
+--------------------+-----------------+------+------+-------+
|
||||
| cdc$batch_seq_no | cdc$operation | ck | pk | val |
|
||||
|--------------------+-----------------+------+------+-------|
|
||||
| 0 | 2 | 1 | 1 | 111 |
|
||||
| 0 | 0 | 1 | 1 | 111 |
|
||||
| 1 | 1 | 1 | 1 | 333 |
|
||||
| 0 | 0 | 1 | 1 | 333 |
|
||||
| 1 | 3 | 1 | 1 | null |
|
||||
+--------------------+-----------------+------+------+-------+
|
||||
>
|
||||
> -- there should be 6 rows in total: (0) + preimg(0) + (2) + preimg(2) + (4) + preimg(4)
|
||||
> SELECT count(*) FROM ks.tbl_cdc_lwt_scylla_cdc_log;
|
||||
+---------+
|
||||
| count |
|
||||
|---------|
|
||||
| 5 |
|
||||
+---------+
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
create table tb1 (pk int primary key, c1 counter) with default_time_to_live = 100;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot set default_time_to_live on a table with counters)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
create table tb2 (pk int primary key, c1 counter);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter table tb2 with default_time_to_live = 100;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot set default_time_to_live on a table with counters)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
create table tb3 (pk int primary key) with default_time_to_live = 100;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter table tb3 add (c1 counter);
|
||||
{
|
||||
"message" : "exceptions::configuration_exception (Cannot add a counter column (c1) in a non counter column family)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
create table tb4 (pk int, ck int, cs counter static, primary KEY (pk, ck)) with default_time_to_live = 100;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot set default_time_to_live on a table with counters)",
|
||||
"status" : "error"
|
||||
}
|
||||
> create table tb1 (pk int primary key, c1 counter) with default_time_to_live = 100;
|
||||
Error from server: code=2200 [Invalid query] message="Cannot set default_time_to_live on a table with counters"
|
||||
>
|
||||
> create table tb2 (pk int primary key, c1 counter);
|
||||
OK
|
||||
> alter table tb2 with default_time_to_live = 100;
|
||||
Error from server: code=2200 [Invalid query] message="Cannot set default_time_to_live on a table with counters"
|
||||
>
|
||||
> create table tb3 (pk int primary key) with default_time_to_live = 100;
|
||||
OK
|
||||
> alter table tb3 add (c1 counter);
|
||||
<Error from server: code=2300 [Query invalid because of configuration issue] message="Cannot add a counter column (c1) in a non counter column family">
|
||||
>
|
||||
> create table tb4 (pk int, ck int, cs counter static, primary KEY (pk, ck)) with default_time_to_live = 100;
|
||||
Error from server: code=2200 [Invalid query] message="Cannot set default_time_to_live on a table with counters"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
|
||||
|
||||
-- insert some values in one column
|
||||
@@ -22,7 +24,7 @@ DELETE c1 from ks.tbl_cnt WHERE pk = 1;
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 1000 ALLOW FILTERING;
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > -1000 ALLOW FILTERING;
|
||||
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
CREATE TABLE counter_bug (t int, c counter, primary key(t));
|
||||
UPDATE counter_bug SET c = c + 9223372036854775807 where t = 0;
|
||||
|
||||
@@ -1,206 +1,126 @@
|
||||
CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- insert some values in one column
|
||||
UPDATE ks.tbl_cnt SET c1 = c1+1 WHERE pk = 1;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
UPDATE ks.tbl_cnt SET c1 = c1+2 WHERE pk = 2;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
UPDATE ks.tbl_cnt SET c1 = c1+3 WHERE pk = 3;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
UPDATE ks.tbl_cnt SET c1 = c1+4 WHERE pk = 4;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- test various filtering options on counter column
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 3 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "1",
|
||||
"pk" : "1"
|
||||
},
|
||||
{
|
||||
"c1" : "2",
|
||||
"pk" : "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 1 ALLOW FILTERING;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 3 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "1",
|
||||
"pk" : "1"
|
||||
},
|
||||
{
|
||||
"c1" : "2",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"c1" : "3",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 2 AND pk = 4 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "4",
|
||||
"pk" : "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 >= 3 and pk = 3 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "3",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 4 ALLOW FILTERING;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 in (-1, 2, 3) ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "2",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"c1" : "3",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 0 ALLOW FILTERING;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "1",
|
||||
"pk" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- delete `c1` and make sure it doesn't appear in filtering results
|
||||
DELETE c1 from ks.tbl_cnt WHERE pk = 1;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 1000 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "2",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"c1" : "4",
|
||||
"pk" : "4"
|
||||
},
|
||||
{
|
||||
"c1" : "3",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > -1000 ALLOW FILTERING;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c1" : "2",
|
||||
"pk" : "2"
|
||||
},
|
||||
{
|
||||
"c1" : "4",
|
||||
"pk" : "4"
|
||||
},
|
||||
{
|
||||
"c1" : "3",
|
||||
"pk" : "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
CREATE TABLE counter_bug (t int, c counter, primary key(t));
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
UPDATE counter_bug SET c = c + 9223372036854775807 where t = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * from counter_bug;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c" : "9223372036854775807",
|
||||
"t" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE counter_bug SET c = c + 1 where t = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * from counter_bug;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c" : "-9223372036854775808",
|
||||
"t" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE counter_bug SET c = c - 1 where t = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * from counter_bug;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c" : "9223372036854775807",
|
||||
"t" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
|
||||
OK
|
||||
>
|
||||
> -- insert some values in one column
|
||||
> UPDATE ks.tbl_cnt SET c1 = c1+1 WHERE pk = 1;
|
||||
OK
|
||||
> UPDATE ks.tbl_cnt SET c1 = c1+2 WHERE pk = 2;
|
||||
OK
|
||||
> UPDATE ks.tbl_cnt SET c1 = c1+3 WHERE pk = 3;
|
||||
OK
|
||||
> UPDATE ks.tbl_cnt SET c1 = c1+4 WHERE pk = 4;
|
||||
OK
|
||||
>
|
||||
> -- test various filtering options on counter column
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 3 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 1 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 3 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 2 AND pk = 4 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 4 | 4 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 >= 3 and pk = 3 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 3 | 3 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 4 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 in (-1, 2, 3) ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 0 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 1 | 1 |
|
||||
+------+------+
|
||||
>
|
||||
> -- delete `c1` and make sure it doesn't appear in filtering results
|
||||
> DELETE c1 from ks.tbl_cnt WHERE pk = 1;
|
||||
OK
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 1000 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 2 | 2 |
|
||||
| 4 | 4 |
|
||||
| 3 | 3 |
|
||||
+------+------+
|
||||
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > -1000 ALLOW FILTERING;
|
||||
+------+------+
|
||||
| pk | c1 |
|
||||
|------+------|
|
||||
| 2 | 2 |
|
||||
| 4 | 4 |
|
||||
| 3 | 3 |
|
||||
+------+------+
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
>
|
||||
> CREATE TABLE counter_bug (t int, c counter, primary key(t));
|
||||
OK
|
||||
> UPDATE counter_bug SET c = c + 9223372036854775807 where t = 0;
|
||||
OK
|
||||
> SELECT * from counter_bug;
|
||||
+-----+---------------------+
|
||||
| t | c |
|
||||
|-----+---------------------|
|
||||
| 0 | 9223372036854775807 |
|
||||
+-----+---------------------+
|
||||
> UPDATE counter_bug SET c = c + 1 where t = 0;
|
||||
OK
|
||||
> SELECT * from counter_bug;
|
||||
+-----+----------------------+
|
||||
| t | c |
|
||||
|-----+----------------------|
|
||||
| 0 | -9223372036854775808 |
|
||||
+-----+----------------------+
|
||||
> UPDATE counter_bug SET c = c - 1 where t = 0;
|
||||
OK
|
||||
> SELECT * from counter_bug;
|
||||
+-----+---------------------+
|
||||
| t | c |
|
||||
|-----+---------------------|
|
||||
| 0 | 9223372036854775807 |
|
||||
+-----+---------------------+
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
create type ut (a int);
|
||||
create table t (pk frozen<ut> primary key);
|
||||
alter type ut add b int;
|
||||
drop table t;
|
||||
alter type ut add c int;
|
||||
create table t2 (pk frozen<list<frozen<ut>>> primary key);
|
||||
alter type ut add d int;
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
create type ks.ut (a int);
|
||||
create table ks.t (pk frozen<ut> primary key);
|
||||
alter type ks.ut add b int;
|
||||
drop table ks.t;
|
||||
alter type ks.ut add c int;
|
||||
create table ks.t2 (pk frozen<list<frozen<ut>>> primary key);
|
||||
alter type ks.ut add d int;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,30 +1,19 @@
|
||||
create type ut (a int);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
create table t (pk frozen<ut> primary key);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter type ut add b int;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot add new field to type ks.ut because it is used in the partition key column pk of table ks.t)",
|
||||
"status" : "error"
|
||||
}
|
||||
drop table t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter type ut add c int;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
create table t2 (pk frozen<list<frozen<ut>>> primary key);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
alter type ut add d int;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Cannot add new field to type ks.ut because it is used in the partition key column pk of table ks.t2)",
|
||||
"status" : "error"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create type ks.ut (a int);
|
||||
OK
|
||||
> create table ks.t (pk frozen<ut> primary key);
|
||||
OK
|
||||
> alter type ks.ut add b int;
|
||||
Error from server: code=2200 [Invalid query] message="Cannot add new field to type ks.ut because it is used in the partition key column pk of table ks.t"
|
||||
> drop table ks.t;
|
||||
OK
|
||||
> alter type ks.ut add c int;
|
||||
OK
|
||||
> create table ks.t2 (pk frozen<list<frozen<ut>>> primary key);
|
||||
OK
|
||||
> alter type ks.ut add d int;
|
||||
Error from server: code=2200 [Invalid query] message="Cannot add new field to type ks.ut because it is used in the partition key column pk of table ks.t2"
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
@@ -1,340 +1,216 @@
|
||||
CREATE TABLE t (pk INT PRIMARY KEY, l LIST<INT>);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
UPDATE t SET l = [-1] + l WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = [-3,-2] + l WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = [-4] + l WHERE pk = 0 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-3, -2, -1]",
|
||||
"pk" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-4, -3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = [-6, -5] + l WHERE pk = 0 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-4, -3, -2, -1]",
|
||||
"pk" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-6, -5, -4, -3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = l + [1] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = l + [2,3] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1, 2, 3]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = l + [4] WHERE pk = 0 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1, 2, 3]",
|
||||
"pk" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1, 2, 3, 4]"
|
||||
}
|
||||
]
|
||||
}
|
||||
UPDATE t SET l = l + [5,6] WHERE pk = 0 IF EXISTS;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1, 2, 3, 4]",
|
||||
"pk" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6]"
|
||||
}
|
||||
]
|
||||
}
|
||||
BEGIN BATCH
|
||||
UPDATE t SET l = l + [7] WHERE pk = 0
|
||||
UPDATE t SET l = [-7] + l WHERE pk = 0
|
||||
UPDATE t SET l = l + [8, 9] WHERE pk = 0
|
||||
UPDATE t SET l = l + [10] WHERE pk = 0
|
||||
UPDATE t SET l = [-9, -8] + l WHERE pk = 0
|
||||
UPDATE t SET l = [-10] + l WHERE pk = 0
|
||||
APPLY BATCH;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- LWT batch
|
||||
BEGIN BATCH
|
||||
UPDATE t SET l = [-11] + l WHERE pk = 0 IF EXISTS
|
||||
UPDATE t SET l = [-13, -12] + l WHERE pk = 0 IF EXISTS
|
||||
UPDATE t SET l = [-14] + l WHERE pk = 0 IF EXISTS
|
||||
UPDATE t SET l = l + [11] WHERE pk = 0 IF EXISTS
|
||||
UPDATE t SET l = l + [12, 13] WHERE pk = 0 IF EXISTS
|
||||
UPDATE t SET l = l + [14] WHERE pk = 0 IF EXISTS
|
||||
APPLY BATCH;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
},
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
},
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
},
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
},
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
},
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"l" : "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
|
||||
"pk" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DROP TABLE t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- test custom timestamps
|
||||
-- Scylla, unlike Cassandra, takes custom timestamps into account
|
||||
-- in list append/prepend operations
|
||||
CREATE TABLE t (pk INT PRIMARY KEY, l LIST<INT>);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- Even though it's an append, since the timestamp is in the past,
|
||||
-- the result is going to be a prepend
|
||||
UPDATE t USING TIMESTAMP 1607100000000000 SET l = l + [-3] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-3]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- append with the same timestamp has an undefined behavior:
|
||||
-- the list key, which is a TIMEUUID, is generated by the coordinator,
|
||||
-- so depends on the coordinator spoof node address. If the coordinator
|
||||
-- happens to be the same, then it generated an identical timestamp, and
|
||||
-- then the the value is reset or skipped, depending on whether it's
|
||||
-- larger or not lexicographically. But if the coordinator is different,
|
||||
-- the value will be appended.
|
||||
-- UPDATE t USING TIMESTAMP 1607100000000000 SET l = l + [-5] WHERE pk = 0;
|
||||
-- SELECT l FROM t WHERE pk = 0;
|
||||
UPDATE t USING TIMESTAMP 1607100000000001 SET l = l + [-2] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-3, -2]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- if a timestamp grows, the new value is after the previous one in the list
|
||||
UPDATE t USING TIMESTAMP 1607100000000002 SET l = l + [-1] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- And if it goes back, it's prepended
|
||||
UPDATE t USING TIMESTAMP 1607099999999999 SET l = l + [-4] WHERE pk = 0;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-4, -3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- The batch has both list append and prepend.
|
||||
-- The relative order of appends and prepends in the batch
|
||||
-- is correct, but since batch timestamp is lower
|
||||
-- than anything that is already in the list cell
|
||||
-- all appends and prepends of the batch end up
|
||||
-- preceding all previous values of the list.
|
||||
BEGIN BATCH USING TIMESTAMP 1607099999999998
|
||||
UPDATE t SET l = [-5] + l WHERE pk = 0
|
||||
UPDATE t SET l = [-7, -6] + l WHERE pk = 0
|
||||
UPDATE t SET l = [-8] + l WHERE pk = 0
|
||||
UPDATE t SET l = l + [0] WHERE pk = 0
|
||||
UPDATE t SET l = l + [1, 2] WHERE pk = 0
|
||||
UPDATE t SET l = l + [3] WHERE pk = 0
|
||||
APPLY BATCH;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-8, -7, -6, -5, 0, 1, 2, 3, -4, -3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- try a very low timestamp
|
||||
BEGIN BATCH USING TIMESTAMP 1000
|
||||
UPDATE t SET l = [-8] + l WHERE pk = 0
|
||||
UPDATE t SET l = [-10, -9] + l WHERE pk = 0
|
||||
UPDATE t SET l = [-11] + l WHERE pk = 0
|
||||
UPDATE t SET l = l + [4] WHERE pk = 0
|
||||
UPDATE t SET l = l + [5, 6] WHERE pk = 0
|
||||
UPDATE t SET l = l + [7] WHERE pk = 0
|
||||
APPLY BATCH;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (List prepend custom timestamp must be greater than Jan 1 2010 00:00:00)",
|
||||
"status" : "error"
|
||||
}
|
||||
SELECT l FROM t WHERE pk = 0;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"l" : "[-8, -7, -6, -5, 0, 1, 2, 3, -4, -3, -2, -1]"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DROP TABLE t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
> CREATE TABLE t (pk INT PRIMARY KEY, l LIST<INT>);
|
||||
OK
|
||||
> UPDATE t SET l = [-1] + l WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+------+
|
||||
| l |
|
||||
|------|
|
||||
| [-1] |
|
||||
+------+
|
||||
> UPDATE t SET l = [-3,-2] + l WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------+
|
||||
| l |
|
||||
|--------------|
|
||||
| [-3, -2, -1] |
|
||||
+--------------+
|
||||
> UPDATE t SET l = [-4] + l WHERE pk = 0 IF EXISTS;
|
||||
+-------------+------+--------------+
|
||||
| [applied] | pk | l |
|
||||
|-------------+------+--------------|
|
||||
| True | 0 | [-3, -2, -1] |
|
||||
+-------------+------+--------------+
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+------------------+
|
||||
| l |
|
||||
|------------------|
|
||||
| [-4, -3, -2, -1] |
|
||||
+------------------+
|
||||
> UPDATE t SET l = [-6, -5] + l WHERE pk = 0 IF EXISTS;
|
||||
+-------------+------+------------------+
|
||||
| [applied] | pk | l |
|
||||
|-------------+------+------------------|
|
||||
| True | 0 | [-4, -3, -2, -1] |
|
||||
+-------------+------+------------------+
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------------------+
|
||||
| l |
|
||||
|--------------------------|
|
||||
| [-6, -5, -4, -3, -2, -1] |
|
||||
+--------------------------+
|
||||
> UPDATE t SET l = l + [1] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+-----------------------------+
|
||||
| l |
|
||||
|-----------------------------|
|
||||
| [-6, -5, -4, -3, -2, -1, 1] |
|
||||
+-----------------------------+
|
||||
> UPDATE t SET l = l + [2,3] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+-----------------------------------+
|
||||
| l |
|
||||
|-----------------------------------|
|
||||
| [-6, -5, -4, -3, -2, -1, 1, 2, 3] |
|
||||
+-----------------------------------+
|
||||
> UPDATE t SET l = l + [4] WHERE pk = 0 IF EXISTS;
|
||||
+-------------+------+-----------------------------------+
|
||||
| [applied] | pk | l |
|
||||
|-------------+------+-----------------------------------|
|
||||
| True | 0 | [-6, -5, -4, -3, -2, -1, 1, 2, 3] |
|
||||
+-------------+------+-----------------------------------+
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------------------------------+
|
||||
| l |
|
||||
|--------------------------------------|
|
||||
| [-6, -5, -4, -3, -2, -1, 1, 2, 3, 4] |
|
||||
+--------------------------------------+
|
||||
> UPDATE t SET l = l + [5,6] WHERE pk = 0 IF EXISTS;
|
||||
+-------------+------+--------------------------------------+
|
||||
| [applied] | pk | l |
|
||||
|-------------+------+--------------------------------------|
|
||||
| True | 0 | [-6, -5, -4, -3, -2, -1, 1, 2, 3, 4] |
|
||||
+-------------+------+--------------------------------------+
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------------------------------------+
|
||||
| l |
|
||||
|--------------------------------------------|
|
||||
| [-6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6] |
|
||||
+--------------------------------------------+
|
||||
> BEGIN BATCH
|
||||
> UPDATE t SET l = l + [7] WHERE pk = 0
|
||||
> UPDATE t SET l = [-7] + l WHERE pk = 0
|
||||
> UPDATE t SET l = l + [8, 9] WHERE pk = 0
|
||||
> UPDATE t SET l = l + [10] WHERE pk = 0
|
||||
> UPDATE t SET l = [-9, -8] + l WHERE pk = 0
|
||||
> UPDATE t SET l = [-10] + l WHERE pk = 0
|
||||
> APPLY BATCH;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------------------------------------------------------------------+
|
||||
| l |
|
||||
|--------------------------------------------------------------------------|
|
||||
| [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
+--------------------------------------------------------------------------+
|
||||
> -- LWT batch
|
||||
> BEGIN BATCH
|
||||
> UPDATE t SET l = [-11] + l WHERE pk = 0 IF EXISTS
|
||||
> UPDATE t SET l = [-13, -12] + l WHERE pk = 0 IF EXISTS
|
||||
> UPDATE t SET l = [-14] + l WHERE pk = 0 IF EXISTS
|
||||
> UPDATE t SET l = l + [11] WHERE pk = 0 IF EXISTS
|
||||
> UPDATE t SET l = l + [12, 13] WHERE pk = 0 IF EXISTS
|
||||
> UPDATE t SET l = l + [14] WHERE pk = 0 IF EXISTS
|
||||
> APPLY BATCH;
|
||||
+-------------+------+--------------------------------------------------------------------------+
|
||||
| [applied] | pk | l |
|
||||
|-------------+------+--------------------------------------------------------------------------|
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
| True | 0 | [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
||||
+-------------+------+--------------------------------------------------------------------------+
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------------------------------------------------------------------------------------------------------+
|
||||
| l |
|
||||
|--------------------------------------------------------------------------------------------------------------|
|
||||
| [-14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
|
||||
+--------------------------------------------------------------------------------------------------------------+
|
||||
>
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
> -- test custom timestamps
|
||||
> -- Scylla, unlike Cassandra, takes custom timestamps into account
|
||||
> -- in list append/prepend operations
|
||||
> CREATE TABLE t (pk INT PRIMARY KEY, l LIST<INT>);
|
||||
OK
|
||||
>
|
||||
> -- Even though it's an append, since the timestamp is in the past,
|
||||
> -- the result is going to be a prepend
|
||||
> UPDATE t USING TIMESTAMP 1607100000000000 SET l = l + [-3] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+------+
|
||||
| l |
|
||||
|------|
|
||||
| [-3] |
|
||||
+------+
|
||||
> -- append with the same timestamp has an undefined behavior:
|
||||
> -- the list key, which is a TIMEUUID, is generated by the coordinator,
|
||||
> -- so depends on the coordinator spoof node address. If the coordinator
|
||||
> -- happens to be the same, then it generated an identical timestamp, and
|
||||
> -- then the the value is reset or skipped, depending on whether it's
|
||||
> -- larger or not lexicographically. But if the coordinator is different,
|
||||
> -- the value will be appended.
|
||||
> -- UPDATE t USING TIMESTAMP 1607100000000000 SET l = l + [-5] WHERE pk = 0;
|
||||
> -- SELECT l FROM t WHERE pk = 0;
|
||||
> UPDATE t USING TIMESTAMP 1607100000000001 SET l = l + [-2] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+----------+
|
||||
| l |
|
||||
|----------|
|
||||
| [-3, -2] |
|
||||
+----------+
|
||||
> -- if a timestamp grows, the new value is after the previous one in the list
|
||||
> UPDATE t USING TIMESTAMP 1607100000000002 SET l = l + [-1] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+--------------+
|
||||
| l |
|
||||
|--------------|
|
||||
| [-3, -2, -1] |
|
||||
+--------------+
|
||||
> -- And if it goes back, it's prepended
|
||||
> UPDATE t USING TIMESTAMP 1607099999999999 SET l = l + [-4] WHERE pk = 0;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+------------------+
|
||||
| l |
|
||||
|------------------|
|
||||
| [-4, -3, -2, -1] |
|
||||
+------------------+
|
||||
> -- The batch has both list append and prepend.
|
||||
> -- The relative order of appends and prepends in the batch
|
||||
> -- is correct, but since batch timestamp is lower
|
||||
> -- than anything that is already in the list cell
|
||||
> -- all appends and prepends of the batch end up
|
||||
> -- preceding all previous values of the list.
|
||||
> BEGIN BATCH USING TIMESTAMP 1607099999999998
|
||||
> UPDATE t SET l = [-5] + l WHERE pk = 0
|
||||
> UPDATE t SET l = [-7, -6] + l WHERE pk = 0
|
||||
> UPDATE t SET l = [-8] + l WHERE pk = 0
|
||||
> UPDATE t SET l = l + [0] WHERE pk = 0
|
||||
> UPDATE t SET l = l + [1, 2] WHERE pk = 0
|
||||
> UPDATE t SET l = l + [3] WHERE pk = 0
|
||||
> APPLY BATCH;
|
||||
OK
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+----------------------------------------------+
|
||||
| l |
|
||||
|----------------------------------------------|
|
||||
| [-8, -7, -6, -5, 0, 1, 2, 3, -4, -3, -2, -1] |
|
||||
+----------------------------------------------+
|
||||
> -- try a very low timestamp
|
||||
> BEGIN BATCH USING TIMESTAMP 1000
|
||||
> UPDATE t SET l = [-8] + l WHERE pk = 0
|
||||
> UPDATE t SET l = [-10, -9] + l WHERE pk = 0
|
||||
> UPDATE t SET l = [-11] + l WHERE pk = 0
|
||||
> UPDATE t SET l = l + [4] WHERE pk = 0
|
||||
> UPDATE t SET l = l + [5, 6] WHERE pk = 0
|
||||
> UPDATE t SET l = l + [7] WHERE pk = 0
|
||||
> APPLY BATCH;
|
||||
Error from server: code=2200 [Invalid query] message="List prepend custom timestamp must be greater than Jan 1 2010 00:00:00"
|
||||
> SELECT l FROM t WHERE pk = 0;
|
||||
+----------------------------------------------+
|
||||
| l |
|
||||
|----------------------------------------------|
|
||||
| [-8, -7, -6, -5, 0, 1, 2, 3, -4, -3, -2, -1] |
|
||||
+----------------------------------------------+
|
||||
>
|
||||
> DROP TABLE t;
|
||||
OK
|
||||
|
||||
@@ -1,101 +1,50 @@
|
||||
--
|
||||
-- https://github.com/scylladb/scylla/issues/7595
|
||||
-- Fail on wrong DC name
|
||||
--
|
||||
CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'nosuchdc' : 3 } AND DURABLE_WRITES = true;
|
||||
{
|
||||
"message" : "exceptions::configuration_exception (Unrecognized strategy option {nosuchdc} passed to org.apache.cassandra.locator.NetworkTopologyStrategy for keyspace t)",
|
||||
"status" : "error"
|
||||
}
|
||||
CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 } AND DURABLE_WRITES = true;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
DROP KEYSPACE t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
--
|
||||
-- https://github.com/scylladb/scylla/issues/5962
|
||||
-- wrong de-facto replication factor
|
||||
-- when RF=0 and SimpleStrategy
|
||||
--
|
||||
CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 0 } AND DURABLE_WRITES = true;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
CREATE TABLE t.t (a INT PRIMARY KEY, b int);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO t.t (a, b) VALUES (1, 1);
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
INSERT INTO t.t (a, b) VALUES (2, 2);
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
SELECT * FROM t.t ALLOW FILTERING;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
-- This statement used to trigger a crash
|
||||
SELECT a FROM t.t WHERE a IN (1, 2);
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
DELETE FROM t.t WHERE a = 1;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
DELETE FROM t.t WHERE a = 2;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
CREATE INDEX b ON t.t (b);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * FROM t.t WHERE b=2;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
INSERT INTO t.t (a) VALUES (1) IF NOT EXISTS;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl SERIAL. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
DELETE FROM t.t WHERE a=1 IF EXISTS;
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl SERIAL. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
CREATE MATERIALIZED VIEW t.mv AS SELECT a, b FROM t.t WHERE b > 1 PRIMARY KEY (b, a);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * FROM t.mv WHERE b IN (2, 1);
|
||||
{
|
||||
"message" : "exceptions::unavailable_exception (Cannot achieve consistency level for cl ONE. Requires 1, alive 0)",
|
||||
"status" : "error"
|
||||
}
|
||||
DROP MATERIALIZED VIEW t.mv;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
DROP TABLE t.t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
DROP KEYSPACE t;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
> --
|
||||
> -- https://github.com/scylladb/scylla/issues/7595
|
||||
> -- Fail on wrong DC name
|
||||
> --
|
||||
> CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'nosuchdc' : 3 } AND DURABLE_WRITES = true;
|
||||
<Error from server: code=2300 [Query invalid because of configuration issue] message="Unrecognized strategy option {nosuchdc} passed to org.apache.cassandra.locator.NetworkTopologyStrategy for keyspace t">
|
||||
> CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 } AND DURABLE_WRITES = true;
|
||||
OK
|
||||
> DROP KEYSPACE t;
|
||||
OK
|
||||
> --
|
||||
> -- https://github.com/scylladb/scylla/issues/5962
|
||||
> -- wrong de-facto replication factor
|
||||
> -- when RF=0 and SimpleStrategy
|
||||
> --
|
||||
> CREATE KEYSPACE t WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 0 } AND DURABLE_WRITES = true;
|
||||
OK
|
||||
> CREATE TABLE t.t (a INT PRIMARY KEY, b int);
|
||||
OK
|
||||
> INSERT INTO t.t (a, b) VALUES (1, 1);
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> INSERT INTO t.t (a, b) VALUES (2, 2);
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> SELECT * FROM t.t ALLOW FILTERING;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> -- This statement used to trigger a crash
|
||||
> SELECT a FROM t.t WHERE a IN (1, 2);
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> DELETE FROM t.t WHERE a = 1;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> DELETE FROM t.t WHERE a = 2;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> CREATE INDEX b ON t.t (b);
|
||||
OK
|
||||
> SELECT * FROM t.t WHERE b=2;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> INSERT INTO t.t (a) VALUES (1) IF NOT EXISTS;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl SERIAL. Requires 1, alive 0" info={\'consistency\': \'SERIAL\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> DELETE FROM t.t WHERE a=1 IF EXISTS;
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl SERIAL. Requires 1, alive 0" info={\'consistency\': \'SERIAL\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> CREATE MATERIALIZED VIEW t.mv AS SELECT a, b FROM t.t WHERE b > 1 PRIMARY KEY (b, a);
|
||||
OK
|
||||
> SELECT * FROM t.mv WHERE b IN (2, 1);
|
||||
('Unable to complete the operation against any hosts', {<Host: 127.0.0.1:9042 datacenter1>: Unavailable('Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level for cl ONE. Requires 1, alive 0" info={\'consistency\': \'ONE\', \'required_replicas\': 1, \'alive_replicas\': 0}')})
|
||||
> DROP MATERIALIZED VIEW t.mv;
|
||||
OK
|
||||
> DROP TABLE t.t;
|
||||
OK
|
||||
> DROP KEYSPACE t;
|
||||
OK
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
-- setup
|
||||
create table my_table (key int primary key);
|
||||
insert into my_table (key) values (1);
|
||||
create table ks.my_table (key int primary key);
|
||||
insert into ks.my_table (key) values (1);
|
||||
|
||||
-- test list<varint>
|
||||
create function my_func(val int) called on null input returns list<varint> language lua as 'return {1,2,3}';
|
||||
select my_func(key) from my_table;
|
||||
drop function my_func;
|
||||
create function ks.my_func(val int) called on null input returns list<varint> language lua as 'return {1,2,3}';
|
||||
select ks.my_func(key) from ks.my_table;
|
||||
drop function ks.my_func;
|
||||
|
||||
-- test list<decimal>
|
||||
create function my_func(val int) called on null input returns list<decimal> language lua as 'return {1,2,3}';
|
||||
select my_func(key) from my_table;
|
||||
drop function my_func;
|
||||
create function ks.my_func(val int) called on null input returns list<decimal> language lua as 'return {1,2,3}';
|
||||
select ks.my_func(key) from ks.my_table;
|
||||
drop function ks.my_func;
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,47 +1,34 @@
|
||||
-- setup
|
||||
create table my_table (key int primary key);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into my_table (key) values (1);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- test list<varint>
|
||||
create function my_func(val int) called on null input returns list<varint> language lua as 'return {1,2,3}';
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select my_func(key) from my_table;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"ks.my_func(key)" : "[1, 2, 3]"
|
||||
}
|
||||
]
|
||||
}
|
||||
drop function my_func;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
-- test list<decimal>
|
||||
create function my_func(val int) called on null input returns list<decimal> language lua as 'return {1,2,3}';
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
select my_func(key) from my_table;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"ks.my_func(key)" : "[1, 2, 3]"
|
||||
}
|
||||
]
|
||||
}
|
||||
drop function my_func;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> -- setup
|
||||
> create table ks.my_table (key int primary key);
|
||||
OK
|
||||
> insert into ks.my_table (key) values (1);
|
||||
OK
|
||||
>
|
||||
> -- test list<varint>
|
||||
> create function ks.my_func(val int) called on null input returns list<varint> language lua as 'return {1,2,3}';
|
||||
OK
|
||||
> select ks.my_func(key) from ks.my_table;
|
||||
+-------------------+
|
||||
| ks.my_func(key) |
|
||||
|-------------------|
|
||||
| [1, 2, 3] |
|
||||
+-------------------+
|
||||
> drop function ks.my_func;
|
||||
OK
|
||||
>
|
||||
> -- test list<decimal>
|
||||
> create function ks.my_func(val int) called on null input returns list<decimal> language lua as 'return {1,2,3}';
|
||||
OK
|
||||
> select ks.my_func(key) from ks.my_table;
|
||||
+--------------------------------------------+
|
||||
| ks.my_func(key) |
|
||||
|--------------------------------------------|
|
||||
| [Decimal('1'), Decimal('2'), Decimal('3')] |
|
||||
+--------------------------------------------+
|
||||
> drop function ks.my_func;
|
||||
OK
|
||||
> DROP KEYSPACE ks;
|
||||
OK
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,13 @@
|
||||
CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
USE k;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
CREATE TABLE t1 (userid int PRIMARY KEY);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
CREATE TABLE t2 (userid int PRIMARY KEY);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
BEGIN BATCH
|
||||
INSERT INTO t1 (userid) VALUES (1) IF NOT EXISTS
|
||||
INSERT INTO t2 (userid) VALUES (1) IF NOT EXISTS
|
||||
APPLY BATCH;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (BATCH with conditions cannot span multiple tables)",
|
||||
"status" : "error"
|
||||
}
|
||||
> CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> USE k;
|
||||
OK
|
||||
> CREATE TABLE t1 (userid int PRIMARY KEY);
|
||||
OK
|
||||
> CREATE TABLE t2 (userid int PRIMARY KEY);
|
||||
OK
|
||||
> BEGIN BATCH
|
||||
> INSERT INTO t1 (userid) VALUES (1) IF NOT EXISTS
|
||||
> INSERT INTO t2 (userid) VALUES (1) IF NOT EXISTS
|
||||
> APPLY BATCH;
|
||||
Error from server: code=2200 [Invalid query] message="BATCH with conditions cannot span multiple tables"
|
||||
|
||||
@@ -1,144 +1,80 @@
|
||||
create table t (pk int primary key, c text);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into t (pk, c) values (1, 'abc');
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into t (pk, c) values (2, 'bcd');
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into t (pk, c) values (3, 'cde');
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- match
|
||||
update t set c = 'chg' where pk = 1 if c like 'a%';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"c" : "\"abc\""
|
||||
}
|
||||
]
|
||||
}
|
||||
update t set c = 'chg' where pk = 2 if c like 'b%';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"c" : "\"bcd\""
|
||||
}
|
||||
]
|
||||
}
|
||||
update t set c = 'chg' where pk = 3 if c like 'c%';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "true",
|
||||
"c" : "\"cde\""
|
||||
}
|
||||
]
|
||||
}
|
||||
-- null value
|
||||
insert into t (pk, c) values (3, null);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
update t set c = 'error' where pk = 3 if c like 'a%';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- unset value
|
||||
insert into t json '{ "pk": 4 }' default unset;
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
update t set c = 'err' where pk = 4 if c like 'a%';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- empty pattern
|
||||
update t set c = 'err' where pk = 1 if c like '';
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"[applied]" : "false",
|
||||
"c" : "\"chg\""
|
||||
}
|
||||
]
|
||||
}
|
||||
-- invalid pattern type
|
||||
update t set c = 'err' where pk = 1 if c like 1;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid INTEGER constant (1) for \"c\" of type text)",
|
||||
"status" : "error"
|
||||
}
|
||||
update t set c = 'err' where pk = 1 if c like null;
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid NULL value in LIKE pattern)",
|
||||
"status" : "error"
|
||||
}
|
||||
update t set c = 'err' where pk = 1 if c like bigintAsBlob(1);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Type error: cannot assign result of function system.bigintasblob (type blob) to c (type text))",
|
||||
"status" : "error"
|
||||
}
|
||||
-- int column
|
||||
create table ti (pk int primary key, c int);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into ti (pk, c) values (1, 1);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
update ti set c = 2 where pk = 1 if c like 'a%';
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid STRING constant (a%) for \"c\" of type int)",
|
||||
"status" : "error"
|
||||
}
|
||||
-- map column
|
||||
create table tm (pk int primary key, m map<int, text>);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into tm (pk, m) values (1, { 1: 'abc' });
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
update tm set m = { 2: 'error' } where pk = 1 if m like 'a%';
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid STRING constant (a%) for \"m\" of type map<int, text>)",
|
||||
"status" : "error"
|
||||
}
|
||||
-- blob column
|
||||
create table tb (pk int primary key, b blob);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
insert into tb (pk, b) values (1, bigintAsBlob(1));
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
update tb set b = bigintAsBlob(2) where pk = 1 if b like 'a%';
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid STRING constant (a%) for \"b\" of type blob)",
|
||||
"status" : "error"
|
||||
}
|
||||
> create table t (pk int primary key, c text);
|
||||
OK
|
||||
> insert into t (pk, c) values (1, 'abc');
|
||||
OK
|
||||
> insert into t (pk, c) values (2, 'bcd');
|
||||
OK
|
||||
> insert into t (pk, c) values (3, 'cde');
|
||||
OK
|
||||
> -- match
|
||||
> update t set c = 'chg' where pk = 1 if c like 'a%';
|
||||
+-------------+-----+
|
||||
| [applied] | c |
|
||||
|-------------+-----|
|
||||
| True | abc |
|
||||
+-------------+-----+
|
||||
> update t set c = 'chg' where pk = 2 if c like 'b%';
|
||||
+-------------+-----+
|
||||
| [applied] | c |
|
||||
|-------------+-----|
|
||||
| True | bcd |
|
||||
+-------------+-----+
|
||||
> update t set c = 'chg' where pk = 3 if c like 'c%';
|
||||
+-------------+-----+
|
||||
| [applied] | c |
|
||||
|-------------+-----|
|
||||
| True | cde |
|
||||
+-------------+-----+
|
||||
> -- null value
|
||||
> insert into t (pk, c) values (3, null);
|
||||
OK
|
||||
> update t set c = 'error' where pk = 3 if c like 'a%';
|
||||
+-------------+------+
|
||||
| [applied] | c |
|
||||
|-------------+------|
|
||||
| False | null |
|
||||
+-------------+------+
|
||||
> -- unset value
|
||||
> insert into t json '{ "pk": 4 }' default unset;
|
||||
OK
|
||||
> update t set c = 'err' where pk = 4 if c like 'a%';
|
||||
+-------------+------+
|
||||
| [applied] | c |
|
||||
|-------------+------|
|
||||
| False | null |
|
||||
+-------------+------+
|
||||
> -- empty pattern
|
||||
> update t set c = 'err' where pk = 1 if c like '';
|
||||
+-------------+-----+
|
||||
| [applied] | c |
|
||||
|-------------+-----|
|
||||
| False | chg |
|
||||
+-------------+-----+
|
||||
> -- invalid pattern type
|
||||
> update t set c = 'err' where pk = 1 if c like 1;
|
||||
Error from server: code=2200 [Invalid query] message="Invalid INTEGER constant (1) for "c" of type text"
|
||||
> update t set c = 'err' where pk = 1 if c like null;
|
||||
Error from server: code=2200 [Invalid query] message="Invalid NULL value in LIKE pattern"
|
||||
> update t set c = 'err' where pk = 1 if c like bigintAsBlob(1);
|
||||
Error from server: code=2200 [Invalid query] message="Type error: cannot assign result of function system.bigintasblob (type blob) to c (type text)"
|
||||
> -- int column
|
||||
> create table ti (pk int primary key, c int);
|
||||
OK
|
||||
> insert into ti (pk, c) values (1, 1);
|
||||
OK
|
||||
> update ti set c = 2 where pk = 1 if c like 'a%';
|
||||
Error from server: code=2200 [Invalid query] message="Invalid STRING constant (a%) for "c" of type int"
|
||||
> -- map column
|
||||
> create table tm (pk int primary key, m map<int, text>);
|
||||
OK
|
||||
> insert into tm (pk, m) values (1, { 1: 'abc' });
|
||||
OK
|
||||
> update tm set m = { 2: 'error' } where pk = 1 if m like 'a%';
|
||||
Error from server: code=2200 [Invalid query] message="Invalid STRING constant (a%) for "m" of type map<int, text>"
|
||||
> -- blob column
|
||||
> create table tb (pk int primary key, b blob);
|
||||
OK
|
||||
> insert into tb (pk, b) values (1, bigintAsBlob(1));
|
||||
OK
|
||||
> update tb set b = bigintAsBlob(2) where pk = 1 if b like 'a%';
|
||||
Error from server: code=2200 [Invalid query] message="Invalid STRING constant (a%) for "b" of type blob"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +1,33 @@
|
||||
-- Simple test case for local materialized views with synchronous local updates.
|
||||
-- A view is local when its partition key definition is the same as base's,
|
||||
-- which results in locating view partition on the same node as the base table.
|
||||
CREATE TABLE t (p1 int, p2 int, c int, v int, primary key ((p1,p2),c));
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
-- a local view - with identical partition key
|
||||
CREATE MATERIALIZED VIEW tv AS SELECT * FROM t WHERE p1 IS NOT NULL AND p2 IS NOT NULL AND c IS NOT NULL AND v IS NOT NULL PRIMARY KEY ((p1,p2),v,c);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO t (p1, p2, c, v) VALUES (1,2,3,4);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO t (p1, p2, c, v) VALUES (2,3,4,5);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * FROM tv;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c" : "4",
|
||||
"p1" : "2",
|
||||
"p2" : "3",
|
||||
"v" : "5"
|
||||
},
|
||||
{
|
||||
"c" : "3",
|
||||
"p1" : "1",
|
||||
"p2" : "2",
|
||||
"v" : "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
-- a local index - with underlying local view
|
||||
CREATE INDEX ON t(v);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO t (p1, p2, c, v) VALUES (3,4,5,6);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO t (p1, p2, c, v) VALUES (4,5,6,6);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
SELECT * FROM t WHERE v = 6;
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"c" : "5",
|
||||
"p1" : "3",
|
||||
"p2" : "4",
|
||||
"v" : "6"
|
||||
},
|
||||
{
|
||||
"c" : "6",
|
||||
"p1" : "4",
|
||||
"p2" : "5",
|
||||
"v" : "6"
|
||||
}
|
||||
]
|
||||
}
|
||||
> -- Simple test case for local materialized views with synchronous local updates.
|
||||
> -- A view is local when its partition key definition is the same as base's,
|
||||
> -- which results in locating view partition on the same node as the base table.
|
||||
> CREATE TABLE t (p1 int, p2 int, c int, v int, primary key ((p1,p2),c));
|
||||
OK
|
||||
> -- a local view - with identical partition key
|
||||
> CREATE MATERIALIZED VIEW tv AS SELECT * FROM t WHERE p1 IS NOT NULL AND p2 IS NOT NULL AND c IS NOT NULL AND v IS NOT NULL PRIMARY KEY ((p1,p2),v,c);
|
||||
OK
|
||||
> INSERT INTO t (p1, p2, c, v) VALUES (1,2,3,4);
|
||||
OK
|
||||
> INSERT INTO t (p1, p2, c, v) VALUES (2,3,4,5);
|
||||
OK
|
||||
> SELECT * FROM tv;
|
||||
+------+------+-----+-----+
|
||||
| p1 | p2 | v | c |
|
||||
|------+------+-----+-----|
|
||||
| 2 | 3 | 5 | 4 |
|
||||
| 1 | 2 | 4 | 3 |
|
||||
+------+------+-----+-----+
|
||||
> -- a local index - with underlying local view
|
||||
> CREATE INDEX ON t(v);
|
||||
OK
|
||||
> INSERT INTO t (p1, p2, c, v) VALUES (3,4,5,6);
|
||||
OK
|
||||
> INSERT INTO t (p1, p2, c, v) VALUES (4,5,6,6);
|
||||
OK
|
||||
> SELECT * FROM t WHERE v = 6;
|
||||
+------+------+-----+-----+
|
||||
| p1 | p2 | c | v |
|
||||
|------+------+-----+-----|
|
||||
| 3 | 4 | 5 | 6 |
|
||||
| 4 | 5 | 6 | 6 |
|
||||
+------+------+-----+-----+
|
||||
|
||||
@@ -1,510 +1,271 @@
|
||||
create table foo (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH CLUSTERING ORDER BY (b DESC, c ASC);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
INSERT INTO foo (a, b, c) VALUES (0, 2, 0);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO foo (a, b, c) VALUES (0, 1, 0);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO foo (a, b, c) VALUES (0, 1, 1);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
INSERT INTO foo (a, b, c) VALUES (0, 0, 0);
|
||||
{
|
||||
"status" : "ok"
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > (1, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > (2, 0);
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) >= (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) >= SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) < (1, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (1, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) < (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) <= (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) <= SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > (1);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > (2);
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) >= (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) >= SCYLLA_CLUSTERING_BOUND (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) < (1);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (1);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) < (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (2);
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) <= (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) <= SCYLLA_CLUSTERING_BOUND (2);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > (1) AND (b, c) <= (2, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "2",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1) AND (b, c) <= SCYLLA_CLUSTERING_BOUND (0, 0);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "0",
|
||||
"c" : "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > (2) AND (b, c) <= (2, 1);
|
||||
{
|
||||
"rows" : null
|
||||
}
|
||||
|
||||
SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2) AND (b, c) <= SCYLLA_CLUSTERING_BOUND(1, 1);
|
||||
{
|
||||
"rows" :
|
||||
[
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "0"
|
||||
},
|
||||
{
|
||||
"a" : "0",
|
||||
"b" : "1",
|
||||
"c" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-- error checks --
|
||||
|
||||
-- wrong side of condition
|
||||
SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > (2);
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND')",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- both sides of condition
|
||||
SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > SCYLLA_CLUSTERING_BOUND(2);
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND')",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- too many values --
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0, 5);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Expected 2 elements in value tuple, but got 3: (1, 0, 5))",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- too few values --
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Expected 2 elements in value tuple, but got 1: (1))",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- missing values --
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND;
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:64 : syntax error...\n)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- not tuple --
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND 45;
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:65 missing '(' at '<missing ')",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- just wrong --
|
||||
SELECT * FROM foo WHERE a=0 SCYLLA_CLUSTERING_BOUND AND (b, c) > (0, 1);
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:28 : syntax error...\n)",
|
||||
"status" : "error"
|
||||
}
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > (0, 1) SCYLLA_CLUSTERING_BOUND;
|
||||
{
|
||||
"message" : "exceptions::syntax_exception (line 1:48 : syntax error...\n)",
|
||||
"status" : "error"
|
||||
}
|
||||
|
||||
-- mixing apples and make_count_rows_function
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (1, 1);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain))",
|
||||
"status" : "error"
|
||||
}
|
||||
-- and again --
|
||||
SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (2, 0);
|
||||
{
|
||||
"message" : "exceptions::invalid_request_exception (Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain))",
|
||||
"status" : "error"
|
||||
}
|
||||
> create table foo (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH CLUSTERING ORDER BY (b DESC, c ASC);
|
||||
OK
|
||||
>
|
||||
> INSERT INTO foo (a, b, c) VALUES (0, 2, 0);
|
||||
OK
|
||||
> INSERT INTO foo (a, b, c) VALUES (0, 1, 0);
|
||||
OK
|
||||
> INSERT INTO foo (a, b, c) VALUES (0, 1, 1);
|
||||
OK
|
||||
> INSERT INTO foo (a, b, c) VALUES (0, 0, 0);
|
||||
OK
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > (1, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) >= (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) >= SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) < (1, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (1, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) < (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) < SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) <= (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) <= SCYLLA_CLUSTERING_BOUND (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > (1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) >= (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) >= SCYLLA_CLUSTERING_BOUND (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) < (1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) < (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) < SCYLLA_CLUSTERING_BOUND (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) <= (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) <= SCYLLA_CLUSTERING_BOUND (2);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
>
|
||||
>
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > (1) AND (b, c) <= (2, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 2 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (1) AND (b, c) <= SCYLLA_CLUSTERING_BOUND (0, 0);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 0 | 0 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > (2) AND (b, c) <= (2, 1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> SELECT * FROM foo WHERE a=0 AND (b) > SCYLLA_CLUSTERING_BOUND (2) AND (b, c) <= SCYLLA_CLUSTERING_BOUND(1, 1);
|
||||
+-----+-----+-----+
|
||||
| a | b | c |
|
||||
|-----+-----+-----|
|
||||
| 0 | 1 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
+-----+-----+-----+
|
||||
>
|
||||
> -- error checks --
|
||||
>
|
||||
> -- wrong side of condition
|
||||
> SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > (2);
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND'">
|
||||
>
|
||||
> -- both sides of condition
|
||||
> SELECT * FROM foo WHERE a=0 AND SCYLLA_CLUSTERING_BOUND(b) > SCYLLA_CLUSTERING_BOUND(2);
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:32 no viable alternative at input 'SCYLLA_CLUSTERING_BOUND'">
|
||||
>
|
||||
> -- too many values --
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1, 0, 5);
|
||||
Error from server: code=2200 [Invalid query] message="Expected 2 elements in value tuple, but got 3: (1, 0, 5)"
|
||||
>
|
||||
> -- too few values --
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND (1);
|
||||
Error from server: code=2200 [Invalid query] message="Expected 2 elements in value tuple, but got 1: (1)"
|
||||
>
|
||||
> -- missing values --
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND;
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:64 : syntax error...
|
||||
">
|
||||
>
|
||||
> -- not tuple --
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND 45;
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:65 missing '(' at '<missing '">
|
||||
>
|
||||
> -- just wrong --
|
||||
> SELECT * FROM foo WHERE a=0 SCYLLA_CLUSTERING_BOUND AND (b, c) > (0, 1);
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:28 : syntax error...
|
||||
">
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > (0, 1) SCYLLA_CLUSTERING_BOUND;
|
||||
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:48 : syntax error...
|
||||
">
|
||||
>
|
||||
> -- mixing apples and make_count_rows_function
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (1, 1);
|
||||
Error from server: code=2200 [Invalid query] message="Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain)"
|
||||
> -- and again --
|
||||
> SELECT * FROM foo WHERE a=0 AND (b, c) > SCYLLA_CLUSTERING_BOUND(2, 0) AND (b, c) < (2, 0);
|
||||
Error from server: code=2200 [Invalid query] message="Invalid combination of restrictions (SCYLLA_CLUSTERING_BOUND / plain)"
|
||||
|
||||
@@ -1 +1 @@
|
||||
type: CQL
|
||||
type: Approval
|
||||
|
||||
Reference in New Issue
Block a user