diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-07 08:08:59 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-07 08:08:59 +0300 |
commit | c7ba2377936be2a3c84080359d87f7486ce682a0 (patch) | |
tree | d5baefb80899dabbe5d3fcac421727409ba15c12 /storage/spider | |
parent | 2917bd0d2cf417cbf9c83b64ae2b7806bdb2f34e (diff) | |
parent | ac49b7a845f5b5de30d1266879a4c584f9d7c914 (diff) | |
download | mariadb-git-c7ba2377936be2a3c84080359d87f7486ce682a0.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'storage/spider')
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result | 84 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/t/mdev_27172.cnf | 3 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test | 92 | ||||
-rw-r--r-- | storage/spider/spd_db_conn.cc | 243 | ||||
-rw-r--r-- | storage/spider/spd_db_include.h | 15 | ||||
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 172 | ||||
-rw-r--r-- | storage/spider/spd_db_mysql.h | 68 |
7 files changed, 382 insertions, 295 deletions
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result new file mode 100644 index 00000000000..d4c8c7e8ec2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result @@ -0,0 +1,84 @@ +# +# MDEV-27172 Prefix indices on Spider tables may lead to wrong query results +# +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection child2_1; +SET @general_log_backup = @@global.general_log; +SET @log_output_backup = @@global.log_output; +SET @@global.general_log = 1; +SET @@global.log_output = "TABLE"; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +CREATE TABLE tbl_a ( +id int NOT NULL, +greeting VARCHAR(255), +KEY(greeting) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE tbl_b ( +id int NOT NULL, +greeting VARCHAR(255), +KEY k (greeting(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE tbl_c ( +id int NOT NULL, +greeting TEXT, +KEY k (greeting(5)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +id int NOT NULL, +greeting VARCHAR(255), +KEY k (greeting) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"'; +INSERT INTO tbl_a VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_a WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; +id greeting +2 Aloha! +CREATE TABLE tbl_b ( +id int NOT NULL, +greeting VARCHAR(255), +KEY k (greeting(5)) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_b", srv "s_2_1"'; +INSERT INTO tbl_b VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_b WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; +id greeting +2 Aloha! +CREATE TABLE tbl_c ( +id int NOT NULL, +greeting TEXT, +KEY k (greeting(5)) +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_c", srv "s_2_1"'; +INSERT INTO tbl_c VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_c WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; +id greeting +2 Aloha! +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; +argument +select `id`,`greeting` from `auto_test_remote`.`tbl_a` where `greeting` = 'Aloha!' and ((`greeting` = 'Aloha!')) +select `id`,`greeting` from `auto_test_remote`.`tbl_b` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!')) +select `id`,`greeting` from `auto_test_remote`.`tbl_c` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!')) +SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %' +connection child2_1; +SET @@global.general_log = @general_log_backup; +SET @@global.log_output = @log_output_backup; +DROP DATABASE auto_test_remote; +connection master_1; +DROP DATABASE auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.cnf @@ -0,0 +1,3 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test new file mode 100644 index 00000000000..d544a0b400e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test @@ -0,0 +1,92 @@ +--echo # +--echo # MDEV-27172 Prefix indices on Spider tables may lead to wrong query results +--echo # + +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +--connection child2_1 +SET @general_log_backup = @@global.general_log; +SET @log_output_backup = @@global.log_output; +SET @@global.general_log = 1; +SET @@global.log_output = "TABLE"; + +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +eval CREATE TABLE tbl_a ( + id int NOT NULL, + greeting VARCHAR(255), + KEY(greeting) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +eval CREATE TABLE tbl_b ( + id int NOT NULL, + greeting VARCHAR(255), + KEY k (greeting(5)) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +eval CREATE TABLE tbl_c ( + id int NOT NULL, + greeting TEXT, + KEY k (greeting(5)) +) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; + +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +CREATE DATABASE auto_test_local; +USE auto_test_local; + +# = (equality) +eval CREATE TABLE tbl_a ( + id int NOT NULL, + greeting VARCHAR(255), + KEY k (greeting) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"'; + +INSERT INTO tbl_a VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_a WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH + +# LIKE +eval CREATE TABLE tbl_b ( + id int NOT NULL, + greeting VARCHAR(255), + KEY k (greeting(5)) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_b", srv "s_2_1"'; + +INSERT INTO tbl_b VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_b WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH + +# LIKE +eval CREATE TABLE tbl_c ( + id int NOT NULL, + greeting TEXT, + KEY k (greeting(5)) +) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_c", srv "s_2_1"'; + +INSERT INTO tbl_c VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +SELECT * FROM tbl_c WHERE greeting = "Aloha!" + AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH + +--connection child2_1 +SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; + +--connection child2_1 +SET @@global.general_log = @general_log_backup; +SET @@global.log_output = @log_output_backup; +DROP DATABASE auto_test_remote; + +--connection master_1 +DROP DATABASE auto_test_local; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index c34dea18adf..2af430101ca 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1885,9 +1885,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) { @@ -1897,16 +1896,15 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) { #ifdef SPIDER_HANDLER_SUPPORT_MULTIPLE_KEY_PARTS if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, + append_column_value(spider, str_part, field, ptr, false, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else @@ -1916,7 +1914,7 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, + append_column_value(spider, str_part, field, ptr, false, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -1944,14 +1942,24 @@ int spider_db_append_key_where_internal( if (sql_kind == SPIDER_SQL_KIND_SQL) { if (str->reserve(store_length + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + - SPIDER_SQL_EQUAL_LEN)) + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); + dbton_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + + bool is_like= MY_TEST(key_part->key_part_flag & HA_PART_KEY_SEG); + if (is_like) + { + if (str->append(SPIDER_SQL_LIKE_STR, SPIDER_SQL_LIKE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + else + { + if (str->append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, is_like, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } else if (sql_kind == SPIDER_SQL_KIND_HANDLER) { @@ -1961,9 +1969,9 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, FALSE, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) @@ -1976,8 +1984,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -1986,8 +1994,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2022,9 +2030,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(op_str, op_len); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_both) start_key_part_map = 0; @@ -2041,9 +2048,9 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, FALSE, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) @@ -2056,8 +2063,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2066,8 +2073,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_GT_STR, SPIDER_SQL_GT_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2103,9 +2110,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(op_str, op_len); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_both) start_key_part_map = 0; @@ -2122,9 +2128,9 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, FALSE, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) @@ -2137,8 +2143,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2147,8 +2153,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2183,9 +2189,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (!set_order) { @@ -2201,9 +2206,9 @@ int spider_db_append_key_where_internal( dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) @@ -2217,8 +2222,8 @@ int spider_db_append_key_where_internal( SPIDER_SQL_LTEQUAL_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2228,8 +2233,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2253,13 +2258,11 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MBR_CONTAIN_STR, SPIDER_SQL_MBR_CONTAIN_LEN); - if ( - spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) - ) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_CLOSE_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); dbton_share->append_column_name(str, field->field_index); @@ -2271,13 +2274,11 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MBR_INTERSECT_STR, SPIDER_SQL_MBR_INTERSECT_LEN); - if ( - spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) - ) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_CLOSE_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); dbton_share->append_column_name(str, field->field_index); @@ -2289,13 +2290,11 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MBR_WITHIN_STR, SPIDER_SQL_MBR_WITHIN_LEN); - if ( - spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) - ) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_CLOSE_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); dbton_share->append_column_name(str, field->field_index); @@ -2307,13 +2306,11 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MBR_DISJOINT_STR, SPIDER_SQL_MBR_DISJOINT_LEN); - if ( - spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) - ) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_CLOSE_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); dbton_share->append_column_name(str, field->field_index); @@ -2324,13 +2321,11 @@ int spider_db_append_key_where_internal( if (str->reserve(SPIDER_SQL_MBR_EQUAL_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MBR_EQUAL_STR, SPIDER_SQL_MBR_EQUAL_LEN); - if ( - spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_CLOSE_PAREN_LEN) - ) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN + key_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_CLOSE_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); dbton_share->append_column_name(str, field->field_index); @@ -2346,9 +2341,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (!set_order) { @@ -2364,9 +2358,9 @@ int spider_db_append_key_where_internal( dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == start_key) @@ -2380,8 +2374,8 @@ int spider_db_append_key_where_internal( SPIDER_SQL_GTEQUAL_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2391,8 +2385,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_GTEQUAL_STR, SPIDER_SQL_GTEQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2471,9 +2465,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } else { if (str_part2->reserve(store_length + key_name_length + @@ -2482,17 +2475,17 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == end_key) { #ifdef SPIDER_HANDLER_SUPPORT_MULTIPLE_KEY_PARTS if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2501,8 +2494,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2529,9 +2522,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(op_str, op_len); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_both) end_key_part_map = 0; @@ -2547,9 +2539,9 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == end_key) @@ -2562,8 +2554,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2572,8 +2564,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LT_STR, SPIDER_SQL_LT_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, + false, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif @@ -2589,9 +2581,8 @@ int spider_db_append_key_where_internal( DBUG_RETURN(HA_ERR_OUT_OF_MEM); dbton_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (!set_order) { @@ -2606,9 +2597,9 @@ int spider_db_append_key_where_internal( dbton_share->append_column_name(str_part2, field->field_index); str_part2->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); - if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part2, field, ptr, - share->access_charset)) + if (spider_dbton[dbton_id].db_util->append_column_value( + spider, str_part2, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (use_key == end_key) @@ -2622,8 +2613,8 @@ int spider_db_append_key_where_internal( SPIDER_SQL_LTEQUAL_LEN); } if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, false, + share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); #else if (str_part->length() == SPIDER_SQL_OPEN_PAREN_LEN) @@ -2633,8 +2624,8 @@ int spider_db_append_key_where_internal( str->q_append(SPIDER_SQL_LTEQUAL_STR, SPIDER_SQL_LTEQUAL_LEN); if (spider_dbton[dbton_id].db_util-> - append_column_value(spider, str_part, field, ptr, - share->access_charset)) + append_column_value(spider, str_part, field, ptr, + false, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } #endif diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 9b005ba7ccd..71403212445 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -94,6 +94,8 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_DOT_STR "." #define SPIDER_SQL_DOT_LEN (sizeof(SPIDER_SQL_DOT_STR) - 1) +#define SPIDER_SQL_PERCENT_STR "%" +#define SPIDER_SQL_PERCENT_LEN (sizeof(SPIDER_SQL_PERCENT_STR) - 1) #define SPIDER_SQL_EQUAL_STR " = " #define SPIDER_SQL_EQUAL_LEN (sizeof(SPIDER_SQL_EQUAL_STR) - 1) @@ -163,6 +165,8 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_IN_LEN (sizeof(SPIDER_SQL_IN_STR) - 1) #define SPIDER_SQL_NOT_IN_STR "not in(" #define SPIDER_SQL_NOT_IN_LEN (sizeof(SPIDER_SQL_NOT_IN_STR) - 1) +#define SPIDER_SQL_LIKE_STR " like " +#define SPIDER_SQL_LIKE_LEN (sizeof(SPIDER_SQL_LIKE_STR) - 1) #define SPIDER_SQL_NOT_LIKE_STR "not like" #define SPIDER_SQL_NOT_LIKE_LEN (sizeof(SPIDER_SQL_NOT_LIKE_STR) - 1) #define SPIDER_SQL_AS_CHAR_STR " as char" @@ -839,13 +843,10 @@ public: virtual int append_escaped_name_quote( spider_string *str ) = 0; - virtual int append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset - ) = 0; + virtual int append_column_value(ha_spider *spider, spider_string *str, + Field *field, const uchar *new_ptr, + bool is_like, + CHARSET_INFO *access_charset)= 0; virtual int append_trx_isolation( spider_string *str, int trx_isolation diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 70c9b3d515f..4f587c8b6ac 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -4033,13 +4033,13 @@ int spider_db_mbase_util::append_escaped_name_quote( DBUG_RETURN(0); } -int spider_db_mariadb_util::append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset -) { +int spider_db_mariadb_util::append_column_value(ha_spider *spider, + spider_string *str, + Field *field, + const uchar *new_ptr, + bool is_like, + CHARSET_INFO *access_charset) +{ bool float_value = FALSE; int error_num; char buf[MAX_FIELD_WIDTH]; @@ -4065,70 +4065,15 @@ int spider_db_mariadb_util::append_column_value( 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); @@ -4157,27 +4102,7 @@ int spider_db_mariadb_util::append_column_value( 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")); @@ -4208,6 +4133,10 @@ int spider_db_mariadb_util::append_column_value( append_escaped_util(str, tmp_str2.get_str()) ) DBUG_RETURN(HA_ERR_OUT_OF_MEM); + + if (is_like && + str->append(SPIDER_SQL_PERCENT_STR, SPIDER_SQL_PERCENT_LEN)) + 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)) @@ -4243,6 +4172,7 @@ int spider_db_mariadb_util::append_column_value( { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } + DBUG_RETURN(0); } @@ -4251,6 +4181,7 @@ int spider_db_mysql_util::append_column_value( spider_string *str, Field *field, const uchar *new_ptr, + bool is_like, CHARSET_INFO *access_charset ) { bool float_value = FALSE; @@ -4421,6 +4352,9 @@ int spider_db_mysql_util::append_column_value( append_escaped_util(str, tmp_str2.get_str()) ) DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (is_like && + str->append(SPIDER_SQL_PERCENT_STR, SPIDER_SQL_PERCENT_LEN)) + 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)) @@ -4458,16 +4392,12 @@ int spider_db_mysql_util::append_column_value( 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); +int spider_db_mbase_util::append_column_value(ha_spider *, spider_string *, + Field *, const uchar *, bool, + CHARSET_INFO *) +{ + MY_ASSERT_UNREACHABLE(); + return 0; } int spider_db_mbase_util::append_from_with_alias( @@ -9375,12 +9305,10 @@ int spider_mbase_handler::append_insert_for_recovery( DBUG_RETURN(HA_ERR_OUT_OF_MEM); insert_sql->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); } else { - if ( - spider_db_mbase_utility-> - append_column_value(spider, insert_sql, *field, NULL, - share->access_charset) || - insert_sql->reserve(SPIDER_SQL_COMMA_LEN) - ) + if (spider_db_mbase_utility->append_column_value(spider, insert_sql, + *field, NULL, false, + share->access_charset) || + insert_sql->reserve(SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } insert_sql->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); @@ -9772,12 +9700,10 @@ int spider_mbase_handler::append_update_set( #ifndef DBUG_OFF MY_BITMAP *tmp_map = dbug_tmp_use_all_columns(table, &table->read_set); #endif - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, *fields, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { + if (spider_db_mbase_utility->append_column_value( + spider, str, *fields, NULL, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN)) + { #ifndef DBUG_OFF dbug_tmp_restore_column_map(&table->read_set, tmp_map); #endif @@ -10576,8 +10502,8 @@ int spider_mbase_handler::append_key_column_values( if (error_num > 0) DBUG_RETURN(error_num); } else { - if (spider_db_mbase_utility->append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_db_mbase_utility->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -10657,8 +10583,8 @@ int spider_mbase_handler::append_key_column_values_with_name( if (error_num > 0) DBUG_RETURN(error_num); } else { - if (spider_db_mbase_utility->append_column_value(spider, str, field, ptr, - share->access_charset)) + if (spider_db_mbase_utility->append_column_value( + spider, str, field, ptr, FALSE, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -11058,12 +10984,9 @@ int spider_mbase_handler::append_update_where( mysql_share->append_column_name(str, (*field)->field_index); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); (*field)->move_field_offset(ptr_diff); - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, *field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_AND_LEN) - ) + if (spider_db_mbase_utility->append_column_value( + spider, str, *field, NULL, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); (*field)->move_field_offset(-ptr_diff); } @@ -11098,12 +11021,9 @@ int spider_mbase_handler::append_update_where( mysql_share->append_column_name(str, (*field)->field_index); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); (*field)->move_field_offset(ptr_diff); - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, *field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_AND_LEN) - ) + if (spider_db_mbase_utility->append_column_value( + spider, str, *field, NULL, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); (*field)->move_field_offset(-ptr_diff); } @@ -12535,12 +12455,10 @@ int spider_mbase_handler::append_insert_values( } str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); } else { - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, *field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { + if (spider_db_mbase_utility->append_column_value( + spider, str, *field, NULL, FALSE, share->access_charset) || + str->reserve(SPIDER_SQL_COMMA_LEN)) + { #ifndef DBUG_OFF dbug_tmp_restore_column_map(&table->read_set, tmp_map); #endif diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 626bb4d5624..d0be89c0b51 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -22,37 +22,33 @@ public: spider_string *str, const char *name, uint name_length - ); + ) override; int append_name_with_charset( spider_string *str, const char *name, uint name_length, CHARSET_INFO *name_charset - ); + ) override; int append_escaped_name( spider_string *str, const char *name, uint name_length - ); + ) override; int append_escaped_name_with_charset( spider_string *str, const char *name, uint name_length, CHARSET_INFO *name_charset - ); + ) override; bool is_name_quote( const char head_code - ); + ) override; int append_escaped_name_quote( spider_string *str - ); - int append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset - ); + ) override; + int append_column_value(ha_spider *spider, spider_string *str, Field *field, + const uchar *new_ptr, bool is_like, + CHARSET_INFO *access_charset) override; int append_from_with_alias( spider_string *str, const char **table_names, @@ -66,19 +62,19 @@ public: int append_trx_isolation( spider_string *str, int trx_isolation - ); + ) override; int append_autocommit( spider_string *str, bool autocommit - ); + ) override; int append_sql_log_off( spider_string *str, bool sql_log_off - ); + ) override; int append_wait_timeout( spider_string *str, int wait_timeout - ); + ) override; virtual int append_sql_mode_internal( spider_string *str, sql_mode_t sql_mode @@ -86,21 +82,21 @@ public: int append_sql_mode( spider_string *str, sql_mode_t sql_mode - ); + ) override; int append_time_zone( spider_string *str, Time_zone *time_zone - ); + ) override; int append_start_transaction( spider_string *str - ); + ) override; int append_xa_start( spider_string *str, XID *xid - ); + ) override; int append_lock_table_head( spider_string *str - ); + ) override; int append_lock_table_body( spider_string *str, const char *db_name, @@ -110,13 +106,13 @@ public: uint table_name_length, CHARSET_INFO *table_name_charset, int lock_type - ); + ) override; int append_lock_table_tail( spider_string *str - ); + ) override; int append_unlock_table( spider_string *str - ); + ) override; int open_item_func( Item_func *item_func, ha_spider *spider, @@ -125,7 +121,7 @@ public: uint alias_length, bool use_fields, spider_fields *fields - ); + ) override; #ifdef HANDLER_HAS_DIRECT_AGGREGATE int open_item_sum_func( Item_sum *item_sum, @@ -135,12 +131,12 @@ public: uint alias_length, bool use_fields, spider_fields *fields - ); + ) override; #endif int append_escaped_util( spider_string *to, String *from - ); + ) override; #ifdef SPIDER_HAS_GROUP_BY_HANDLER int append_table( ha_spider *spider, @@ -182,18 +178,18 @@ public: spider_string *str, TABLE_LIST *table_list, uint table_count - ); + ) override; int reappend_tables( spider_fields *fields, SPIDER_LINK_IDX_CHAIN *link_idx_chain, spider_string *str - ); + ) override; int append_where( spider_string *str - ); + ) override; int append_having( spider_string *str - ); + ) override; #endif }; @@ -207,8 +203,9 @@ public: spider_string *str, Field *field, const uchar *new_ptr, + bool is_like, CHARSET_INFO *access_charset - ); + ) override; }; class spider_db_mariadb_util: public spider_db_mbase_util @@ -219,14 +216,15 @@ public: int append_sql_mode_internal( spider_string *str, sql_mode_t sql_mode - ); + ) override; int append_column_value( ha_spider *spider, spider_string *str, Field *field, const uchar *new_ptr, + bool is_like, CHARSET_INFO *access_charset - ); + ) override; }; class spider_db_mbase_row: public spider_db_row |