1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
#
# Tests for cassandra storage engine
#
--source include/have_cassandra.inc
--disable_warnings
drop table if exists t0, t1;
--enable_warnings
# Test various errors on table creation.
--error ER_WRONG_COLUMN_NAME
create table t1 (a int) engine=cassandra
thrift_host='localhost' keyspace='foo' column_family='colfam';
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
create table t1 (a int primary key, b int) engine=cassandra
thrift_host='localhost' keyspace='foo' column_family='colfam';
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra
thrift_host='127.0.0.2' keyspace='foo' column_family='colfam';
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra
thrift_host='localhost' keyspace='no_such_keyspace' column_family='colfam';
# No column family specified
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra
thrift_host='localhost' keyspace='no_such_keyspace';
############################################################################
## Cassandra initialization:
############################################################################
--disable_parsing
./cqlsh --cql3
CREATE KEYSPACE mariadbtest2
WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy'
AND strategy_options:replication_factor='1';
USE mariadbtest2;
create columnfamily cf1 ( pk varchar primary key, data1 varchar, data2 bigint);
create columnfamily cf2 (rowkey bigint primary key, a bigint);
create columnfamily cf3 (rowkey bigint primary key, intcol int);
create columnfamily cf4 (rowkey bigint primary key, datecol timestamp);
create columnfamily cf5 (rowkey bigint primary key, uuidcol uuid);
create columnfamily cf6 (rowkey uuid primary key, col1 int);
./cassandra-cli
CREATE COLUMN FAMILY cf10
WITH comparator = UTF8Type
AND key_validation_class=UTF8Type
AND default_validation_class = UTF8Type;
--enable_parsing
############################################################################
## Cassandra initialization ends
############################################################################
--echo # Now, create a table for real and insert data
create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra
thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1';
--echo # Just in case there were left-overs from previous:
delete from t1;
select * from t1;
insert into t1 values ('rowkey10', 'data1-value', 123456);
insert into t1 values ('rowkey11', 'data1-value2', 34543);
insert into t1 values ('rowkey12', 'data1-value3', 454);
select * from t1;
explain
select * from t1 where pk='rowkey11';
select * from t1 where pk='rowkey11';
# Deletion functions weirdly: it sets all columns to NULL
# but when If I do this in cassandra-cli:
#
# del cf1[ascii('rowkey10')]
#
# Subsequent 'list cf1' command also gives
#
# RowKey: rowkey10
#
# without any columns.
#
# CQL seems to simply ignore all "incomplete" records.
delete from t1 where pk='rowkey11';
select * from t1;
delete from t1;
select * from t1;
--echo #
--echo # A query with filesort (check that table_flags() & HA_REC_NOT_IN_SEQ,
--echo # also check ::rnd_pos()
--echo #
insert into t1 values ('rowkey10', 'data1-value', 123456);
insert into t1 values ('rowkey11', 'data1-value2', 34543);
insert into t1 values ('rowkey12', 'data1-value3', 454);
select * from t1 order by data2;
delete from t1;
drop table t1;
--echo #
--echo # MDEV-476: Cassandra: Server crashes in calculate_key_len on DELETE with ORDER BY
--echo #
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
INSERT INTO t1 VALUES (1,1),(2,2);
DELETE FROM t1 ORDER BY a LIMIT 1;
DROP TABLE t1;
--echo #
--echo # Batched INSERT
--echo #
show variables like 'cassandra_insert_batch_size';
show status like 'cassandra_row_insert%';
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
delete from t1;
INSERT INTO t1 VALUES (1,1),(2,2);
DELETE FROM t1 ORDER BY a LIMIT 1;
DROP TABLE t1;
show status like 'cassandra_row_insert%';
--echo # FLUSH STATUS doesn't work for our variables, just like with InnoDB.
flush status;
show status like 'cassandra_row_insert%';
--echo #
--echo # Batched Key Access
--echo #
--echo # Control variable (we are not yet able to make use of MRR's buffer)
show variables like 'cassandra_multi%';
--echo # MRR-related status variables:
show status like 'cassandra_multi%';
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
delete from t1;
INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
set @tmp_jcl=@@join_cache_level;
set join_cache_level=8;
explain select * from t1 A, t1 B where B.rowkey=A.a;
select * from t1 A, t1 B where B.rowkey=A.a;
show status like 'cassandra_multi%';
# The following INSERTs are really UPDATEs
insert into t1 values(1, 8);
insert into t1 values(3, 8);
insert into t1 values(5, 8);
insert into t1 values(7, 8);
select * from t1 A, t1 B where B.rowkey=A.a;
show status like 'cassandra_multi%';
delete from t1;
drop table t1;
--echo #
--echo # MDEV-480: TRUNCATE TABLE on a Cassandra table does not remove rows
--echo #
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
INSERT INTO t1 VALUES (0,0),(1,1),(2,2);
truncate table t1;
select * from t1;
drop table t1;
--echo #
--echo # MDEV-494, part #1: phantom row for big full-scan selects
--echo #
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
insert into t1 select A.a + 10 * B.a + 100*C.a, 12345 from t0 A, t0 B, t0 C;
select count(*) from t1;
select count(*) from t1 where a=12345;
delete from t1;
drop table t1;
drop table t0;
--echo # 32-bit INT type support
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, intcol INT) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf3';
insert into t1 values (10,10);
insert into t1 values (12,12);
delete from t1;
drop table t1;
--echo #
--echo # Try accessing column family w/o explicitly defined columns
--echo #
--error ER_INTERNAL_ERROR
CREATE TABLE t1 (my_primary_key varchar(10) PRIMARY KEY) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10';
CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10';
DROP TABLE t1;
--echo #
--echo # Timestamp datatype support
--echo #
CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol timestamp) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4';
delete from t2;
insert into t2 values (1, '2012-08-29 01:23:45');
select * from t2;
delete from t2;
--echo # MDEV-498: Cassandra: Inserting a timestamp does not work on a 32-bit system
INSERT INTO t2 VALUES (10,'2012-12-12 12:12:12');
SELECT * FROM t2;
delete from t2;
--echo #
--echo # (no MDEV#) Check that insert counters work correctly
--echo #
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
let $start_inserts=`select variable_value from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_inserts'`;
let $start_insert_batches=`select variable_value from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_insert_batches'`;
set cassandra_insert_batch_size=10;
insert into t2 select A.a+10*B.a, now() from t0 A, t0 B;
--disable_query_log
eval select
(select variable_value - $start_inserts from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_inserts')
AS 'inserts',
(select variable_value - $start_insert_batches from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_insert_batches')
AS 'insert_batches';
--enable_query_log
let $start_inserts=`select variable_value from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_inserts'`;
let $start_insert_batches=`select variable_value from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_insert_batches'`;
set cassandra_insert_batch_size=1;
insert into t2 select A.a+10*B.a+100, now() from t0 A, t0 B;
--disable_query_log
eval select
(select variable_value - $start_inserts from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_inserts')
AS 'inserts',
(select variable_value - $start_insert_batches from information_schema.SESSION_STATUS
where variable_name ='Cassandra_row_insert_batches')
AS 'insert_batches';
--enable_query_log
delete from t2;
drop table t2;
drop table t0;
--echo #
--echo # UUID datatype support
--echo #
#create columnfamily cf5 (rowkey bigint primary key, uuidcol uuid);
CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5';
delete from t2;
insert into t2 values(1,'9b5658dc-f32f-11e1-94cd-f46d046e9f09');
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t2 values(2,'not-an-uuid');
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t2 values(3,'9b5658dc-f32f-11e1=94cd-f46d046e9f09');
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t2 values(4,'9b5658dc-fzzf-11e1-94cd-f46d046e9f09');
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t2 values
(5,'9b5658dc-f11f-11e1-94cd-f46d046e9f09'),
(6,'9b5658dc-f11f011e1-94cd-f46d046e9f09');
select * from t2;
delete from t2;
drop table t2;
# create columnfamily cf6 (rowkey uuid primary key, col1 int);
CREATE TABLE t2 (rowkey char(36) PRIMARY KEY, col1 int) ENGINE=CASSANDRA
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf6';
delete from t2;
insert into t2 values('9b5658dc-f32f-11e1-94cd-f46d046e9f09', 1234);
--error ER_WARN_DATA_OUT_OF_RANGE
insert into t2 values('not-an-uuid', 563);
select * from t2;
delete from t2;
drop table t2;
############################################################################
## Cassandra cleanup
############################################################################
--disable_parsing
drop columnfamily cf1;
drop columnfamily cf2;
drop columnfamily cf3;
drop columnfamily cf4;
--enable_parsing
############################################################################
## Cassandra cleanup ends
############################################################################
|