2012-08-17 21:13:20 +04:00
|
|
|
drop table if exists t0, t1;
|
|
|
|
create table t1 (a int) engine=cassandra
|
|
|
|
thrift_host='localhost' keyspace='foo' column_family='colfam';
|
2012-08-29 10:05:21 +04:00
|
|
|
ERROR 42000: Incorrect column name 'First column must be NOT NULL'
|
2012-08-17 21:13:20 +04:00
|
|
|
create table t1 (a int primary key, b int) engine=cassandra
|
|
|
|
thrift_host='localhost' keyspace='foo' column_family='colfam';
|
2012-08-29 10:05:21 +04:00
|
|
|
ERROR HY000: Unable to connect to foreign data source: Default TException. [Keyspace foo does not exist]
|
2012-08-17 21:13:20 +04:00
|
|
|
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 HY000: Unable to connect to foreign data source: connect() failed: Connection refused [1]
|
|
|
|
create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra
|
|
|
|
thrift_host='localhost' keyspace='no_such_keyspace' column_family='colfam';
|
|
|
|
ERROR HY000: Unable to connect to foreign data source: Default TException. [Keyspace no_such_keyspace does not exist]
|
|
|
|
create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra
|
|
|
|
thrift_host='localhost' keyspace='no_such_keyspace';
|
2012-08-19 12:50:53 +04:00
|
|
|
ERROR HY000: Unable to connect to foreign data source: thrift_host, keyspace, and column_family table options must be s
|
2012-08-19 13:21:23 +04:00
|
|
|
# Now, create a table for real and insert data
|
2012-08-29 10:05:21 +04:00
|
|
|
create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra
|
2012-08-18 21:21:50 +04:00
|
|
|
thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1';
|
2012-08-19 13:21:23 +04:00
|
|
|
# Just in case there were left-overs from previous:
|
|
|
|
delete from t1;
|
2012-08-19 12:50:53 +04:00
|
|
|
select * from t1;
|
2012-08-29 10:05:21 +04:00
|
|
|
pk data1 data2
|
2012-08-18 21:21:50 +04:00
|
|
|
insert into t1 values ('rowkey10', 'data1-value', 123456);
|
|
|
|
insert into t1 values ('rowkey11', 'data1-value2', 34543);
|
2012-08-19 12:50:53 +04:00
|
|
|
insert into t1 values ('rowkey12', 'data1-value3', 454);
|
2012-08-18 21:21:50 +04:00
|
|
|
select * from t1;
|
2012-08-29 10:05:21 +04:00
|
|
|
pk data1 data2
|
2012-08-19 12:50:53 +04:00
|
|
|
rowkey12 data1-value3 454
|
|
|
|
rowkey10 data1-value 123456
|
|
|
|
rowkey11 data1-value2 34543
|
|
|
|
explain
|
2012-08-29 10:05:21 +04:00
|
|
|
select * from t1 where pk='rowkey11';
|
2012-08-19 12:50:53 +04:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 const PRIMARY PRIMARY 38 const 1
|
2012-08-29 10:05:21 +04:00
|
|
|
select * from t1 where pk='rowkey11';
|
|
|
|
pk data1 data2
|
2012-08-19 12:50:53 +04:00
|
|
|
rowkey11 data1-value2 34543
|
2012-08-29 10:05:21 +04:00
|
|
|
delete from t1 where pk='rowkey11';
|
2012-08-19 13:21:23 +04:00
|
|
|
select * from t1;
|
2012-08-29 10:05:21 +04:00
|
|
|
pk data1 data2
|
2012-08-19 13:21:23 +04:00
|
|
|
rowkey12 data1-value3 454
|
|
|
|
rowkey10 data1-value 123456
|
|
|
|
rowkey11 NULL NULL
|
2012-08-18 21:29:31 +04:00
|
|
|
delete from t1;
|
|
|
|
select * from t1;
|
2012-08-29 10:05:21 +04:00
|
|
|
pk data1 data2
|
2012-08-21 18:38:27 +04:00
|
|
|
#
|
|
|
|
# A query with filesort (check that table_flags() & HA_REC_NOT_IN_SEQ,
|
|
|
|
# also check ::rnd_pos()
|
|
|
|
#
|
|
|
|
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;
|
2012-08-29 10:05:21 +04:00
|
|
|
pk data1 data2
|
2012-08-21 18:38:27 +04:00
|
|
|
rowkey12 data1-value3 454
|
|
|
|
rowkey11 data1-value2 34543
|
|
|
|
rowkey10 data1-value 123456
|
|
|
|
delete from t1;
|
2012-08-17 21:13:20 +04:00
|
|
|
drop table t1;
|
2012-08-23 16:15:28 +04:00
|
|
|
#
|
|
|
|
# MDEV-476: Cassandra: Server crashes in calculate_key_len on DELETE with ORDER BY
|
|
|
|
#
|
|
|
|
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;
|
2012-08-26 16:06:39 +04:00
|
|
|
#
|
|
|
|
# Batched INSERT
|
|
|
|
#
|
|
|
|
show variables like 'cassandra_insert_batch_size';
|
|
|
|
Variable_name Value
|
|
|
|
cassandra_insert_batch_size 100
|
|
|
|
show status like 'cassandra_row_insert%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_row_inserts 8
|
|
|
|
Cassandra_row_insert_batches 7
|
|
|
|
CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA
|
|
|
|
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2';
|
2012-08-27 08:44:58 +04:00
|
|
|
delete from t1;
|
2012-08-26 16:06:39 +04:00
|
|
|
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%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_row_inserts 10
|
|
|
|
Cassandra_row_insert_batches 8
|
|
|
|
# FLUSH STATUS doesn't work for our variables, just like with InnoDB.
|
|
|
|
flush status;
|
|
|
|
show status like 'cassandra_row_insert%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_row_inserts 10
|
|
|
|
Cassandra_row_insert_batches 8
|
2012-08-27 08:44:58 +04:00
|
|
|
#
|
|
|
|
# Batched Key Access
|
|
|
|
#
|
|
|
|
# Control variable (we are not yet able to make use of MRR's buffer)
|
|
|
|
show variables like 'cassandra_multi%';
|
|
|
|
Variable_name Value
|
|
|
|
cassandra_multiget_batch_size 100
|
|
|
|
# MRR-related status variables:
|
|
|
|
show status like 'cassandra_multi%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_multiget_reads 0
|
|
|
|
Cassandra_multiget_keys_scanned 0
|
|
|
|
Cassandra_multiget_rows_read 0
|
|
|
|
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;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE A ALL NULL NULL NULL NULL 1000 Using where
|
|
|
|
1 SIMPLE B eq_ref PRIMARY PRIMARY 8 test.A.a 1 Using join buffer (flat, BKAH join); multiget_slice
|
|
|
|
select * from t1 A, t1 B where B.rowkey=A.a;
|
|
|
|
rowkey a rowkey a
|
|
|
|
0 0 0 0
|
|
|
|
1 1 1 1
|
|
|
|
2 2 2 2
|
|
|
|
3 3 3 3
|
|
|
|
4 4 4 4
|
|
|
|
5 5 5 5
|
|
|
|
6 6 6 6
|
|
|
|
7 7 7 7
|
|
|
|
8 8 8 8
|
|
|
|
9 9 9 9
|
|
|
|
show status like 'cassandra_multi%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_multiget_reads 1
|
|
|
|
Cassandra_multiget_keys_scanned 10
|
|
|
|
Cassandra_multiget_rows_read 10
|
|
|
|
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;
|
|
|
|
rowkey a rowkey a
|
|
|
|
0 0 0 0
|
|
|
|
2 2 2 2
|
|
|
|
4 4 4 4
|
|
|
|
6 6 6 6
|
|
|
|
1 8 8 8
|
|
|
|
7 8 8 8
|
|
|
|
8 8 8 8
|
|
|
|
5 8 8 8
|
|
|
|
3 8 8 8
|
|
|
|
9 9 9 9
|
|
|
|
show status like 'cassandra_multi%';
|
|
|
|
Variable_name Value
|
|
|
|
Cassandra_multiget_reads 2
|
|
|
|
Cassandra_multiget_keys_scanned 16
|
|
|
|
Cassandra_multiget_rows_read 16
|
|
|
|
delete from t1;
|
|
|
|
drop table t1;
|
2012-08-28 12:53:33 +04:00
|
|
|
#
|
|
|
|
# MDEV-480: TRUNCATE TABLE on a Cassandra table does not remove rows
|
|
|
|
#
|
|
|
|
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;
|
|
|
|
rowkey a
|
|
|
|
drop table t1;
|
2012-08-28 20:22:45 +04:00
|
|
|
#
|
|
|
|
# MDEV-494, part #1: phantom row for big full-scan selects
|
|
|
|
#
|
|
|
|
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;
|
|
|
|
count(*)
|
|
|
|
1000
|
|
|
|
select count(*) from t1 where a=12345;
|
|
|
|
count(*)
|
|
|
|
1000
|
|
|
|
delete from t1;
|
|
|
|
drop table t1;
|
|
|
|
drop table t0;
|
2012-08-29 10:05:21 +04:00
|
|
|
# 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;
|
|
|
|
#
|
|
|
|
# Try accessing column family w/o explicitly defined columns
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (my_primary_key varchar(10) PRIMARY KEY) ENGINE=CASSANDRA
|
|
|
|
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10';
|
|
|
|
ERROR HY000: Internal error: 'target column family has no key_alias defined, PRIMARY KEY column must be named 'rowkey''
|
|
|
|
CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY) ENGINE=CASSANDRA
|
|
|
|
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10';
|
|
|
|
DROP TABLE t1;
|
2012-08-29 11:05:46 +04:00
|
|
|
#
|
|
|
|
# Timestamp datatype support
|
|
|
|
#
|
|
|
|
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;
|
|
|
|
rowkey datecol
|
|
|
|
1 2012-08-29 01:23:45
|
|
|
|
delete from t2;
|
2012-08-29 20:27:11 +04:00
|
|
|
#
|
|
|
|
# (no MDEV#) Check that insert counters work correctly
|
|
|
|
#
|
|
|
|
create table t0 (a int);
|
|
|
|
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
set cassandra_insert_batch_size=10;
|
|
|
|
insert into t2 select A.a+10*B.a, now() from t0 A, t0 B;
|
|
|
|
inserts insert_batches
|
|
|
|
100 10
|
|
|
|
set cassandra_insert_batch_size=1;
|
|
|
|
insert into t2 select A.a+10*B.a+100, now() from t0 A, t0 B;
|
|
|
|
inserts insert_batches
|
|
|
|
100 100
|
|
|
|
delete from t2;
|
2012-08-29 11:05:46 +04:00
|
|
|
drop table t2;
|
2012-08-29 20:27:11 +04:00
|
|
|
drop table t0;
|
2012-08-31 10:49:36 +04:00
|
|
|
#
|
|
|
|
# UUID datatype support
|
|
|
|
#
|
|
|
|
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');
|
|
|
|
insert into t2 values(2,'not-an-uuid');
|
|
|
|
ERROR 22003: Out of range value for column 'uuidcol' at row 1
|
|
|
|
insert into t2 values(3,'9b5658dc-f32f-11e1=94cd-f46d046e9f09');
|
|
|
|
ERROR 22003: Out of range value for column 'uuidcol' at row 1
|
|
|
|
insert into t2 values(4,'9b5658dc-fzzf-11e1-94cd-f46d046e9f09');
|
|
|
|
ERROR 22003: Out of range value for column 'uuidcol' at row 1
|
|
|
|
insert into t2 values
|
|
|
|
(5,'9b5658dc-f11f-11e1-94cd-f46d046e9f09'),
|
|
|
|
(6,'9b5658dc-f11f011e1-94cd-f46d046e9f09');
|
|
|
|
ERROR 22003: Out of range value for column 'uuidcol' at row 2
|
|
|
|
select * from t2;
|
|
|
|
rowkey uuidcol
|
|
|
|
1 9b5658dc-f32f-11e1-94cd-f46d046e9f09
|
|
|
|
5 9b5658dc-f11f-11e1-94cd-f46d046e9f09
|
|
|
|
delete from t2;
|
|
|
|
drop table t2;
|
|
|
|
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);
|
|
|
|
insert into t2 values('not-an-uuid', 563);
|
|
|
|
ERROR 22003: Out of range value for column 'rowkey' at row 1
|
|
|
|
select * from t2;
|
|
|
|
rowkey col1
|
|
|
|
9b5658dc-f32f-11e1-94cd-f46d046e9f09 1234
|
|
|
|
delete from t2;
|
|
|
|
drop table t2;
|