summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_deinit.inc13
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc24
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_deinit.inc4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_init.inc14
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_deinit.inc4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_init.inc16
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result85
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result85
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc98
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.test5
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.test5
-rw-r--r--storage/spider/spd_db_include.h4
-rw-r--r--storage/spider/spd_db_mysql.cc254
-rw-r--r--storage/spider/spd_db_mysql.h14
-rw-r--r--storage/spider/spd_include.h2
17 files changed, 632 insertions, 3 deletions
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_deinit.inc
new file mode 100644
index 00000000000..4ea789feae8
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_deinit.inc
@@ -0,0 +1,13 @@
+--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP
+--connection master_1
+set session binlog_format= @old_binlog_format;
+--connection slave1_1
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../include/deinit_spider.inc
+--source ../t/slave_test_deinit.inc
+--source ../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc
new file mode 100644
index 00000000000..f2f8635f9e3
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc
@@ -0,0 +1,24 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../t/test_init.inc
+--source ../t/slave_test_init.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
+let $CHILD2_1_SELECT_TABLES=
+ SELECT pkey, f FROM tbl_a ORDER BY pkey;
+let $CHILD2_1_SELECT_ARGUMENT1=
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+--connection slave1_1
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../include/init_spider.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--connection master_1
+set @old_binlog_format= @@binlog_format;
+set session binlog_format= 'ROW';
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_deinit.inc
new file mode 100644
index 00000000000..4fd217a5676
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_deinit.inc
@@ -0,0 +1,4 @@
+--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
+--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
+--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
+--source delete_with_float_column_deinit.inc
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_init.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_init.inc
new file mode 100644
index 00000000000..9d3961491e6
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mariadb_init.inc
@@ -0,0 +1,14 @@
+--source delete_with_float_column_init.inc
+--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='table "tbl_a", srv "s_2_1", wrapper "mariadb"';
+--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS tbl_a;
+--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_deinit.inc
new file mode 100644
index 00000000000..4fd217a5676
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_deinit.inc
@@ -0,0 +1,4 @@
+--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
+--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
+--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
+--source delete_with_float_column_deinit.inc
diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_init.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_init.inc
new file mode 100644
index 00000000000..d98f3c12397
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_mysql_init.inc
@@ -0,0 +1,16 @@
+--source delete_with_float_column_init.inc
+--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='table "tbl_a", srv "s_2_1", wrapper "mysql"';
+--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS tbl_a $STR_SEMICOLON
+ DROP FUNCTION to_float;
+--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE FUNCTION to_float(a decimal(20,6)) RETURNS float RETURN cast(a as double);
diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result
new file mode 100644
index 00000000000..d9fb00a09fc
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result
@@ -0,0 +1,85 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+connection slave1_1;
+connection master_1;
+set @old_binlog_format= @@binlog_format;
+set session binlog_format= 'ROW';
+
+drop and create databases
+connection master_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+
+create table and insert
+connection child2_1;
+CHILD2_1_CREATE_TABLES
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+connection slave1_1;
+connection master_1;
+SET SESSION sql_log_bin= 0;
+CREATE TABLE tbl_a (
+pkey int NOT NULL,
+f float DEFAULT NULL,
+PRIMARY KEY (pkey)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SET SESSION sql_log_bin= 1;
+connection slave1_1;
+CREATE TABLE tbl_a (
+pkey int NOT NULL,
+f float DEFAULT NULL,
+PRIMARY KEY (pkey)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+connection master_1;
+INSERT INTO tbl_a (pkey, f) VALUES (0,NULL);
+INSERT INTO tbl_a (pkey, f) VALUES (1,0.671437);
+DELETE FROM tbl_a WHERE pkey = 0;
+DELETE FROM tbl_a WHERE pkey = 1;
+connection slave1_1;
+connection master_1;
+SET SESSION sql_log_bin= 0;
+connection child2_1;
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+argument
+delete from `auto_test_remote`.`tbl_a` where `pkey` = 0 and `f` is null limit 1
+delete from `auto_test_remote`.`tbl_a` where `pkey` = 1 and `f` = cast(0.671437 as float) limit 1
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'
+SELECT pkey, f FROM tbl_a ORDER BY pkey;
+pkey f
+connection slave1_1;
+SELECT pkey, f FROM tbl_a ORDER BY pkey;
+pkey f
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+SET GLOBAL log_output = @old_log_output;
+connection master_1;
+set session binlog_format= @old_binlog_format;
+connection slave1_1;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result
new file mode 100644
index 00000000000..c41cfe8156a
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result
@@ -0,0 +1,85 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+connection slave1_1;
+connection master_1;
+set @old_binlog_format= @@binlog_format;
+set session binlog_format= 'ROW';
+
+drop and create databases
+connection master_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+
+create table and insert
+connection child2_1;
+CHILD2_1_CREATE_TABLES
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+connection slave1_1;
+connection master_1;
+SET SESSION sql_log_bin= 0;
+CREATE TABLE tbl_a (
+pkey int NOT NULL,
+f float DEFAULT NULL,
+PRIMARY KEY (pkey)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SET SESSION sql_log_bin= 1;
+connection slave1_1;
+CREATE TABLE tbl_a (
+pkey int NOT NULL,
+f float DEFAULT NULL,
+PRIMARY KEY (pkey)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+connection master_1;
+INSERT INTO tbl_a (pkey, f) VALUES (0,NULL);
+INSERT INTO tbl_a (pkey, f) VALUES (1,0.671437);
+DELETE FROM tbl_a WHERE pkey = 0;
+DELETE FROM tbl_a WHERE pkey = 1;
+connection slave1_1;
+connection master_1;
+SET SESSION sql_log_bin= 0;
+connection child2_1;
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+argument
+delete from `auto_test_remote`.`tbl_a` where `pkey` = 0 and `f` is null limit 1
+delete from `auto_test_remote`.`tbl_a` where `pkey` = 1 and `f` = /* create function to_float(a decimal(20,6)) returns float return cast(a as double) */ to_float(0.671437) limit 1
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'
+SELECT pkey, f FROM tbl_a ORDER BY pkey;
+pkey f
+connection slave1_1;
+SELECT pkey, f FROM tbl_a ORDER BY pkey;
+pkey f
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+SET GLOBAL log_output = @old_log_output;
+connection master_1;
+set session binlog_format= @old_binlog_format;
+connection slave1_1;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc
new file mode 100644
index 00000000000..794ebedf355
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc
@@ -0,0 +1,98 @@
+--echo
+--echo drop and create databases
+--connection master_1
+--disable_warnings
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+--connection slave1_1
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+--connection child2_1
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+--enable_warnings
+
+--echo
+--echo create table and insert
+
+--connection child2_1
+--disable_query_log
+echo CHILD2_1_CREATE_TABLES;
+eval $CHILD2_1_CREATE_TABLES;
+--enable_query_log
+TRUNCATE TABLE mysql.general_log;
+
+--connection master_1
+save_master_pos;
+
+--connection slave1_1
+sync_with_master;
+
+--connection master_1
+SET SESSION sql_log_bin= 0;
+--disable_query_log
+echo CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+SET SESSION sql_log_bin= 1;
+
+--connection slave1_1
+--disable_query_log
+echo CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ f float DEFAULT NULL,
+ PRIMARY KEY (pkey)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+
+--connection master_1
+INSERT INTO tbl_a (pkey, f) VALUES (0,NULL);
+INSERT INTO tbl_a (pkey, f) VALUES (1,0.671437);
+DELETE FROM tbl_a WHERE pkey = 0;
+DELETE FROM tbl_a WHERE pkey = 1;
+save_master_pos;
+
+--connection slave1_1
+sync_with_master;
+
+--connection master_1
+SET SESSION sql_log_bin= 0;
+
+--connection child2_1
+eval $CHILD2_1_SELECT_ARGUMENT1;
+eval $CHILD2_1_SELECT_TABLES;
+
+--connection slave1_1
+SELECT pkey, f FROM tbl_a ORDER BY pkey;
+
+--echo
+--echo deinit
+--disable_warnings
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+
+--connection slave1_1
+DROP DATABASE IF EXISTS auto_test_local;
+
+--connection child2_1
+DROP DATABASE IF EXISTS auto_test_remote;
+SET GLOBAL log_output = @old_log_output;
+
+--enable_warnings
diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.cnf b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.cnf
new file mode 100644
index 00000000000..45019d6c537
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.cnf
@@ -0,0 +1,4 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
+!include ../my_4_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.test
new file mode 100644
index 00000000000..ce1a09d6287
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mariadb.test
@@ -0,0 +1,5 @@
+--source ../include/delete_with_float_column_mariadb_init.inc
+--source delete_with_float_column.inc
+--source ../include/delete_with_float_column_mariadb_deinit.inc
+--echo
+--echo end of test
diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.cnf b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.cnf
new file mode 100644
index 00000000000..45019d6c537
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.cnf
@@ -0,0 +1,4 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
+!include ../my_4_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.test b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.test
new file mode 100644
index 00000000000..c687f947a91
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column_mysql.test
@@ -0,0 +1,5 @@
+--source ../include/delete_with_float_column_mysql_init.inc
+--source delete_with_float_column.inc
+--source ../include/delete_with_float_column_mysql_deinit.inc
+--echo
+--echo end of test
diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h
index 622462bdb98..2f401fa8ff8 100644
--- a/storage/spider/spd_db_include.h
+++ b/storage/spider/spd_db_include.h
@@ -157,6 +157,8 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_MBR_DISJOINT_LEN (sizeof(SPIDER_SQL_MBR_DISJOINT_STR) - 1)
#define SPIDER_SQL_NOT_BETWEEN_STR "not between"
#define SPIDER_SQL_NOT_BETWEEN_LEN (sizeof(SPIDER_SQL_NOT_BETWEEN_STR) - 1)
+#define SPIDER_SQL_TO_FLOAT_STR "/* create function to_float(a decimal(20,6)) returns float return a */ to_float("
+#define SPIDER_SQL_TO_FLOAT_LEN (sizeof(SPIDER_SQL_TO_FLOAT_STR) - 1)
#define SPIDER_SQL_IN_STR "in("
#define SPIDER_SQL_IN_LEN (sizeof(SPIDER_SQL_IN_STR) - 1)
#define SPIDER_SQL_NOT_IN_STR "not in("
@@ -181,6 +183,8 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_AS_TIME_LEN (sizeof(SPIDER_SQL_AS_TIME_STR) - 1)
#define SPIDER_SQL_AS_BINARY_STR " as binary"
#define SPIDER_SQL_AS_BINARY_LEN (sizeof(SPIDER_SQL_AS_BINARY_STR) - 1)
+#define SPIDER_SQL_AS_FLOAT_STR " as float"
+#define SPIDER_SQL_AS_FLOAT_LEN (sizeof(SPIDER_SQL_AS_FLOAT_STR) - 1)
#define SPIDER_SQL_IS_TRUE_STR " is true"
#define SPIDER_SQL_IS_TRUE_LEN (sizeof(SPIDER_SQL_IS_TRUE_STR) - 1)
#define SPIDER_SQL_IS_NOT_TRUE_STR " is not true"
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 6fc7b5770a1..cd29cb1343f 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -3656,13 +3656,14 @@ int spider_db_mbase_util::append_escaped_name_quote(
DBUG_RETURN(0);
}
-int spider_db_mbase_util::append_column_value(
+int spider_db_mariadb_util::append_column_value(
ha_spider *spider,
spider_string *str,
Field *field,
const uchar *new_ptr,
CHARSET_INFO *access_charset
) {
+ bool float_value = FALSE;
int error_num;
char buf[MAX_FIELD_WIDTH];
spider_string tmp_str(buf, MAX_FIELD_WIDTH, field->charset());
@@ -3670,7 +3671,7 @@ int spider_db_mbase_util::append_column_value(
uint length;
THD *thd = field->table->in_use;
Time_zone *saved_time_zone = thd->variables.time_zone;
- DBUG_ENTER("spider_db_mbase_util::append_column_value");
+ DBUG_ENTER("spider_db_mariadb_util::append_column_value");
tmp_str.init_calc_mem(113);
thd->variables.time_zone = UTC;
@@ -3769,6 +3770,10 @@ int spider_db_mbase_util::append_column_value(
} else {
ptr = field->val_str(tmp_str.get_str());
tmp_str.mem_calc();
+ if (field->type() == MYSQL_TYPE_FLOAT)
+ {
+ float_value = TRUE;
+ }
}
thd->variables.time_zone = saved_time_zone;
@@ -3833,13 +3838,258 @@ int spider_db_mbase_util::append_column_value(
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
} else if (field->str_needs_quotes())
{
+ if (str->charset() != field->charset())
+ {
+ if ((error_num = spider_db_append_charset_name_before_string(str,
+ field->charset())))
+ {
+ DBUG_RETURN(error_num);
+ }
+ }
if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + ptr->length() * 2 + 2))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
append_escaped_util(str, ptr);
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ } else if (float_value)
+ {
+ if (str->reserve(SPIDER_SQL_CAST_LEN + ptr->length() +
+ SPIDER_SQL_AS_FLOAT_LEN, SPIDER_SQL_CLOSE_PAREN_LEN))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN);
+ str->q_append(ptr->ptr(), ptr->length());
+ str->q_append(SPIDER_SQL_AS_FLOAT_STR, SPIDER_SQL_AS_FLOAT_LEN);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
} else if (str->append(*ptr))
+ {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ DBUG_RETURN(0);
+}
+
+int spider_db_mysql_util::append_column_value(
+ ha_spider *spider,
+ spider_string *str,
+ Field *field,
+ const uchar *new_ptr,
+ CHARSET_INFO *access_charset
+) {
+ bool float_value = FALSE;
+ int error_num;
+ char buf[MAX_FIELD_WIDTH];
+ spider_string tmp_str(buf, MAX_FIELD_WIDTH, field->charset());
+ String *ptr;
+ uint length;
+ THD *thd = field->table->in_use;
+ Time_zone *saved_time_zone = thd->variables.time_zone;
+ DBUG_ENTER("spider_db_mysql_util::append_column_value");
+ tmp_str.init_calc_mem(266);
+
+ thd->variables.time_zone = UTC;
+
+ if (new_ptr)
+ {
+ if (
+ field->type() == MYSQL_TYPE_BLOB ||
+ field->real_type() == MYSQL_TYPE_VARCHAR
+ ) {
+ length = uint2korr(new_ptr);
+ tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length,
+ field->charset());
+ ptr = tmp_str.get_str();
+ } else if (field->type() == MYSQL_TYPE_GEOMETRY)
+ {
+/*
+ uint mlength = SIZEOF_STORED_DOUBLE, lcnt;
+ uchar *dest = (uchar *) buf;
+ const uchar *source;
+ for (lcnt = 0; lcnt < 4; lcnt++)
+ {
+ mlength = SIZEOF_STORED_DOUBLE;
+ source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt;
+ while (mlength--)
+ *dest++ = *--source;
+ }
+ tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt);
+*/
+#ifndef DBUG_OFF
+ double xmin, xmax, ymin, ymax;
+/*
+ float8store(buf,xmin);
+ float8store(buf+8,xmax);
+ float8store(buf+16,ymin);
+ float8store(buf+24,ymax);
+ memcpy(&xmin,new_ptr,sizeof(xmin));
+ memcpy(&xmax,new_ptr + 8,sizeof(xmax));
+ memcpy(&ymin,new_ptr + 16,sizeof(ymin));
+ memcpy(&ymax,new_ptr + 24,sizeof(ymax));
+ float8get(xmin, buf);
+ float8get(xmax, buf + 8);
+ float8get(ymin, buf + 16);
+ float8get(ymax, buf + 24);
+ DBUG_PRINT("info", ("spider geo is %f %f %f %f",
+ xmin, xmax, ymin, ymax));
+ DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g",
+ xmin, xmax, ymin, ymax));
+*/
+ float8get(xmin, new_ptr);
+ float8get(xmax, new_ptr + 8);
+ float8get(ymin, new_ptr + 16);
+ float8get(ymax, new_ptr + 24);
+ DBUG_PRINT("info", ("spider geo is %f %f %f %f",
+ xmin, xmax, ymin, ymax));
+/*
+ float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4);
+ float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5);
+ float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6);
+ float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7);
+ DBUG_PRINT("info", ("spider geo is %f %f %f %f",
+ xmin, xmax, ymin, ymax));
+ float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8);
+ float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9);
+ float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10);
+ float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11);
+ DBUG_PRINT("info", ("spider geo is %f %f %f %f",
+ xmin, xmax, ymin, ymax));
+ float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12);
+ float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13);
+ float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14);
+ float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15);
+ DBUG_PRINT("info", ("spider geo is %f %f %f %f",
+ xmin, xmax, ymin, ymax));
+*/
+#endif
+/*
+ tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4,
+ &my_charset_bin);
+*/
+ tmp_str.length(0);
+ tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR,
+ SPIDER_SQL_LINESTRING_HEAD_LEN);
+ tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE);
+ tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2,
+ SIZEOF_STORED_DOUBLE);
+ tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE,
+ SIZEOF_STORED_DOUBLE);
+ tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3,
+ SIZEOF_STORED_DOUBLE);
+ ptr = tmp_str.get_str();
+ } else {
+ ptr = field->val_str(tmp_str.get_str(), new_ptr);
+ tmp_str.mem_calc();
+ }
+ } else {
+ ptr = field->val_str(tmp_str.get_str());
+ tmp_str.mem_calc();
+ if (field->type() == MYSQL_TYPE_FLOAT)
+ {
+ float_value = TRUE;
+ }
+ }
+
+ thd->variables.time_zone = saved_time_zone;
+
+ DBUG_PRINT("info", ("spider field->type() is %d", field->type()));
+ DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length()));
+/*
+ if (
+ field->type() == MYSQL_TYPE_BIT ||
+ (field->type() >= MYSQL_TYPE_TINY_BLOB &&
+ field->type() <= MYSQL_TYPE_BLOB)
+ ) {
+ uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr;
+ char *str_ptr;
+ DBUG_PRINT("info", ("spider HEX"));
+ if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN);
+ str_ptr = (char *) str->ptr() + str->length();
+ for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++)
+ {
+ *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4];
+ *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F];
+ }
+ str->length(str->length() + ptr->length() * 2);
+ } else
+*/
+ if (field->result_type() == STRING_RESULT)
+ {
+ DBUG_PRINT("info", ("spider STRING_RESULT"));
+ if (str->charset() != field->charset())
+ {
+ if ((error_num = spider_db_append_charset_name_before_string(str,
+ field->charset())))
+ {
+ DBUG_RETURN(error_num);
+ }
+ }
+ if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ if (
+ field->type() == MYSQL_TYPE_VARCHAR ||
+ (field->type() >= MYSQL_TYPE_ENUM &&
+ field->type() <= MYSQL_TYPE_GEOMETRY)
+ ) {
+ DBUG_PRINT("info", ("spider append_escaped"));
+ char buf2[MAX_FIELD_WIDTH];
+ spider_string tmp_str2(buf2, MAX_FIELD_WIDTH, field->charset());
+ tmp_str2.init_calc_mem(267);
+ tmp_str2.length(0);
+ if (
+ tmp_str2.append(ptr->ptr(), ptr->length(), field->charset()) ||
+ str->reserve(tmp_str2.length() * 2) ||
+ append_escaped_util(str, tmp_str2.get_str())
+ )
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ } else if (str->append(*ptr))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ } else if (field->str_needs_quotes())
+ {
+ if (str->charset() != field->charset())
+ {
+ if ((error_num = spider_db_append_charset_name_before_string(str,
+ field->charset())))
+ {
+ DBUG_RETURN(error_num);
+ }
+ }
+ if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + ptr->length() * 2 + 2))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ append_escaped_util(str, ptr);
+ str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ } else if (float_value)
+ {
+ if (str->reserve(SPIDER_SQL_TO_FLOAT_LEN + ptr->length() +
+ SPIDER_SQL_CLOSE_PAREN_LEN))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ str->q_append(SPIDER_SQL_TO_FLOAT_STR, SPIDER_SQL_TO_FLOAT_LEN);
+ str->q_append(ptr->ptr(), ptr->length());
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
+ } else if (str->append(*ptr))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ DBUG_RETURN(0);
+}
+
+int spider_db_mbase_util::append_column_value(
+ ha_spider *spider,
+ spider_string *str,
+ Field *field,
+ const uchar *new_ptr,
+ CHARSET_INFO *access_charset
+) {
+ DBUG_ENTER("spider_db_mbase_util::append_column_value");
+ DBUG_ASSERT(0);
DBUG_RETURN(0);
}
diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h
index 8f317d03e0e..51db3b1f2fa 100644
--- a/storage/spider/spd_db_mysql.h
+++ b/storage/spider/spd_db_mysql.h
@@ -202,6 +202,13 @@ class spider_db_mysql_util: public spider_db_mbase_util
public:
spider_db_mysql_util();
~spider_db_mysql_util();
+ int append_column_value(
+ ha_spider *spider,
+ spider_string *str,
+ Field *field,
+ const uchar *new_ptr,
+ CHARSET_INFO *access_charset
+ );
};
class spider_db_mariadb_util: public spider_db_mbase_util
@@ -213,6 +220,13 @@ public:
spider_string *str,
sql_mode_t sql_mode
);
+ int append_column_value(
+ ha_spider *spider,
+ spider_string *str,
+ Field *field,
+ const uchar *new_ptr,
+ CHARSET_INFO *access_charset
+ );
};
class spider_db_mbase_row: public spider_db_row
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index 5fa5faea6db..faec3e63804 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -260,7 +260,7 @@ const char SPIDER_empty_string = "";
#define SPIDER_TMP_SHARE_LONG_COUNT 19
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
-#define SPIDER_MEM_CALC_LIST_NUM 266
+#define SPIDER_MEM_CALC_LIST_NUM 268
#define SPIDER_CONN_META_BUF_LEN 64
#define SPIDER_BACKUP_DASTATUS \