1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-28 13:01:41 +03:00
mariadb/mysql-test/t/cassandra.test
2012-08-21 18:38:27 +04:00

109 lines
3.4 KiB
Plaintext

#
# 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_WRONG_COLUMN_NAME
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);
--enable_parsing
############################################################################
## Cassandra initialization ends
############################################################################
--echo # Now, create a table for real and insert data
create table t1 (rowkey 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 rowkey='rowkey11';
select * from t1 where rowkey='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 rowkey='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;
############################################################################
## Cassandra cleanup
############################################################################
--disable_parsing
drop columnfamily cf1;
--enable_parsing
############################################################################
## Cassandra cleanup ends
############################################################################