1drop table if exists t0, t1; 2# 3# Check variables and status counters 4# 5show status like 'cassandra%'; 6Variable_name Value 7Cassandra_row_inserts 0 8Cassandra_row_insert_batches 0 9Cassandra_multiget_keys_scanned 0 10Cassandra_multiget_reads 0 11Cassandra_multiget_rows_read 0 12Cassandra_network_exceptions 0 13Cassandra_timeout_exceptions 0 14Cassandra_unavailable_exceptions 0 15show variables like 'cassandra%'; 16Variable_name Value 17cassandra_default_thrift_host 18cassandra_failure_retries 3 19cassandra_insert_batch_size 100 20cassandra_multiget_batch_size 100 21cassandra_read_consistency ONE 22cassandra_rnd_batch_size 10000 23cassandra_write_consistency ONE 24# 25# Test various errors on table creation. 26# 27create table t1 (a int) engine=cassandra 28thrift_host='localhost' keyspace='foo' column_family='colfam'; 29ERROR 42000: This table type requires a primary key 30create table t1 (a int primary key, b int) engine=cassandra 31thrift_host='localhost' keyspace='foo' column_family='colfam'; 32ERROR HY000: Unable to connect to foreign data source: Default TException. [Keyspace foo does not exist] 33create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra 34thrift_host='127.0.0.2' keyspace='foo' column_family='colfam'; 35ERROR HY000: Unable to connect to foreign data source: connect() failed: Connection refused [1] 36create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra 37thrift_host='localhost' keyspace='no_such_keyspace' column_family='colfam'; 38ERROR HY000: Unable to connect to foreign data source: Default TException. [Keyspace no_such_keyspace does not exist] 39create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra 40thrift_host='localhost' keyspace='no_such_keyspace'; 41ERROR HY000: Unable to connect to foreign data source: keyspace and column_family table options must be specified 42# Now, create a table for real and insert data 43create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra 44thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; 45# Just in case there were left-overs from previous: 46delete from t1; 47select * from t1; 48pk data1 data2 49insert into t1 values ('rowkey10', 'data1-value', 123456); 50insert into t1 values ('rowkey11', 'data1-value2', 34543); 51insert into t1 values ('rowkey12', 'data1-value3', 454); 52select * from t1; 53pk data1 data2 54rowkey12 data1-value3 454 55rowkey10 data1-value 123456 56rowkey11 data1-value2 34543 57explain 58select * from t1 where pk='rowkey11'; 59id select_type table type possible_keys key key_len ref rows Extra 601 SIMPLE t1 const PRIMARY PRIMARY 38 const 1 61select * from t1 where pk='rowkey11'; 62pk data1 data2 63rowkey11 data1-value2 34543 64delete from t1 where pk='rowkey11'; 65select * from t1; 66pk data1 data2 67rowkey12 data1-value3 454 68rowkey10 data1-value 123456 69delete from t1; 70select * from t1; 71pk data1 data2 72# 73# A query with filesort (check that table_flags() & HA_REC_NOT_IN_SEQ, 74# also check ::rnd_pos() 75# 76insert into t1 values ('rowkey10', 'data1-value', 123456); 77insert into t1 values ('rowkey11', 'data1-value2', 34543); 78insert into t1 values ('rowkey12', 'data1-value3', 454); 79select * from t1 order by data2; 80pk data1 data2 81rowkey12 data1-value3 454 82rowkey11 data1-value2 34543 83rowkey10 data1-value 123456 84delete from t1; 85drop table t1; 86# 87# MDEV-476: Cassandra: Server crashes in calculate_key_len on DELETE with ORDER BY 88# 89CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA 90thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 91INSERT INTO t1 VALUES (1,1),(2,2); 92DELETE FROM t1 ORDER BY a LIMIT 1; 93DROP TABLE t1; 94# 95# Batched INSERT 96# 97show variables like 'cassandra_insert_batch_size'; 98Variable_name Value 99cassandra_insert_batch_size 100 100show status like 'cassandra_row_insert%'; 101Variable_name Value 102Cassandra_row_inserts 8 103Cassandra_row_insert_batches 7 104CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA 105thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 106delete from t1; 107INSERT INTO t1 VALUES (1,1),(2,2); 108DELETE FROM t1 ORDER BY a LIMIT 1; 109DROP TABLE t1; 110show status like 'cassandra_row_insert%'; 111Variable_name Value 112Cassandra_row_inserts 10 113Cassandra_row_insert_batches 8 114# FLUSH STATUS doesn't work for our variables, just like with InnoDB. 115flush status; 116show status like 'cassandra_row_insert%'; 117Variable_name Value 118Cassandra_row_inserts 10 119Cassandra_row_insert_batches 8 120# 121# Batched Key Access 122# 123# Control variable (we are not yet able to make use of MRR's buffer) 124show variables like 'cassandra_multi%'; 125Variable_name Value 126cassandra_multiget_batch_size 100 127# MRR-related status variables: 128show status like 'cassandra_multi%'; 129Variable_name Value 130Cassandra_multiget_keys_scanned 0 131Cassandra_multiget_reads 0 132Cassandra_multiget_rows_read 0 133CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA 134thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 135delete from t1; 136INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); 137set @tmp_jcl=@@join_cache_level; 138set join_cache_level=8; 139explain select * from t1 A, t1 B where B.rowkey=A.a; 140id select_type table type possible_keys key key_len ref rows Extra 1411 SIMPLE A ALL NULL NULL NULL NULL 1000 Using where 1421 SIMPLE B eq_ref PRIMARY PRIMARY 8 test.A.a 1 Using join buffer (flat, BKAH join); multiget_slice 143select * from t1 A, t1 B where B.rowkey=A.a; 144rowkey a rowkey a 1450 0 0 0 1461 1 1 1 1472 2 2 2 1483 3 3 3 1494 4 4 4 1505 5 5 5 1516 6 6 6 1527 7 7 7 1538 8 8 8 1549 9 9 9 155show status like 'cassandra_multi%'; 156Variable_name Value 157Cassandra_multiget_keys_scanned 10 158Cassandra_multiget_reads 1 159Cassandra_multiget_rows_read 10 160insert into t1 values(1, 8); 161insert into t1 values(3, 8); 162insert into t1 values(5, 8); 163insert into t1 values(7, 8); 164select * from t1 A, t1 B where B.rowkey=A.a; 165rowkey a rowkey a 1660 0 0 0 1672 2 2 2 1684 4 4 4 1696 6 6 6 1701 8 8 8 1717 8 8 8 1728 8 8 8 1735 8 8 8 1743 8 8 8 1759 9 9 9 176show status like 'cassandra_multi%'; 177Variable_name Value 178Cassandra_multiget_keys_scanned 16 179Cassandra_multiget_reads 2 180Cassandra_multiget_rows_read 16 181delete from t1; 182drop table t1; 183# 184# MDEV-480: TRUNCATE TABLE on a Cassandra table does not remove rows 185# 186CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA 187thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 188INSERT INTO t1 VALUES (0,0),(1,1),(2,2); 189truncate table t1; 190select * from t1; 191rowkey a 192drop table t1; 193# 194# MDEV-494, part #1: phantom row for big full-scan selects 195# 196create table t0 (a int); 197insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 198CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, a BIGINT) ENGINE=CASSANDRA 199thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 200insert into t1 select A.a + 10 * B.a + 100*C.a, 12345 from t0 A, t0 B, t0 C; 201select count(*) from t1; 202count(*) 2031000 204select count(*) from t1 where a=12345; 205count(*) 2061000 207delete from t1; 208drop table t1; 209drop table t0; 210# 32-bit INT type support 211CREATE TABLE t1 (rowkey BIGINT PRIMARY KEY, intcol INT) ENGINE=CASSANDRA 212thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf3'; 213insert into t1 values (10,10); 214insert into t1 values (12,12); 215delete from t1; 216drop table t1; 217# 218# Try accessing column family w/o explicitly defined columns 219# 220CREATE TABLE t1 (my_primary_key varchar(10) PRIMARY KEY) ENGINE=CASSANDRA 221thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10'; 222ERROR HY000: Internal error: target column family has no key_alias defined, PRIMARY KEY column must be named 'rowkey' 223CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY) ENGINE=CASSANDRA 224thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf10'; 225DROP TABLE t1; 226# 227# Timestamp datatype support 228# 229CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol timestamp) ENGINE=CASSANDRA 230thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; 231delete from t2; 232insert into t2 values (1, '2012-08-29 01:23:45'); 233select * from t2; 234rowkey datecol 2351 2012-08-29 01:23:45 236delete from t2; 237# MDEV-498: Cassandra: Inserting a timestamp does not work on a 32-bit system 238INSERT INTO t2 VALUES (10,'2012-12-12 12:12:12'); 239SELECT * FROM t2; 240rowkey datecol 24110 2012-12-12 12:12:12 242delete from t2; 243# 244# (no MDEV#) Check that insert counters work correctly 245# 246create table t0 (a int); 247insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 248set cassandra_insert_batch_size=10; 249insert into t2 select A.a+10*B.a, now() from t0 A, t0 B; 250inserts insert_batches 251100 10 252set cassandra_insert_batch_size=1; 253insert into t2 select A.a+10*B.a+100, now() from t0 A, t0 B; 254inserts insert_batches 255100 100 256delete from t2; 257drop table t2; 258drop table t0; 259# 260# UUID datatype support 261# 262CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA 263thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 264delete from t2; 265insert into t2 values(1,'9b5658dc-f32f-11e1-94cd-f46d046e9f09'); 266insert into t2 values(2,'not-an-uuid'); 267ERROR 22003: Out of range value for column 'uuidcol' at row 1 268insert into t2 values(3,'9b5658dc-f32f-11e1=94cd-f46d046e9f09'); 269ERROR 22003: Out of range value for column 'uuidcol' at row 1 270insert into t2 values(4,'9b5658dc-fzzf-11e1-94cd-f46d046e9f09'); 271ERROR 22003: Out of range value for column 'uuidcol' at row 1 272insert into t2 values 273(5,'9b5658dc-f11f-11e1-94cd-f46d046e9f09'), 274(6,'9b5658dc-f11f011e1-94cd-f46d046e9f09'); 275ERROR 22003: Out of range value for column 'uuidcol' at row 2 276select * from t2; 277rowkey uuidcol 2781 9b5658dc-f32f-11e1-94cd-f46d046e9f09 2795 9b5658dc-f11f-11e1-94cd-f46d046e9f09 280delete from t2; 281drop table t2; 282CREATE TABLE t2 (rowkey char(36) PRIMARY KEY, col1 int) ENGINE=CASSANDRA 283thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf6'; 284delete from t2; 285insert into t2 values('9b5658dc-f32f-11e1-94cd-f46d046e9f09', 1234); 286insert into t2 values('not-an-uuid', 563); 287ERROR 22003: Out of range value for column 'rowkey' at row 1 288select * from t2; 289rowkey col1 2909b5658dc-f32f-11e1-94cd-f46d046e9f09 1234 291delete from t2; 292drop table t2; 293# 294# boolean datatype support 295# 296CREATE TABLE t2 (rowkey int PRIMARY KEY, boolcol bool) ENGINE=CASSANDRA 297thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7'; 298insert into t2 values (0, 0); 299insert into t2 values (1, 1); 300select * from t2; 301rowkey boolcol 3020 0 3031 1 304delete from t2; 305drop table t2; 306# 307# Counter datatype support (read-only) 308# 309CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, countercol bigint) ENGINE=CASSANDRA 310thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf8'; 311select * from t2; 312rowkey countercol 313cnt1 1 314cnt2 100 315drop table t2; 316# 317# Check that @@cassandra_default_thrift_host works 318# 319show variables like 'cassandra_default_thrift_host'; 320Variable_name Value 321cassandra_default_thrift_host 322set @tmp=@@cassandra_default_thrift_host; 323set cassandra_default_thrift_host='localhost'; 324ERROR HY000: Variable 'cassandra_default_thrift_host' is a GLOBAL variable and should be set with SET GLOBAL 325set global cassandra_default_thrift_host='localhost'; 326# Try creating a table without specifying thrift_host: 327CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, countercol bigint) ENGINE=CASSANDRA 328keyspace='mariadbtest2' column_family = 'cf8'; 329select * from t2; 330rowkey countercol 331cnt1 1 332cnt2 100 333drop table t2; 334set global cassandra_default_thrift_host=@tmp; 335# 336# Consistency settings 337# 338show variables like 'cassandra_%consistency'; 339Variable_name Value 340cassandra_read_consistency ONE 341cassandra_write_consistency ONE 342set @tmp=@@cassandra_write_consistency; 343# Unfortunately, there is no easy way to check if setting have the effect.. 344set cassandra_write_consistency='ONE'; 345set cassandra_write_consistency='QUORUM'; 346set cassandra_write_consistency='LOCAL_QUORUM'; 347set cassandra_write_consistency='EACH_QUORUM'; 348set cassandra_write_consistency='ALL'; 349set cassandra_write_consistency='ANY'; 350set cassandra_write_consistency='TWO'; 351set cassandra_write_consistency='THREE'; 352set cassandra_write_consistency=@tmp; 353# 354# varint datatype support 355# 356CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, varint_col varbinary(32)) ENGINE=CASSANDRA 357thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf9'; 358select rowkey, hex(varint_col) from t2; 359rowkey hex(varint_col) 360val-01 01 361val-0x123456 123456 362val-0x12345678 12345678 363drop table t2; 364# now, let's check what happens when MariaDB's column is not wide enough: 365CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, varint_col varbinary(2)) ENGINE=CASSANDRA 366thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf9'; 367select rowkey, hex(varint_col) from t2; 368ERROR HY000: Internal error: Unable to convert value for field `varint_col` from Cassandra's data format. Source data is 4 bytes, 0x12345678 369drop table t2; 370# 371# Decimal datatype support 372# 373CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA 374thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; 375select rowkey, hex(decimal_col) from t2; 376rowkey hex(decimal_col) 377val_1.5 000000010F 378val_0.5 0000000105 379val_1234 0000000004D2 380drop table t2; 381# 382# Mapping TIMESTAMP -> int64 383# 384set @save_tz= @@time_zone; 385set time_zone='UTC'; 386CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol timestamp) ENGINE=CASSANDRA 387thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; 388insert into t2 values (1, '2012-08-29 01:23:45'); 389INSERT INTO t2 VALUES (10,'2012-08-29 01:23:46'); 390drop table t2; 391CREATE TABLE t2 (rowkey bigint PRIMARY KEY, datecol bigint) ENGINE=CASSANDRA 392thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; 393select * from t2; 394rowkey datecol 3951 1346203425000 39610 1346203426000 397delete from t2; 398drop table t2; 399set time_zone=@save_tz; 400# 401# Check whether changing parameters with ALTER TABLE works. 402# 403CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA 404thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; 405drop table t2; 406CREATE TABLE t2 (rowkey varchar(32) PRIMARY KEY, decimal_col varbinary(32)) ENGINE=CASSANDRA 407thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf11'; 408alter table t2 column_family='cf12'; 409Writes made during ALTER TABLE 4100 411drop table t2; 412# 413# UPDATE command support 414# 415create table t1 (pk varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra 416thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1'; 417insert into t1 values ('rowkey10', 'data1-value', 123456); 418insert into t1 values ('rowkey11', 'data1-value2', 34543); 419insert into t1 values ('rowkey12', 'data1-value3', 454); 420select * from t1; 421pk data1 data2 422rowkey12 data1-value3 454 423rowkey10 data1-value 123456 424rowkey11 data1-value2 34543 425update t1 set data1='updated-1' where pk='rowkey11'; 426select * from t1; 427pk data1 data2 428rowkey12 data1-value3 454 429rowkey10 data1-value 123456 430rowkey11 updated-1 34543 431update t1 set pk='new-rowkey12' where pk='rowkey12'; 432select * from t1; 433pk data1 data2 434rowkey10 data1-value 123456 435new-rowkey12 data1-value3 454 436rowkey11 updated-1 34543 437delete from t1; 438drop table t1; 439# 440# Dynamic columns support 441# 442CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol blob DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 443drop table t2; 444#error: dynamic column is not a blob 445CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36) DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 446ERROR 42000: Incorrect column specifier for column 'uuidcol' 447#error: double dynamic column 448CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol blob DYNAMIC_COLUMN_STORAGE=1, textcol blob DYNAMIC_COLUMN_STORAGE=1) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 449ERROR 42000: Incorrect column specifier for column 'textcol' 450# 451# Dynamic column read 452# 453CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA 454thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 455delete from t2; 456insert into t2 values(1,'9b5658dc-f32f-11e1-94cd-f46d046e9f09'); 457insert into t2 values(2,'9b5658dc-f32f-11e1-94cd-f46d046e9f0a'); 458drop table t2; 459CREATE TABLE t2 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 460select rowkey, column_list(dyn), column_get(dyn, 'uuidcol' as char) from t2; 461rowkey column_list(dyn) column_get(dyn, 'uuidcol' as char) 4621 `uuidcol` 9b5658dc-f32f-11e1-94cd-f46d046e9f09 4632 `uuidcol` 9b5658dc-f32f-11e1-94cd-f46d046e9f0a 464drop table t2; 465CREATE TABLE t2 (rowkey bigint PRIMARY KEY, uuidcol char(36)) ENGINE=CASSANDRA 466thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 467delete from t2; 468drop table t2; 469# 470# Dynamic column insert 471# 472CREATE TABLE t2 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf5'; 473insert into t2 values (1, column_create("dyn1", 1, "dyn2", "two")); 474select rowkey, column_json(dyn) from t2; 475rowkey column_json(dyn) 4761 {"dyn1":"1","dyn2":"two"} 477delete from t2; 478drop table t2; 479# bigint 480CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf2'; 481insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'a', 254324)); 482insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'a', 2543)); 483select rowkey, column_json(dyn) from t1; 484rowkey column_json(dyn) 4851 {"a":254324,"dyn1":"1","dyn2":"two"} 4862 {"a":2543,"dyn1":"1","dyn2":"two"} 487delete from t1; 488drop table t1; 489# int 490CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf3'; 491insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'intcol', 254324)); 492insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'intcol', 2543)); 493select rowkey, column_json(dyn) from t1; 494rowkey column_json(dyn) 4951 {"dyn1":"1","dyn2":"two","intcol":254324} 4962 {"dyn1":"1","dyn2":"two","intcol":2543} 497delete from t1; 498drop table t1; 499# timestamp 500CREATE TABLE t1 (rowkey bigint PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf4'; 501insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'datecol', 254324)); 502insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'datecol', 2543)); 503select rowkey, column_json(dyn) from t1; 504rowkey column_json(dyn) 5051 {"dyn1":"1","dyn2":"two","datecol":254324} 5062 {"dyn1":"1","dyn2":"two","datecol":2543} 507delete from t1; 508drop table t1; 509# boolean 510CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7'; 511insert into t1 values (1, column_create("dyn1", 1, "dyn2", "two", 'boolcol', 254324)); 512insert into t1 values (2, column_create("dyn1", 1, "dyn2", "two", 'boolcol', 0)); 513select rowkey, column_json(dyn) from t1; 514rowkey column_json(dyn) 5151 {"dyn1":"1","dyn2":"two","boolcol":1} 5162 {"dyn1":"1","dyn2":"two","boolcol":0} 517select rowkey, column_json(dyn) from t1; 518rowkey column_json(dyn) 5191 {"dyn1":"1","dyn2":"two","boolcol":1} 5202 {"dyn1":"1","dyn2":"two","boolcol":0} 521update t1 set dyn=column_add(dyn, "dyn2", null, "dyn3", "3"); 522select rowkey, column_json(dyn) from t1; 523rowkey column_json(dyn) 5241 {"dyn1":"1","dyn3":"3","boolcol":1} 5252 {"dyn1":"1","dyn3":"3","boolcol":0} 526update t1 set dyn=column_add(dyn, "dyn1", null) where rowkey= 1; 527select rowkey, column_json(dyn) from t1; 528rowkey column_json(dyn) 5291 {"dyn3":"3","boolcol":1} 5302 {"dyn1":"1","dyn3":"3","boolcol":0} 531update t1 set dyn=column_add(dyn, "dyn3", null, "a", "ddd"); 532select rowkey, column_json(dyn) from t1; 533rowkey column_json(dyn) 5341 {"a":"ddd","boolcol":1} 5352 {"a":"ddd","dyn1":"1","boolcol":0} 536update t1 set dyn=column_add(dyn, "12345678901234", "ddd"); 537select rowkey, column_json(dyn) from t1; 538rowkey column_json(dyn) 5391 {"a":"ddd","boolcol":1,"12345678901234":"ddd"} 5402 {"a":"ddd","dyn1":"1","boolcol":0,"12345678901234":"ddd"} 541update t1 set dyn=column_add(dyn, "12345678901234", null); 542select rowkey, column_json(dyn) from t1; 543rowkey column_json(dyn) 5441 {"a":"ddd","boolcol":1} 5452 {"a":"ddd","dyn1":"1","boolcol":0} 546update t1 set dyn=column_add(dyn, 'boolcol', null) where rowkey= 2; 547select rowkey, column_json(dyn) from t1; 548rowkey column_json(dyn) 5491 {"a":"ddd","boolcol":1} 5502 {"a":"ddd","dyn1":"1"} 551update t1 set rowkey= 3, dyn=column_add(dyn, "dyn1", null, 'boolcol', 0) where rowkey= 2; 552select rowkey, column_json(dyn) from t1; 553rowkey column_json(dyn) 5541 {"a":"ddd","boolcol":1} 5553 {"a":"ddd","boolcol":0} 556delete from t1; 557drop table t1; 558CREATE TABLE t1 (rowkey varchar(10) PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd1'; 559select * from t1; 560ERROR HY000: Internal error: Unable to convert value for field `dyn` from Cassandra's data format. Name length exceed limit of 16383: 'very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_v 561drop table t1; 562CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) 563ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; 564DELETE FROM t1; 565insert into t1 values (1, column_create("dyn", 1)); 566select rowkey, column_list(dyn) from t1; 567rowkey column_list(dyn) 5681 `dyn` 569delete from t1; 570DROP TABLE t1; 571CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) 572ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; 573insert into t1 values (1,'9b5658dc-f32f-11e1-94cd-f46d046e9f0a'); 574ERROR HY000: Encountered illegal format of dynamic column string 575delete from t1; 576DROP TABLE t1; 577# 578# MDEV-565: Server crashes in ha_cassandra::write_row on 579# inserting NULL into a dynamic column 580# 581CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) 582ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; 583insert into t1 values (1, NULL); 584delete from t1; 585DROP TABLE t1; 586# 587# strange side effect of Cassandra - remiving all columns of primary 588# key removes all row. 589# 590CREATE TABLE t1 (rowkey int PRIMARY KEY, dyn blob DYNAMIC_COLUMN_STORAGE=yes) 591ENGINE=CASSANDRA thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cfd2'; 592INSERT INTO t1 VALUES(2,column_create("ab","ab")); 593select rowkey, column_json(dyn) from t1; 594rowkey column_json(dyn) 5952 {"ab":"ab"} 596UPDATE t1 set dyn=NULL; 597select rowkey, column_json(dyn) from t1; 598rowkey column_json(dyn) 599INSERT INTO t1 VALUES(2,column_create("ab","ab")); 600select rowkey, column_json(dyn) from t1; 601rowkey column_json(dyn) 6022 {"ab":"ab"} 603UPDATE t1 set dyn=""; 604select rowkey, column_json(dyn) from t1; 605rowkey column_json(dyn) 606delete from t1; 607DROP TABLE t1; 608# 609# MDEV-4005 #Server crashes on creating a Cassandra table 610# with a mix of static and dynamic columns 611# 612DROP TABLE IF EXISTS t1, t2; 613CREATE TABLE t1 ( 614pk int primary key, 615col_int int, 616dyncol blob DYNAMIC_COLUMN_STORAGE=yes 617) ENGINE=cassandra keyspace='bug' thrift_host = '127.0.0.1' column_family='cf1'; 618drop table t1; 619# 620# MDEV-4000: Mapping between Cassandra blob (BytesType) and MySQL BLOB does not work 621# 622create table t1 (rowkey int primary key, b blob ) ENGINE=CASSANDRA thrift_host = '127.0.0.1' `keyspace`='mariadbtest2' `column_family`='cf13'; 623insert into t1 values (1, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar'); 624insert into t1 values (2, 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz'); 625select * from t1; 626rowkey b 6271 fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar 6282 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz 629drop table t1; 630# 631# MDEV-4001: Cassandra: server crashes in ha_cassandra::end_bulk_insert on INSERT .. SELECT with a non-existing column 632# 633create table t1 (rowkey int primary key, a int) ENGINE=cassandra thrift_host='127.0.0.1' keyspace='mariadbtest2' column_family='cf14'; 634insert into t1 (a) select b from t1; 635ERROR 42S22: Unknown column 'b' in 'field list' 636drop table t1; 637