From 52045d40d4fe0df0e60fa37eb35609fcb0fd857a Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 20 May 2013 08:37:03 +0400 Subject: [PATCH] MDEV-4000: Mapping between Cassandra blob (BytesType) and MySQL BLOB does not work - Allow SQL blobs in the data mapping. --- mysql-test/suite/plugins/r/cassandra.result | 11 +++++++++++ mysql-test/suite/plugins/t/cassandra.test | 17 +++++++++++++++++ storage/cassandra/ha_cassandra.cc | 1 + 3 files changed, 29 insertions(+) diff --git a/mysql-test/suite/plugins/r/cassandra.result b/mysql-test/suite/plugins/r/cassandra.result index 65a81c429b0..5bd58710dd6 100644 --- a/mysql-test/suite/plugins/r/cassandra.result +++ b/mysql-test/suite/plugins/r/cassandra.result @@ -591,3 +591,14 @@ col_int int, dyncol blob DYNAMIC_COLUMN_STORAGE=yes ) ENGINE=cassandra keyspace='bug' thrift_host = '127.0.0.1' column_family='cf1'; drop table t1; +# +# MDEV-4000: Mapping between Cassandra blob (BytesType) and MySQL BLOB does not work +# +create table t1 (rowkey int primary key, b blob ) ENGINE=CASSANDRA thrift_host = '127.0.0.1' `keyspace`='mariadbtest2' `column_family`='cf13'; +insert into t1 values (1, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar'); +insert into t1 values (2, 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz'); +select * from t1; +rowkey b +1 fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar +2 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz +drop table t1; diff --git a/mysql-test/suite/plugins/t/cassandra.test b/mysql-test/suite/plugins/t/cassandra.test index 1543993843a..c7060d673e4 100644 --- a/mysql-test/suite/plugins/t/cassandra.test +++ b/mysql-test/suite/plugins/t/cassandra.test @@ -83,6 +83,8 @@ insert into cf11 (rowkey, decimal_col) values ('val_1234', 1234); create columnfamily cf12 (rowkey varchar primary key, decimal_col decimal); +create columnfamily cf13 (rowkey int primary key, b blob); + EOF --error 0,1,2 --system cqlsh -3 -f $MYSQLTEST_VARDIR/cassandra_test_init.cql @@ -704,6 +706,19 @@ CREATE TABLE t1 ( drop table t1; + +--echo # +--echo # MDEV-4000: Mapping between Cassandra blob (BytesType) and MySQL BLOB does not work +--echo # + +create table t1 (rowkey int primary key, b blob ) ENGINE=CASSANDRA thrift_host = '127.0.0.1' `keyspace`='mariadbtest2' `column_family`='cf13'; + +insert into t1 values (1, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo-bar'); +insert into t1 values (2, 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq-baz'); + +select * from t1; +drop table t1; + ############################################################################ ## Cassandra cleanup ############################################################################ @@ -715,6 +730,8 @@ drop columnfamily cf4; drop columnfamily cf5; drop columnfamily cf6; drop columnfamily cf7; + +drop columnfamily cf13; --enable_parsing ############################################################################ ## Cassandra cleanup ends diff --git a/storage/cassandra/ha_cassandra.cc b/storage/cassandra/ha_cassandra.cc index a9a97806a7e..481b520e79a 100644 --- a/storage/cassandra/ha_cassandra.cc +++ b/storage/cassandra/ha_cassandra.cc @@ -1373,6 +1373,7 @@ ColumnDataConverter *map_field_to_validator(Field *field, const char *validator_ /* fall through: */ case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: + case MYSQL_TYPE_BLOB: { /* Cassandra's "varint" type is a binary-encoded arbitary-length