diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-07 08:47:20 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-09-07 08:47:20 +0300 |
commit | 1985204044852f6be55453b3b843e81fd0fe1730 (patch) | |
tree | ef186b5c3f0dcd78b25c28662003b7ec8957675d | |
parent | 4318391346dfd3ebc43175aa24e880b0e74159d4 (diff) | |
parent | 38d36b59f925dc19f5b8346b3e54bec782771967 (diff) | |
download | mariadb-git-1985204044852f6be55453b3b843e81fd0fe1730.tar.gz |
Merge 10.5 into 10.6
20 files changed, 572 insertions, 318 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index be86cf7565e..e8038cdec7f 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -333,7 +333,7 @@ SET @rowlog_decrypt_1= WHERE variable_name = 'innodb_encryption_n_rowlog_blocks_decrypted'); connection con1; SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; -ALTER TABLE t1 ADD INDEX c2f(c2); +ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; connection default; SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; @@ -396,7 +396,6 @@ SET DEBUG_SYNC = 'now SIGNAL dml3_done'; connection con1; Warnings: Note 1831 Duplicate index `c2f`. This is deprecated and will be disallowed in a future release -ALTER TABLE t1 CHANGE c2 c22f INT; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test index 2cb84b18402..f4f17d9c92c 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online.test +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -312,9 +312,7 @@ connection con1; # Accumulate and apply some modification log. SET DEBUG_SYNC = 'row_log_apply_before SIGNAL c2f_created WAIT_FOR dml3_done'; --send -# FIXME: MDEV-13668 -#ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; -ALTER TABLE t1 ADD INDEX c2f(c2); +ALTER TABLE t1 ADD INDEX c2f(c22f), CHANGE c2 c22f INT; connection default; SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; @@ -338,8 +336,6 @@ SET DEBUG_SYNC = 'now SIGNAL dml3_done'; connection con1; reap; -# FIXME: MDEV-13668 -ALTER TABLE t1 CHANGE c2 c22f INT; eval $innodb_metrics_select; diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result index ed7e6b9b7e1..f1ebef6175f 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug2.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result @@ -6,3 +6,17 @@ INSERT INTO mdev21563 VALUES('This is a test'); ALTER TABLE mdev21563 DISCARD TABLESPACE; # restart DROP TABLE mdev21563; +# +# MDEV-29342 Assertion failure in file que0que.cc line 728 +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +set debug_dbug="+d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('test'); +set debug_dbug="-d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('This is a fts issue'); +# restart +set debug_dbug="+d,fts_instrument_sync_debug"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug="-d,fts_instrument_sync_debug"; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test index 0a9e137dd80..1ba77f2481e 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug2.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test @@ -10,3 +10,18 @@ INSERT INTO mdev21563 VALUES('This is a test'); ALTER TABLE mdev21563 DISCARD TABLESPACE; --source include/restart_mysqld.inc DROP TABLE mdev21563; + +--echo # +--echo # MDEV-29342 Assertion failure in file que0que.cc line 728 +--echo # +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +set debug_dbug="+d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('test'); +set debug_dbug="-d,fts_instrument_sync_debug"; +INSERT INTO t1 VALUES('This is a fts issue'); +--source include/restart_mysqld.inc +set debug_dbug="+d,fts_instrument_sync_debug"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug="-d,fts_instrument_sync_debug"; +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/r/rpl_filter_revoke_missing_user.result b/mysql-test/suite/rpl/r/rpl_filter_revoke_missing_user.result new file mode 100644 index 00000000000..efd73d88964 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_filter_revoke_missing_user.result @@ -0,0 +1,39 @@ +include/master-slave.inc +[connection master] +# +# Set replica to ignore system tables +connection slave; +include/stop_slave.inc +SET @@GLOBAL.replicate_wild_ignore_table="mysql.%"; +include/start_slave.inc +# +# Trying to execute REVOKE ALL PRIVILEGES on a non-existent user and +# DROP USER on a list of users where not all users exist should error +# and be written into the binary log +connection master; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'nonexistentuser'@'%'; +ERROR HY000: Can't revoke all privileges for one or more of the requested users +CREATE USER 'testuser'@'localhost' IDENTIFIED by ''; +DROP USER 'testuser'@'localhost', 'nonexistentuser'@'%'; +ERROR HY000: Operation DROP USER failed for 'nonexistentuser'@'%' +# +# Ensure the events exist in the primary's binary log +FLUSH BINARY LOGS; +# MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > MYSQL_TMP_DIR/mysqlbinlog_out.sql +# There should be three Query events: REVOKE, CREATE USER, and DROP USER +FOUND 3 /Query/ in mysqlbinlog_out.sql +FOUND 1 /REVOKE ALL PRIVILEGES/ in mysqlbinlog_out.sql +FOUND 1 /CREATE USER/ in mysqlbinlog_out.sql +FOUND 1 /DROP USER/ in mysqlbinlog_out.sql +# +# Ensure that the replica receives the event without error +connection slave; +Last_SQL_Error = +Last_SQL_Errno = 0 +# +# Clean up +connection slave; +include/stop_slave.inc +SET @@GLOBAL.replicate_wild_ignore_table=""; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_filter_revoke_missing_user.test b/mysql-test/suite/rpl/t/rpl_filter_revoke_missing_user.test new file mode 100644 index 00000000000..ca2c18d36e1 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_filter_revoke_missing_user.test @@ -0,0 +1,92 @@ +# +# Purpose: +# This test ensures that a binlogged Query_log_event which failed on the +# primary server does not break replication if it is ignored by Grant_tables +# on the replica. The bug reported by MDEV-28530 shows this with +# REVOKE ALL PRIVILEGES.. using a non-existent user. The primary will binlog +# the REVOKE command with an error code, and the replica will think the command +# executed with success because the replication filter will ignore the command +# while accessing the Grant_tables classes. When the replica performs an error +# check, it sees the difference between the error codes, and replication +# breaks. +# +# Methodology: +# Using a replica configured with replicate_wild_ignore_table="schema.%", +# on the primary, execute REVOKE ALL PRVILEGES using a non-existent user and +# DROP USER using a list of users where not all users exist, and ensure that +# the replica acknowledges and ignores the events without erroring. +# +# References: +# MDEV-28530: Revoking privileges from a non-existing user on a master breaks +# replication on the slave in the presence of replication filters +# + +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; + +--echo # +--echo # Set replica to ignore system tables +connection slave; +let $old_filter= query_get_value(SHOW SLAVE STATUS, Replicate_Wild_Ignore_Table, 1); +source include/stop_slave.inc; +SET @@GLOBAL.replicate_wild_ignore_table="mysql.%"; +source include/start_slave.inc; + + +--echo # +--echo # Trying to execute REVOKE ALL PRIVILEGES on a non-existent user and +--echo # DROP USER on a list of users where not all users exist should error +--echo # and be written into the binary log +--connection master + +--error 1269 +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'nonexistentuser'@'%'; + +CREATE USER 'testuser'@'localhost' IDENTIFIED by ''; +--error 1396 +DROP USER 'testuser'@'localhost', 'nonexistentuser'@'%'; +--save_master_pos + + +--echo # +--echo # Ensure the events exist in the primary's binary log +--let $MYSQLD_DATADIR= `select @@datadir` +--let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1) +FLUSH BINARY LOGS; +--echo # MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > MYSQL_TMP_DIR/mysqlbinlog_out.sql +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file > $MYSQL_TMP_DIR/mysqlbinlog_out.sql + +--echo # There should be three Query events: REVOKE, CREATE USER, and DROP USER +--let SEARCH_FILE= $MYSQL_TMP_DIR/mysqlbinlog_out.sql + +--let SEARCH_PATTERN= Query +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= REVOKE ALL PRIVILEGES +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= CREATE USER +--source include/search_pattern_in_file.inc + +--let SEARCH_PATTERN= DROP USER +--source include/search_pattern_in_file.inc + + +--echo # +--echo # Ensure that the replica receives the event without error +connection slave; +--sync_with_master +let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1); +--echo Last_SQL_Error = $error +let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); +--echo Last_SQL_Errno = $errno + + +--echo # +--echo # Clean up +--connection slave +source include/stop_slave.inc; +--eval SET @@GLOBAL.replicate_wild_ignore_table="$old_filter" +source include/start_slave.inc; + +--source include/rpl_end.inc diff --git a/plugin/disks/information_schema_disks.cc b/plugin/disks/information_schema_disks.cc index 174264c3269..15e26dad12a 100644 --- a/plugin/disks/information_schema_disks.cc +++ b/plugin/disks/information_schema_disks.cc @@ -108,7 +108,7 @@ static int disks_table_add_row_stat( #else if (info.f_flags & MNT_RDONLY) #endif - return 0; + return 0; pTable->field[0]->store(zDisk, strlen(zDisk), system_charset_info); pTable->field[1]->store(zPath, strlen(zPath), system_charset_info); @@ -214,15 +214,15 @@ static int disks_fill_table(THD* pThd, TABLE_LIST* pTables, Item* pCond) ) { struct stat f; - const char *path, *point; + const char *path, *point; #ifdef HAVE_SETMNTENT - path= pEnt->mnt_dir; - point= pEnt->mnt_fsname; + path= pEnt->mnt_dir; + point= pEnt->mnt_fsname; #else - path= pEnt->mnt_mountp; - point= pEnt->mnt_special; + path= pEnt->mnt_mountp; + point= pEnt->mnt_special; #endif - // Try to keep to real storage by excluding + // Try to keep to real storage by excluding // read only mounts, and mount points that aren't directories if (hasmntopt(pEnt, MNTOPT_RO) != NULL) continue; diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 2cae9f60e4e..c137a3b3621 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1921,6 +1921,13 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, thd->update_server_status(); log_slow_statement(thd); thd->lex->restore_set_statement_var(); + + /* + When THD::slave_expected_error gets reset inside execution stack + that is the case of to be ignored event. In this case the expected + error must change to the reset value as well. + */ + expected_error= thd->slave_expected_error; } thd->variables.option_bits&= ~OPTION_MASTER_SQL_ERROR; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index b04b0efbc03..de3f0e74155 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7535,9 +7535,10 @@ ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS eng "Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction" spa "La sentencia no es segura porque accede a una tabla no transaccional tras acceder a una transaccional dentro de la misma transacción" ER_MESSAGE_AND_STATEMENT - chi "%s语句:%s" - eng "%s Statement: %s" - spa "%s Sentencia: %s" + chi "%s.语句:%s" + eng "%s. Statement: %s" + spa "%s. Sentencia: %s" + ER_SLAVE_CONVERSION_FAILED chi "列%d表'%-.192s.%-.192s'无法从'%-.50s'类型为'%-.50s'" eng "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.50s' to type '%-.50s'" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 999f7d5b836..e4a929e8747 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2094,9 +2094,11 @@ class Grant_tables some kind of updates to the mysql.% tables. */ Rpl_filter *rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter; - if (rpl_filter->is_on() && !rpl_filter->tables_ok(0, tables)) + { + thd->slave_expected_error= 0; DBUG_RETURN(1); + } } DBUG_RETURN(0); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 1d13a5be8af..c0aa56f5355 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3616,6 +3616,8 @@ public: /* In case of a slave, set to the error code the master got when executing the query. 0 if no error on the master. + The stored into variable master error code may get reset inside + execution stack when the event turns out to be ignored. */ int slave_expected_error; enum_sql_command last_sql_command; // Last sql_command exceuted in mysql_execute_command() diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index afbb904d5c5..ae270bf72b2 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -2605,7 +2605,7 @@ retry: } mysql_mutex_unlock(&cache->doc_id_lock); - if (cmp_doc_id > *doc_id) { + if (cmp_doc_id && cmp_doc_id >= *doc_id) { error = fts_update_sync_doc_id( table, cache->synced_doc_id, trx); } diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 56bef29cc70..d846894fc2f 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -996,8 +996,8 @@ static void trx_undo_seg_free(const trx_undo_t *undo) else if (buf_block_t* rseg_header = rseg->get(&mtr, nullptr)) { static_assert(FIL_NULL == 0xffffffff, "compatibility"); - memset(TRX_RSEG + TRX_RSEG_UNDO_SLOTS + undo->id * TRX_RSEG_SLOT_SIZE + - rseg_header->page.frame, 0xff, 4); + mtr.memset(rseg_header, TRX_RSEG + TRX_RSEG_UNDO_SLOTS + + undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff); MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED); } } 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 b21f7c4e1e7..15e4c0e909d 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1910,9 +1910,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) { @@ -1922,16 +1921,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 @@ -1941,7 +1939,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); } @@ -1969,14 +1967,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) { @@ -1986,9 +1994,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) @@ -2001,8 +2009,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) @@ -2011,8 +2019,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 @@ -2047,9 +2055,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; @@ -2066,9 +2073,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) @@ -2081,8 +2088,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) @@ -2091,8 +2098,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 @@ -2128,9 +2135,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; @@ -2147,9 +2153,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) @@ -2162,8 +2168,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) @@ -2172,8 +2178,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 @@ -2208,9 +2214,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) { @@ -2226,9 +2231,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) @@ -2242,8 +2247,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) @@ -2253,8 +2258,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 @@ -2278,13 +2283,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); @@ -2296,13 +2299,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); @@ -2314,13 +2315,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); @@ -2332,13 +2331,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); @@ -2349,13 +2346,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); @@ -2371,9 +2366,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) { @@ -2389,9 +2383,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) @@ -2405,8 +2399,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) @@ -2416,8 +2410,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 @@ -2496,9 +2490,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 + @@ -2507,17 +2500,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) @@ -2526,8 +2519,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 @@ -2554,9 +2547,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; @@ -2572,9 +2564,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) @@ -2587,8 +2579,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) @@ -2597,8 +2589,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 @@ -2614,9 +2606,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) { @@ -2631,9 +2622,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) @@ -2647,8 +2638,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) @@ -2658,8 +2649,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 886ffed3b4b..e04f67897dc 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1,5 +1,5 @@ /* Copyright (C) 2008-2020 Kentoku Shiba - Copyright (C) 2019-2020 MariaDB corp + Copyright (C) 2019, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -101,6 +101,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_HYPHEN_STR "-" #define SPIDER_SQL_HYPHEN_LEN (sizeof(SPIDER_SQL_HYPHEN_STR) - 1) @@ -172,6 +174,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" @@ -848,13 +852,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 e1365d60f4e..15fb415c82e 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -4178,13 +4178,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]; @@ -4210,70 +4210,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((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); @@ -4302,27 +4247,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")); @@ -4353,6 +4278,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)) @@ -4388,6 +4317,7 @@ int spider_db_mariadb_util::append_column_value( { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } + DBUG_RETURN(0); } @@ -4396,6 +4326,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; @@ -4566,6 +4497,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)) @@ -4603,16 +4537,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( @@ -9634,12 +9564,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); @@ -10031,12 +9959,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 @@ -11074,8 +11000,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); } @@ -11155,8 +11081,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); } @@ -11556,12 +11482,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); } @@ -11596,12 +11519,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); } @@ -13033,12 +12953,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 af7b860f3f5..8c7f52ef75b 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,25 +82,25 @@ 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_loop_check( spider_string *str, SPIDER_CONN *conn - ); + ) 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, @@ -114,13 +110,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, @@ -129,7 +125,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, @@ -139,12 +135,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, @@ -186,18 +182,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 bool tables_on_different_db_are_joinable(); bool socket_has_default_value(); @@ -218,8 +214,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 @@ -230,14 +227,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 |