Commit 4a739d76 authored by Kentoku SHIBA's avatar Kentoku SHIBA Committed by GitHub

MDEV-16248 Row based replication to spider with float column fails on delete/update (#1354)

parent fb3998c3
--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
--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';
--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
--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;
--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
--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);
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
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
--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
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
!include ../my_4_1.cnf
--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
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
!include ../my_4_1.cnf
--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
......@@ -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"
......
......@@ -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);
}
......
......@@ -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 @@ class spider_db_mariadb_util: public spider_db_mbase_util
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
......
......@@ -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 \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment