From ce28fa53032dd7c233ed4875514bf85eafec0bc4 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 24 Jan 2019 16:01:28 +0200 Subject: [PATCH 01/22] Backported wsrep-recover test from 10.4. Backported wsrep-recover test from 10.4 to test the wsrep recovery after database shutdown or crash. Renamed the test to wsrep-recover-v25 to avoid conflicts with existing test in 10.4 and to provide coverage for wsrep-API v25 compatible behavior. The test case in 10.2 is simpler because out of order prepare step cannot happen, the commit order critical section is grabbed before prepare phase. Test is not recorded since it does not produce expected result. --- .../suite/wsrep/t/wsrep-recover-step.inc | 41 ++++++ .../suite/wsrep/t/wsrep-recover-v25.cnf | 7 ++ .../wsrep/t/wsrep-recover-v25.combinations | 4 + .../suite/wsrep/t/wsrep-recover-v25.test | 119 ++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 mysql-test/suite/wsrep/t/wsrep-recover-step.inc create mode 100644 mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf create mode 100644 mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations create mode 100644 mysql-test/suite/wsrep/t/wsrep-recover-v25.test diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-step.inc b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc new file mode 100644 index 00000000000..22669438fe0 --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc @@ -0,0 +1,41 @@ +# +# Macro to run wsrep recovery step. This is adapted from +# suite/galera/include/galera_wsrep_recover.inc, with additional +# option to pass binlog argument to recovery command. The macro +# returns recovered position split in uuid and seqno parts. +# +# Arguments: +# +# wsrep_recover_binlog_opt - Binlog options to recovery command +# +# Return: +# +# wsrep_recover_start_position_uuid - UUID corresponding to recovered position +# wsrep_recover_start_position_seqno - seqno corresponding to recovered position +# + +--exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover $wsrep_recover_binlog_opt --core-file > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 + +--perl + use strict; + my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + chomp($wsrep_start_position); + die if $wsrep_start_position eq ''; + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die; + my ($uuid, $seqno) = split /:/, $wsrep_start_position; + print FILE "--let \$wsrep_recover_start_position_uuid = $uuid\n"; + print FILE "--let \$wsrep_recover_start_position_seqno = $seqno\n"; + close FILE; +EOF + +--source $MYSQL_TMP_DIR/galera_wsrep_start_position.inc + +if ($wsrep_recover_start_position_uuid == '') { + --die "Could not obtain start_position_uuid." +} + +if ($wsrep_recover_start_position_seqno == '') { + --die "Could not obtain start_position_seqno." +} + +--remove_file $MYSQL_TMP_DIR/galera_wsrep_start_position.inc diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf b/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf new file mode 100644 index 00000000000..b1c96d2614d --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf @@ -0,0 +1,7 @@ +!include ../my.cnf + +[mysqld.1] +wsrep-on=ON +wsrep-cluster-address=gcomm:// +wsrep-provider=@ENV.WSREP_PROVIDER +binlog-format=ROW diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations b/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations new file mode 100644 index 00000000000..1ce3b45aa1a --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations @@ -0,0 +1,4 @@ +[binlogon] +log-bin + +[binlogoff] diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.test b/mysql-test/suite/wsrep/t/wsrep-recover-v25.test new file mode 100644 index 00000000000..cfd77fbdef4 --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.test @@ -0,0 +1,119 @@ +# +# Verify that the wsrep XID gets updated in InnoDB rollback segment +# properly and can be recovered with --wsrep-recover +# +# The test runs the following scenarios: +# +# 1) The server is started but no SQL is run +# 2) DDL is executed +# 3) INSERT is executed +# 4) Two INSERTs are executed so that the first one in order will be +# blocked after certification and the second one before entering +# commit order critical section. +# 5) Two DMLs are executed so that the prepare step is run out of order. +# Both transactions are blocked before commit order critical section. +# +# After each scenario server is killed and the recovered position +# is validated. +# + +--source include/have_wsrep.inc +--source include/have_innodb.inc +--source include/have_wsrep_provider.inc +--source include/have_debug_sync.inc + +# +# Binlog option for recovery run. This must be set in the test because +# combinations file causes log-bin option to be set from command line, +# not via my.cnf. +# +--let $log_bin = `SELECT @@log_bin` +if ($log_bin) { +--let $wsrep_recover_binlog_opt = --log-bin +} + +# +# Scenario 1 +# The expected recovered seqno is 1 corresponding to initial cluster +# configuration change. +# +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 0 +--echo $wsrep_recover_start_position_seqno + +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +# +# Senario 2 +# The expected recovered seqno is 1 corresponding to CREATE TABLE +# + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 1 +--echo $wsrep_recover_start_position_seqno + +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +# +# Scenario 3 +# The expected recovered seqno is 2 corresponding to CREATE TABLE and INSERT. +# +# The expected wsrep_last_committed after the server is restarted is 2. +# + +INSERT INTO t1 VALUES (5); +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 2 +--echo $wsrep_recover_start_position_seqno +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +SELECT VARIABLE_VALUE `expect 2` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'; + +# +# Scenario 4 +# +# The INSERT gets prepared but not committed. +# +# If binlog is off, the expected outcome is that the INSERT gets committed +# since it is already committed in the cluster. If binlog is on, the INSERT +# should be rolled back during recovery phase since it has not yet +# been logged into binlog. +# +--connect con1, localhost, root +SET DEBUG_SYNC = "ha_commit_trans_after_prepare SIGNAL after_prepare_reached WAIT_FOR continue"; +--send INSERT INTO t1 VALUES (7) + +--connection default +SET DEBUG_SYNC = "now WAIT_FOR after_prepare_reached"; +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +if ($log_bin) { + --echo Expect seqno 2 +} +if (!$log_bin) { + --echo Expect seqno 3 +} +--echo $wsrep_recover_start_position_seqno +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +if ($log_bin) { + --echo Expect 5 +} +if (!$log_bin) { + --echo Expect 5 7 +} +SELECT * FROM t1; + +DROP TABLE t1; From 040b840de7bcd32b0236531a7aec95b11341cef3 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 24 Jan 2019 16:31:33 +0200 Subject: [PATCH 02/22] MDEV-15740 Backport wsrep recovery fixes from 10.4. Clear wsrep XID in innobase_rollback_by_xid() for recovered wsrep transaction in order to avoid resetting XID storage when rolling back wsrep transaction during recovery. Sort wsrep XIDs read from storage engine in ascending order and erify that the range is continuous during crash recovery. If binlog is off, commit all recovered transactions for continuous seqno range. This is safe because all transactions with wsrep XID have been certified and must be committed in the cluster. On the other hand if binlog is on, respect binlog as a transaction coordinator in order to avoid missing transactions in binlog that have been committed into storage engine . --- sql/handler.cc | 51 +++++++++++++++++++++++++-- sql/wsrep_xid.cc | 34 ++++++++++++++++++ sql/wsrep_xid.h | 2 ++ storage/innobase/handler/ha_innodb.cc | 8 +++++ 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index da41daf2440..e2a8d16b723 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1827,6 +1827,35 @@ static char* xid_to_str(char *buf, XID *xid) } #endif +#ifdef WITH_WSREP +static my_xid wsrep_order_and_check_continuity(XID *list, int len) +{ + wsrep_sort_xid_array(list, len); + wsrep_uuid_t uuid; + wsrep_seqno_t seqno; + if (wsrep_get_SE_checkpoint(uuid, seqno)) + { + WSREP_ERROR("Could not read wsrep SE checkpoint for recovery"); + return 0; + } + long long cur_seqno= seqno; + for (int i= 0; i < len; ++i) + { + if (!wsrep_is_wsrep_xid(list + i) || + wsrep_xid_seqno(*(list + i)) != cur_seqno + 1) + { + WSREP_WARN("Discovered discontinuity in recovered wsrep " + "transaction XIDs. Truncating the recovery list to " + "%d entries", i); + break; + } + ++cur_seqno; + } + WSREP_INFO("Last wsrep seqno to be recovered %lld", cur_seqno); + return (cur_seqno < 0 ? 0 : cur_seqno); +} +#endif /* WITH_WSREP */ + /** recover() step of xa. @@ -1864,6 +1893,19 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, { sql_print_information("Found %d prepared transaction(s) in %s", got, hton_name(hton)->str); +#ifdef WITH_WSREP + /* If wsrep_on=ON, XIDs are first ordered and then the range of + recovered XIDs is checked for continuity. All the XIDs which + are in continuous range can be safely committed if binlog + is off since they have already ordered and certified in the + cluster. */ + my_xid wsrep_limit= 0; + if (WSREP_ON) + { + wsrep_limit= wsrep_order_and_check_continuity(info->list, got); + } +#endif /* WITH_WSREP */ + for (int i=0; i < got; i ++) { my_xid x= WSREP_ON && wsrep_is_wsrep_xid(&info->list[i]) ? @@ -1885,9 +1927,12 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, continue; } // recovery mode - if (info->commit_list ? - my_hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : - tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) + if (IF_WSREP((wsrep_emulate_bin_log && + wsrep_is_wsrep_xid(info->list + i) && + x <= wsrep_limit), false) || + (info->commit_list ? + my_hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : + tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)) { #ifndef DBUG_OFF int rc= diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc index c0b7669d8ca..72b96cadfb0 100644 --- a/sql/wsrep_xid.cc +++ b/sql/wsrep_xid.cc @@ -20,6 +20,8 @@ #include "sql_class.h" #include "wsrep_mysqld.h" // for logging macros +#include /* std::sort() */ + /* * WSREPXid */ @@ -154,3 +156,35 @@ bool wsrep_get_SE_checkpoint(wsrep_uuid_t& uuid, wsrep_seqno_t& seqno) return false; } + +/* + Sort order for XIDs. Wsrep XIDs are sorted according to + seqno in ascending order. Non-wsrep XIDs are considered + equal among themselves and greater than with respect + to wsrep XIDs. + */ +struct Wsrep_xid_cmp +{ + bool operator()(const XID& left, const XID& right) const + { + const bool left_is_wsrep= wsrep_is_wsrep_xid(&left); + const bool right_is_wsrep= wsrep_is_wsrep_xid(&right); + if (left_is_wsrep && right_is_wsrep) + { + return (wsrep_xid_seqno(left) < wsrep_xid_seqno(right)); + } + else if (left_is_wsrep) + { + return true; + } + else + { + return false; + } + } +}; + +void wsrep_sort_xid_array(XID *array, int len) +{ + std::sort(array, array + len, Wsrep_xid_cmp()); +} diff --git a/sql/wsrep_xid.h b/sql/wsrep_xid.h index 5b33a904de1..01b18506708 100644 --- a/sql/wsrep_xid.h +++ b/sql/wsrep_xid.h @@ -32,5 +32,7 @@ bool wsrep_get_SE_checkpoint(wsrep_uuid_t&, wsrep_seqno_t&); //void wsrep_set_SE_checkpoint(XID&); /* uncomment if needed */ bool wsrep_set_SE_checkpoint(const wsrep_uuid_t&, wsrep_seqno_t); +void wsrep_sort_xid_array(XID *array, int len); + #endif /* WITH_WSREP */ #endif /* WSREP_UTILS_H */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3e68e2d1d4a..dde12e5c2d5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -17260,6 +17260,14 @@ innobase_rollback_by_xid( } if (trx_t* trx = trx_get_trx_by_xid(xid)) { +#ifdef WITH_WSREP + /* If a wsrep transaction is being rolled back during + the recovery, we must clear the xid in order to avoid + writing serialisation history for rolled back transaction. */ + if (wsrep_is_wsrep_xid(trx->xid)) { + trx->xid->null(); + } +#endif /* WITH_WSREP */ int ret = innobase_rollback_trx(trx); trx_deregister_from_2pc(trx); ut_ad(!trx->will_lock); From 4ea128391b964fbad5b58629bdee980bbedbd228 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 24 Jan 2019 17:37:45 +0200 Subject: [PATCH 03/22] MDEV-15740 Fix wsrep recovery with wsrep_emulate_bin_log If the TC log did not provide list of XIDs to recover, the commit by XID was skipped during wsrep recovery if binlog emulation was on. However, with wsrep we want to commit every prepared transaction with assigned wsrep XID since the transaction has already been committed in the cluster. Added a special condition to always proceed to commit by XID in xarecover_handlerton() if binlog is off and the recovered transaction has wsrep XID. --- sql/handler.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/handler.cc b/sql/handler.cc index e2a8d16b723..a9688fb96b4 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1921,7 +1921,10 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, info->found_foreign_xids++; continue; } - if (info->dry_run) + if (IF_WSREP(!(wsrep_emulate_bin_log && + wsrep_is_wsrep_xid(info->list + i) && + x <= wsrep_limit) && info->dry_run, + info->dry_run)) { info->found_my_xids++; continue; From ddfc789098e7f038e1f8f62f79663d9751b957c2 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Sun, 27 Jan 2019 15:44:35 +0200 Subject: [PATCH 04/22] MDEV-15740 Recorded wsrep-recover-v25 --- .../wsrep/r/wsrep-recover-v25,binlogon.rdiff | 17 +++++++++++ .../suite/wsrep/r/wsrep-recover-v25.result | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff create mode 100644 mysql-test/suite/wsrep/r/wsrep-recover-v25.result diff --git a/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff b/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff new file mode 100644 index 00000000000..5bf6502d0d8 --- /dev/null +++ b/mysql-test/suite/wsrep/r/wsrep-recover-v25,binlogon.rdiff @@ -0,0 +1,17 @@ +--- r/wsrep-recover-v25.result 2019-01-27 15:38:58.819204748 +0200 ++++ r/wsrep-recover-v25.reject 2019-01-27 15:39:49.967358994 +0200 +@@ -18,11 +18,10 @@ + connection default; + SET DEBUG_SYNC = "now WAIT_FOR after_prepare_reached"; + # Kill the server +-Expect seqno 3 +-3 +-Expect 5 7 ++Expect seqno 2 ++2 ++Expect 5 + SELECT * FROM t1; + f1 + 5 +-7 + DROP TABLE t1; diff --git a/mysql-test/suite/wsrep/r/wsrep-recover-v25.result b/mysql-test/suite/wsrep/r/wsrep-recover-v25.result new file mode 100644 index 00000000000..6d146f67bdf --- /dev/null +++ b/mysql-test/suite/wsrep/r/wsrep-recover-v25.result @@ -0,0 +1,28 @@ +# Kill the server +Expect seqno 0 +0 +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; +# Kill the server +Expect seqno 1 +1 +INSERT INTO t1 VALUES (5); +# Kill the server +Expect seqno 2 +2 +SELECT VARIABLE_VALUE `expect 2` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'; +expect 2 +2 +connect con1, localhost, root; +SET DEBUG_SYNC = "ha_commit_trans_after_prepare SIGNAL after_prepare_reached WAIT_FOR continue"; +INSERT INTO t1 VALUES (7); +connection default; +SET DEBUG_SYNC = "now WAIT_FOR after_prepare_reached"; +# Kill the server +Expect seqno 3 +3 +Expect 5 7 +SELECT * FROM t1; +f1 +5 +7 +DROP TABLE t1; From 4ef556955f5083ff046a195b3d0a68545224483e Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 24 Jan 2019 17:42:30 +0200 Subject: [PATCH 05/22] MDEV-15740 Enabled and recorded galera_gcache_recover_manytrx --- mysql-test/suite/galera/disabled.def | 1 - .../r/galera_gcache_recover_manytrx.result | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 9a8adba7a03..4dcfdec84ce 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -44,4 +44,3 @@ galera.MW-328C : MDEV-17847 Galera test failure on MW-328[A|B|C] galera.galera_sst_xtrabackup-v2 : MDEV-17848 Galera test failure on galera_sst_xtrabackup-v2[_data_dir] galera.galera_sst_xtrabackup-v2_data_dir : MDEV-17848 Galera test failure on galera_sst_xtrabackup-v2[_data_dir] query_cache : MDEV-18137: Galera test failure on query_cache -galera_gcache_recover_manytrx : MDEV-15740 diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result index 868b39bfbd6..604b24a8fab 100644 --- a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result +++ b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result @@ -70,28 +70,55 @@ WHILE 1 DO INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); END WHILE; END| +connect node_1_insert_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_insert_multi, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_insert_transaction, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_update_simple, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_insert_1k, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_insert_1m, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connect node_1_insert_10m, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1_insert_simple; CALL insert_simple();; +connection node_1_insert_multi; CALL insert_multi();; +connection node_1_insert_transaction; CALL insert_transaction ();; +connection node_1_update_simple; CALL update_simple ();; +connection node_1_insert_1k; CALL insert_1k ();; +connection node_1_insert_1m; CALL insert_1m ();; +connection node_1_insert_10m; CALL insert_10m ();; +connection node_2; SET SESSION wsrep_sync_wait = 0; Killing server ... +connection node_1; Killing server ... +connection node_1_insert_simple; ERROR HY000: Lost connection to MySQL server during query +connection node_1_insert_multi; ERROR HY000: Lost connection to MySQL server during query +connection node_1_insert_transaction; ERROR HY000: Lost connection to MySQL server during query +connection node_1_update_simple; ERROR HY000: Lost connection to MySQL server during query +connection node_1_insert_1k; ERROR HY000: Lost connection to MySQL server during query +connection node_1_insert_1m; ERROR HY000: Lost connection to MySQL server during query +connection node_1_insert_10m; ERROR HY000: Lost connection to MySQL server during query +connection node_1; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... +connection node_2; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... +connection node_1; include/diff_servers.inc [servers=1 2] +connection node_1; DROP TABLE t1; DROP TABLE ten; DROP PROCEDURE insert_simple; @@ -100,8 +127,10 @@ DROP PROCEDURE insert_transaction; DROP PROCEDURE update_simple; DROP PROCEDURE insert_1k; DROP PROCEDURE insert_1m; +connection node_1; CALL mtr.add_suppression("conflict state 7 after post commit"); CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); include/assert_grep.inc [async IST sender starting to serve] +connection node_2; CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence] From 36be0a5aef0376c526d68007da1c11ac440f0d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Jan 2019 17:58:14 +0200 Subject: [PATCH 06/22] MDEV-18399 Recognize the deprecated parameters innodb_file_format, innodb_large_prefix The parameters innodb_file_format and innodb_large_prefix were overridden in the Debian-distributed configuration files, because the default values of these parameters between MariaDB 5.5 and MariaDB 10.2 did not make any sense. To allow a more seamless upgrade from MariaDB 10.1 to later versions, let InnoDB recognize the parameters innodb_file_format and innodb_large_prefix and issue deprecation warnings for them if they are specified. A deprecation period of only one major release (one year between the MariaDB 10.2 and 10.3 releases) is insufficient for these widely used parameters. --- .../r/prefix_index_liftedlimit.result | 2 +- .../t/prefix_index_liftedlimit.test | 2 +- .../suite/sys_vars/r/sysvars_innodb.result | 28 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 25 +++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result b/mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result index 7a73dae473e..96e51e506f2 100644 --- a/mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result +++ b/mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result @@ -1388,7 +1388,7 @@ ALTER TABLE worklog5743 ADD PRIMARY KEY `pk_idx` (col_1_varchar(3000)); ERROR 23000: Duplicate entry 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' for key 'PRIMARY' DROP TABLE worklog5743; set global innodb_large_prefix=0; -ERROR HY000: Unknown system variable 'innodb_large_prefix' +ERROR HY000: Variable 'innodb_large_prefix' is a read only variable CREATE TABLE worklog5743 ( col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , PRIMARY KEY (col_1_varchar(3072)) diff --git a/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test b/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test index 5a944f0ae8b..bca710386d0 100644 --- a/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test +++ b/mysql-test/suite/innodb_zip/t/prefix_index_liftedlimit.test @@ -1300,7 +1300,7 @@ ALTER TABLE worklog5743 ADD PRIMARY KEY `pk_idx` (col_1_varchar(3000)); DROP TABLE worklog5743; # ----------------------------------------------------------------------------- ---error ER_UNKNOWN_SYSTEM_VARIABLE +--error ER_INCORRECT_GLOBAL_LOCAL_VAR set global innodb_large_prefix=0; CREATE TABLE worklog5743 ( col_1_varchar VARCHAR (4000) , col_2_varchar VARCHAR (4000) , diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index a6f626dd0b5..22105923764 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -904,6 +904,20 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_FILE_FORMAT +SESSION_VALUE NULL +GLOBAL_VALUE +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Deprecated parameter with no effect. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_FILE_PER_TABLE SESSION_VALUE NULL GLOBAL_VALUE ON @@ -1296,6 +1310,20 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME INNODB_LARGE_PREFIX +SESSION_VALUE NULL +GLOBAL_VALUE +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE VARCHAR +VARIABLE_COMMENT Deprecated parameter with no effect. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST NULL +READ_ONLY YES +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG SESSION_VALUE NULL GLOBAL_VALUE 0 diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0311b0400e6..7ccf296533a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -206,6 +206,11 @@ static char* innobase_reset_all_monitor_counter; static ulong innodb_flush_method; +/** Deprecated; no effect other than issuing a deprecation warning. */ +static char* innodb_file_format; +/** Deprecated; no effect other than issuing a deprecation warning. */ +static char* innodb_large_prefix; + /* This variable can be set in the server configure file, specifying stopword table to be used */ static char* innobase_server_stopword_table; @@ -3705,6 +3710,17 @@ static int innodb_init_params() char *default_path; ulong num_pll_degree; + if (innodb_large_prefix || innodb_file_format) { + const char* p = innodb_file_format + ? "file_format" + : "large_prefix"; + sql_print_warning("The parameter innodb_%s is deprecated" + " and has no effect." + " It may be removed in future releases." + " See https://mariadb.com/kb/en/library/" + "xtradbinnodb-file-format/", p); + } + /* Check that values don't overflow on 32-bit systems. */ if (sizeof(ulint) == 4) { if (innobase_buffer_pool_size > UINT_MAX32) { @@ -18989,6 +19005,13 @@ static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method, NULL, NULL, IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_FSYNC), &innodb_flush_method_typelib); +static MYSQL_SYSVAR_STR(file_format, innodb_file_format, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Deprecated parameter with no effect.", NULL, NULL, NULL); +static MYSQL_SYSVAR_STR(large_prefix, innodb_large_prefix, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Deprecated parameter with no effect.", NULL, NULL, NULL); + static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Force InnoDB to load metadata of corrupted table.", @@ -20033,6 +20056,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(read_io_threads), MYSQL_SYSVAR(write_io_threads), MYSQL_SYSVAR(file_per_table), + MYSQL_SYSVAR(file_format), /* deprecated in MariaDB 10.2; no effect */ MYSQL_SYSVAR(flush_log_at_timeout), MYSQL_SYSVAR(flush_log_at_trx_commit), MYSQL_SYSVAR(flush_method), @@ -20046,6 +20070,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(ft_min_token_size), MYSQL_SYSVAR(ft_num_word_optimize), MYSQL_SYSVAR(ft_sort_pll_degree), + MYSQL_SYSVAR(large_prefix), /* deprecated in MariaDB 10.2; no effect */ MYSQL_SYSVAR(force_load_corrupted), MYSQL_SYSVAR(lock_schedule_algorithm), MYSQL_SYSVAR(locks_unsafe_for_binlog), From b8aef87221c46c82921377f18a6498a31f7e5367 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 30 Jan 2019 15:32:51 +0530 Subject: [PATCH 07/22] MDEV-16849 Extending indexed VARCHAR column should be instantaneous Analysis: ======== Increasing the length of the indexed varchar column is not an instant operation for innodb. Fix: === - Introduce the new handler flag 'Alter_inplace_info::ALTER_COLUMN_INDEX_LENGTH' to indicate the index length differs due to change of column length changes. - InnoDB makes the ALTER_COLUMN_INDEX_LENGTH flag as instant operation. This is a port of Mysql fix. commit 913071c0b16cc03e703308250d795bc381627e37 Author: Nisha Gopalakrishnan Date: Wed May 30 14:54:46 2018 +0530 BUG#26848813: INDEXED COLUMN CAN'T BE CHANGED FROM VARCHAR(15) TO VARCHAR(40) INSTANTANEOUSLY --- .../innodb/r/alter_varchar_change.result | 461 ++++++++++++++++++ .../suite/innodb/t/alter_varchar_change.test | 336 +++++++++++++ sql/handler.h | 5 + sql/sql_table.cc | 41 +- storage/innobase/handler/handler0alter.cc | 3 +- 5 files changed, 834 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/innodb/r/alter_varchar_change.result create mode 100644 mysql-test/suite/innodb/t/alter_varchar_change.test diff --git a/mysql-test/suite/innodb/r/alter_varchar_change.result b/mysql-test/suite/innodb/r/alter_varchar_change.result new file mode 100644 index 00000000000..0b06fddd35e --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_varchar_change.result @@ -0,0 +1,461 @@ +CREATE PROCEDURE get_index_id(IN tbl_id INT, IN idx_name char(100), OUT idx_id INT) +BEGIN +SELECT index_id into idx_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE +NAME=idx_name and TABLE_ID=tbl_id; +END| +CREATE PROCEDURE get_table_id(IN tbl_name char(100), OUT tbl_id INT) +BEGIN +SELECT table_id into tbl_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE +NAME = tbl_name; +END| +SET @tbl_id = 0; +SET @tbl1_id = 0; +SET @idx_id = 0; +SET @idx1_id = 0; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) NOT NULL, + PRIMARY KEY (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100), +INDEX idx(f2, f3), index idx1(f3, f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + `f3` varchar(150) DEFAULT NULL, + KEY `idx` (`f2`,`f3`), + KEY `idx1` (`f3`,`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), +INDEX idx(f2(40)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`(40)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + FULLTEXT KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +f3 VARCHAR(50) as (f2) VIRTUAL, +INDEX idx(f3))ENGINE=InnoDB; +INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40)); +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(100); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(100) DEFAULT NULL, + `f3` varchar(50) GENERATED ALWAYS AS (`f2`) VIRTUAL, + KEY `idx` (`f3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)), +INDEX idx1(f1))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx1; +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(50)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`(50)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(100)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD INDEX idx1(f1); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`), + KEY `idx1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(6)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +1 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + KEY `idx` (`f2`(6)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + `f3` int(11) DEFAULT NULL, + KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) NOT NULL, + `f3` int(11) DEFAULT NULL, + PRIMARY KEY (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100))ENGINE=INNODB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD FULLTEXT idx(f2); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) DEFAULT NULL, + FULLTEXT KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 CHAR(100) PRIMARY KEY)ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 CHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` char(200) NOT NULL, + PRIMARY KEY (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)), +INDEX idx1(f1))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(50); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(50) DEFAULT NULL, + KEY `idx` (`f2`(10)), + KEY `idx1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(10)), +INDEX idx1(f1))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(5), DROP INDEX idx1; +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(5) DEFAULT NULL, + KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(50); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SELECT @idx1_id = @idx_id; +@idx1_id = @idx_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(50) DEFAULT NULL, + FULLTEXT KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 CHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` char(200) DEFAULT NULL, + KEY `idx` (`f2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(40)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 TEXT; +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` text DEFAULT NULL, + KEY `idx` (`f2`(40)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(40)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(300); +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(300) DEFAULT NULL, + KEY `idx` (`f2`(40)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +INDEX idx(f2(40)))ENGINE=InnoDB; +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200) CHARACTER SET UTF16; +CALL get_table_id("test/t1", @tbl1_id); +SELECT @tbl1_id = @tbl_id; +@tbl1_id = @tbl_id +0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(200) CHARACTER SET utf16 DEFAULT NULL, + KEY `idx` (`f2`(40)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, +f2 VARCHAR(100), +f3 VARCHAR(50) as (f2) VIRTUAL, +INDEX idx(f3))ENGINE=InnoDB; +# If varchar virtual column extension is allowed in the future then +# InnoDB must rebuild the index +ALTER TABLE t1 MODIFY f3 VARCHAR(100); +ERROR HY000: This is not yet supported for generated columns +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` varchar(100) DEFAULT NULL, + `f3` varchar(50) GENERATED ALWAYS AS (`f2`) VIRTUAL, + KEY `idx` (`f3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +DROP PROCEDURE get_index_id; +DROP PROCEDURE get_table_id; diff --git a/mysql-test/suite/innodb/t/alter_varchar_change.test b/mysql-test/suite/innodb/t/alter_varchar_change.test new file mode 100644 index 00000000000..f435125e581 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_varchar_change.test @@ -0,0 +1,336 @@ +--source include/have_innodb.inc + +DELIMITER |; +CREATE PROCEDURE get_index_id(IN tbl_id INT, IN idx_name char(100), OUT idx_id INT) +BEGIN +SELECT index_id into idx_id FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE + NAME=idx_name and TABLE_ID=tbl_id; +END| + +CREATE PROCEDURE get_table_id(IN tbl_name char(100), OUT tbl_id INT) +BEGIN +SELECT table_id into tbl_id FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE + NAME = tbl_name; +END| + +DELIMITER ;| + +SET @tbl_id = 0; +SET @tbl1_id = 0; +SET @idx_id = 0; +SET @idx1_id = 0; + +# Table should avoid rebuild for the following varchar change. + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# Index should avoid rebuild +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100), + INDEX idx(f2, f3), index idx1(f3, f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), + INDEX idx(f2(40)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + f3 VARCHAR(50) as (f2) VIRTUAL, + INDEX idx(f3))ENGINE=InnoDB; + +INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40)); + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(100); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)), + INDEX idx1(f1))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx1; +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(50)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# Newly added index should built + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(100)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD INDEX idx1(f1); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(6)); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# Table should rebuild + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100))ENGINE=INNODB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD FULLTEXT idx(f2); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 CHAR(100) PRIMARY KEY)ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 CHAR(200); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)), + INDEX idx1(f1))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(50); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(10)), + INDEX idx1(f1))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(5), DROP INDEX idx1; +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +CALL get_index_id(@tbl_id, "idx", @idx_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(50); +CALL get_table_id("test/t1", @tbl1_id); +CALL get_index_id(@tbl1_id, "idx", @idx1_id); + +SELECT @tbl1_id = @tbl_id; +SELECT @idx1_id = @idx_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 CHAR(200); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(40)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 TEXT; +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(40)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(300); +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + INDEX idx(f2(40)))ENGINE=InnoDB; + +CALL get_table_id("test/t1", @tbl_id); +ALTER TABLE t1 MODIFY f2 VARCHAR(200) CHARACTER SET UTF16; +CALL get_table_id("test/t1", @tbl1_id); + +SELECT @tbl1_id = @tbl_id; +SHOW CREATE TABLE t1; +DROP TABLE t1; +# Show error when virtual varchar column got changed + +CREATE TABLE t1(f1 INT NOT NULL, + f2 VARCHAR(100), + f3 VARCHAR(50) as (f2) VIRTUAL, + INDEX idx(f3))ENGINE=InnoDB; + +--echo # If varchar virtual column extension is allowed in the future then +--echo # InnoDB must rebuild the index + +--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN +ALTER TABLE t1 MODIFY f3 VARCHAR(100); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +DROP PROCEDURE get_index_id; +DROP PROCEDURE get_table_id; diff --git a/sql/handler.h b/sql/handler.h index 284fed7cd7e..229197a2c78 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2001,6 +2001,11 @@ public: static const HA_ALTER_FLAGS ALTER_DROP_CHECK_CONSTRAINT= 1ULL << 40; + /** + Change in index length such that it doesn't require index rebuild. + */ + static const HA_ALTER_FLAGS ALTER_COLUMN_INDEX_LENGTH= 1ULL << 41; + /** Create options (like MAX_ROWS) for the new version of table. diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1b426f80a88..19100aafd51 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6303,7 +6303,7 @@ static bool fill_alter_inplace_info(THD *thd, bool varchar, Alter_inplace_info *ha_alter_info) { - Field **f_ptr, *field; + Field **f_ptr, *field, *old_field; List_iterator_fast new_field_it; Create_field *new_field; KEY_PART_INFO *key_part, *new_part; @@ -6629,6 +6629,7 @@ static bool fill_alter_inplace_info(THD *thd, Go through keys and check if the original ones are compatible with new table. */ + uint old_field_len= 0; KEY *table_key; KEY *table_key_end= table->key_info + table->s->keys; KEY *new_key; @@ -6693,17 +6694,35 @@ static bool fill_alter_inplace_info(THD *thd, key_part < end; key_part++, new_part++) { - /* - Key definition has changed if we are using a different field or - if the used key part length is different. It makes sense to - check lengths first as in case when fields differ it is likely - that lengths differ too and checking fields is more expensive - in general case. - */ - if (key_part->length != new_part->length) - goto index_changed; - new_field= get_field_by_index(alter_info, new_part->fieldnr); + old_field= table->field[key_part->fieldnr - 1]; + /* + If there is a change in index length due to column expansion + like varchar(X) changed to varchar(X + N) and has a compatible + packed data representation, we mark it for fast/INPLACE change + in index definition. InnoDB supports INPLACE for this cases + + Key definition has changed if we are using a different field or + if the user key part length is different. + */ + old_field_len= old_field->pack_length(); + + if (old_field->type() == MYSQL_TYPE_VARCHAR) + { + old_field_len= (old_field->pack_length() + - ((Field_varstring*) old_field)->length_bytes); + } + + if (key_part->length == old_field_len && + key_part->length < new_part->length && + (key_part->field->is_equal((Create_field*) new_field) + == IS_EQUAL_PACK_LENGTH)) + { + ha_alter_info->handler_flags |= + Alter_inplace_info::ALTER_COLUMN_INDEX_LENGTH; + } + else if (key_part->length != new_part->length) + goto index_changed; /* For prefix keys KEY_PART_INFO::field points to cloned Field diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 0f896e6138f..13d78d636d8 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -90,7 +90,8 @@ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_INPLACE_IGNORE | Alter_inplace_info::ALTER_COLUMN_COLUMN_FORMAT | Alter_inplace_info::ALTER_COLUMN_STORAGE_TYPE | Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR - | Alter_inplace_info::ALTER_RENAME; + | Alter_inplace_info::ALTER_RENAME + | Alter_inplace_info::ALTER_COLUMN_INDEX_LENGTH; /** Operations on foreign key definitions (changing the schema only) */ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_FOREIGN_OPERATIONS From c9f0a4a9bf52dedb229c7b12eee05db2b08a0289 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 30 Jan 2019 15:16:36 +0100 Subject: [PATCH 08/22] MDEV-18426: Most of the mtr tests in the galera_3nodes suite fail Most of the mtr tests in the galera_3nodes suite fail for a variety of reasons with a variety of errors. Some tests simply need to add the missing "connection" lines to the result files, but many of them fail due to substantial errors that require reworking test files. This patch adds the missing "connection" lines to the result files and fixes several substantial flaws in the galera_3nodes suite tests and in the mtr framework service files, adapting the tests from galera_3nodes for the current version of MariaDB. https://jira.mariadb.org/browse/MDEV-18426 --- .../galera => }/include/galera_resume.inc | 2 +- .../include/galera_suspend.inc | 2 +- mysql-test/include/mtr_check.sql | 1 + .../r/galera_evs_suspect_timeout.result | 6 ++++ .../suite/galera_3nodes/r/galera_garbd.result | 8 +++++ .../r/galera_ist_gcache_rollover.result | 1 + .../r/galera_pc_bootstrap.result | 11 +++++++ .../galera_3nodes/r/galera_pc_weight.result | 13 ++++++++ .../r/galera_safe_to_bootstrap.result | 27 ++++++++++++++++ .../r/galera_var_dirty_reads2.result | 5 +++ .../t/galera_evs_suspect_timeout.test | 2 +- .../suite/galera_3nodes/t/galera_garbd.test | 8 +++-- .../t/galera_ist_gcache_rollover.cnf | 6 ++-- .../t/galera_ist_gcache_rollover.test | 1 + .../t/galera_safe_to_bootstrap.test | 32 ++++++++++++++++--- 15 files changed, 112 insertions(+), 13 deletions(-) rename mysql-test/{suite/galera => }/include/galera_resume.inc (80%) rename mysql-test/{suite/galera_3nodes => }/include/galera_suspend.inc (86%) diff --git a/mysql-test/suite/galera/include/galera_resume.inc b/mysql-test/include/galera_resume.inc similarity index 80% rename from mysql-test/suite/galera/include/galera_resume.inc rename to mysql-test/include/galera_resume.inc index 232cb46479e..af8f2b956fd 100644 --- a/mysql-test/suite/galera/include/galera_resume.inc +++ b/mysql-test/include/galera_resume.inc @@ -3,7 +3,7 @@ my $pid_filename = $ENV{'_SUSPEND_NODE_PIDFILE'}; my $mysqld_pid = `cat $pid_filename`; chomp($mysqld_pid); - system("kill -18 $mysqld_pid"); + system("kill -SIGCONT $mysqld_pid"); exit(0); EOF diff --git a/mysql-test/suite/galera_3nodes/include/galera_suspend.inc b/mysql-test/include/galera_suspend.inc similarity index 86% rename from mysql-test/suite/galera_3nodes/include/galera_suspend.inc rename to mysql-test/include/galera_suspend.inc index 3495ad2342b..d4037d8958c 100644 --- a/mysql-test/suite/galera_3nodes/include/galera_suspend.inc +++ b/mysql-test/include/galera_suspend.inc @@ -9,6 +9,6 @@ my $pid_filename = $ENV{'_SUSPEND_NODE_PIDFILE'}; my $mysqld_pid = `cat $pid_filename`; chomp($mysqld_pid); - system("kill -19 $mysqld_pid"); + system("kill -SIGSTOP $mysqld_pid"); exit(0); EOF diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index f2c0b70e192..9f29222c969 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -35,6 +35,7 @@ BEGIN AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP' AND variable_name not like 'GTID%POS' AND variable_name != 'GTID_BINLOG_STATE' + AND variable_name != 'AUTO_INCREMENT_INCREMENT' ORDER BY variable_name; -- Dump all databases, there should be none diff --git a/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result b/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result index 7e0d282ec7f..6a7eea94077 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result +++ b/mysql-test/suite/galera_3nodes/r/galera_evs_suspect_timeout.result @@ -1,12 +1,17 @@ +connection node_1; SET GLOBAL wsrep_provider_options = 'evs.inactive_timeout=PT100M; evs.suspect_timeout=PT1S'; +connection node_2; SET GLOBAL wsrep_provider_options = 'evs.inactive_timeout=PT100M; evs.suspect_timeout=PT1S'; +connection node_3; Suspending node ... +connection node_1; SET SESSION wsrep_sync_wait = 0; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 1 CREATE TABLE t1 (f1 INTEGER); INSERT INTO t1 VALUES (1); +connection node_2; SET SESSION wsrep_sync_wait = 0; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 @@ -17,4 +22,5 @@ COUNT(*) = 1 1 DROP TABLE t1; Resuming node ... +connection node_3; CALL mtr.add_suppression("WSREP: gcs_caused() returned -1 \\(Operation not permitted\\)"); diff --git a/mysql-test/suite/galera_3nodes/r/galera_garbd.result b/mysql-test/suite/galera_3nodes/r/galera_garbd.result index 180aade029c..2d70b1742ab 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_garbd.result +++ b/mysql-test/suite/galera_3nodes/r/galera_garbd.result @@ -1,17 +1,25 @@ Killing node #3 to free ports for garbd ... +connection node_1; Starting garbd ... CREATE TABLE t1 (f1 INTEGER); INSERT INTO t1 VALUES (1); +connection node_2; SELECT COUNT(*) = 1 FROM t1; COUNT(*) = 1 1 Killing garbd ... +connection node_1; INSERT INTO t1 VALUES (2); +connection node_2; SELECT COUNT(*) = 2 FROM t1; COUNT(*) = 2 1 DROP TABLE t1; Restarting node #3 to satisfy MTR's end-of-test checks +connection node_3; +connection node_1; CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)"); +connection node_2; CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)"); +connection node_3; CALL mtr.add_suppression("WSREP: Protocol violation\. JOIN message sender 1\.0 \(.*\) is not in state transfer \(SYNCED\)"); diff --git a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result index 3d4dbcc00b0..aa3e349eda7 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result +++ b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result @@ -1,6 +1,7 @@ connection node_1; connection node_2; connection node_3; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); INSERT INTO t1 VALUES (01), (02), (03), (04), (05); connection node_2; diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result index 69995acb982..3405beef12f 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_bootstrap.result @@ -1,8 +1,13 @@ CREATE TABLE t1 (f1 INTEGER); +connection node_1; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; +connection node_2; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET SESSION wsrep_sync_wait = 0; +connection node_2; SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1'; SHOW STATUS LIKE 'wsrep_cluster_size'; Variable_name Value @@ -11,15 +16,21 @@ SHOW STATUS LIKE 'wsrep_cluster_status'; Variable_name Value wsrep_cluster_status Primary INSERT INTO t1 VALUES (1); +connection node_2; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +connection node_1; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +connection node_3; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +connection node_1; SELECT COUNT(*) FROM t1; COUNT(*) 1 +connection node_2; SELECT COUNT(*) FROM t1; COUNT(*) 1 +connection node_3; SELECT COUNT(*) FROM t1; COUNT(*) 1 diff --git a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result index 9f845ffe776..240232d9c96 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result +++ b/mysql-test/suite/galera_3nodes/r/galera_pc_weight.result @@ -1,9 +1,11 @@ +connection node_1; SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight'; VARIABLE_VALUE = 3 SET GLOBAL wsrep_provider_options = 'pc.weight=3'; SELECT VARIABLE_VALUE = 5 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight'; VARIABLE_VALUE = 5 SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; +connection node_2; SET SESSION wsrep_sync_wait=0; SET SESSION wsrep_on=OFF; SET SESSION wsrep_on=ON; @@ -27,6 +29,7 @@ wsrep_local_state 0 SHOW STATUS LIKE 'wsrep_local_state_comment'; Variable_name Value wsrep_local_state_comment Initialized +connection node_3; SET SESSION wsrep_sync_wait=0; SET SESSION wsrep_on=OFF; SET SESSION wsrep_on=ON; @@ -50,6 +53,7 @@ wsrep_local_state 0 SHOW STATUS LIKE 'wsrep_local_state_comment'; Variable_name Value wsrep_local_state_comment Initialized +connection node_1; SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight'; VARIABLE_VALUE = 3 SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; @@ -70,7 +74,11 @@ VARIABLE_VALUE = 'Synced' SET GLOBAL wsrep_provider_options = 'pc.weight=1'; SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight'; VARIABLE_VALUE = 1 +connection node_1; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; +connection node_2; +connection node_3; +connection node_1; SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 3 1 @@ -91,6 +99,7 @@ VARIABLE_VALUE = 4 SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 +connection node_2; SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 3 1 @@ -111,6 +120,7 @@ VARIABLE_VALUE = 4 SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 +connection node_3; SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 3 1 @@ -131,12 +141,15 @@ VARIABLE_VALUE = 4 SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; VARIABLE_VALUE = 'Synced' 1 +connection node_1; SET GLOBAL wsrep_provider_options = 'pc.weight=1'; CALL mtr.add_suppression('WSREP: gcs_caused\\(\\) returned -1'); +connection node_2; CALL mtr.add_suppression('overriding reported weight for'); CALL mtr.add_suppression('SYNC message from member'); CALL mtr.add_suppression('user message in state LEAVING'); CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)'); +connection node_3; CALL mtr.add_suppression('WSREP: user message in state LEAVING'); CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)'); CALL mtr.add_suppression('overriding reported weight for'); diff --git a/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result index 21f747d280b..45b4d63fb4f 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result +++ b/mysql-test/suite/galera_3nodes/r/galera_safe_to_bootstrap.result @@ -1,22 +1,49 @@ +connection node_1; +connection node_2; +connection node_3; +connection node_1; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +connection node_2; +connection node_1; include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +connection node_3; +connection node_1; include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 1'] +connection node_2; +connection node_1; include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] include/assert_grep.inc [grastate.dat does not have 'safe_to_bootstrap: 0'] +connection node_2; +connection node_1; SET SESSION wsrep_on = OFF; Killing server ... safe_to_bootstrap: 1 safe_to_bootstrap: 0 safe_to_bootstrap: 0 +connection node_1; +connection node_2; +connection node_3; +connection node_2; +CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible"); +CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node"); +CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7"); +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0"); CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); +connection node_3; +CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible"); +CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node"); +CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7"); +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0"); CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); SHOW CREATE TABLE t1; Table Create Table diff --git a/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result index 88780a2c87f..c6756bce210 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result +++ b/mysql-test/suite/galera_3nodes/r/galera_var_dirty_reads2.result @@ -1,6 +1,9 @@ CREATE TABLE t1 (f1 INTEGER); INSERT INTO t1 VALUES (1); +connection node_2; SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; +connection node_1; +connection node_2; SET SESSION wsrep_sync_wait = 0; SET SESSION wsrep_dirty_reads = 1; SELECT f1 FROM t1; @@ -45,4 +48,6 @@ SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST; COUNT(*) > 0 1 SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; +connection node_1; +connection node_2; DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test b/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test index 03236a3cb93..4dab936c343 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test +++ b/mysql-test/suite/galera_3nodes/t/galera_evs_suspect_timeout.test @@ -56,8 +56,8 @@ DROP TABLE t1; # Reconnect node #3 so that MTR's end-of-test checks can run ---connection node_3 --source include/galera_resume.inc +--connection node_3 --source include/wait_until_connected_again.inc CALL mtr.add_suppression("WSREP: gcs_caused() returned -1 \\(Operation not permitted\\)"); diff --git a/mysql-test/suite/galera_3nodes/t/galera_garbd.test b/mysql-test/suite/galera_3nodes/t/galera_garbd.test index a68ba8ce15b..5509c4628c9 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_garbd.test +++ b/mysql-test/suite/galera_3nodes/t/galera_garbd.test @@ -11,6 +11,8 @@ --let $galera_connection_name = node_3 --let $galera_server_number = 3 --source include/galera_connect.inc +--let $gp3 = `SELECT SUBSTR(@@wsrep_provider_options, LOCATE('base_port =', @@wsrep_provider_options) + LENGTH('base_port = '))` +--let $galera_port_3 = `SELECT SUBSTR('$gp3', 1, LOCATE(';', '$gp3') - 1)` --source include/shutdown_mysqld.inc --connection node_1 @@ -18,7 +20,9 @@ --source include/wait_condition.inc --echo Starting garbd ... ---exec `dirname $WSREP_PROVIDER`/garb/garbd --address "gcomm://127.0.0.1:$NODE_GALERAPORT_1" --group my_wsrep_cluster --options 'base_port=$NODE_GALERAPORT_3' > $MYSQL_TMP_DIR/garbd.log 2>&1 & +--let $gp1 = `SELECT SUBSTR(@@wsrep_provider_options, LOCATE('base_port =', @@wsrep_provider_options) + LENGTH('base_port = '))` +--let $galera_port_1 = `SELECT SUBSTR('$gp1', 1, LOCATE(';', '$gp1') - 1)` +--exec `dirname $WSREP_PROVIDER`/../../bin/garb/garbd --address "gcomm://127.0.0.1:$galera_port_1" --group my_wsrep_cluster --options 'base_port=$galera_port_3' > $MYSQL_TMP_DIR/garbd.log 2>&1 & --sleep 5 @@ -32,7 +36,7 @@ INSERT INTO t1 VALUES (1); SELECT COUNT(*) = 1 FROM t1; --echo Killing garbd ... ---exec pkill --oldest --full garbd.*$NODE_GALERAPORT_3 +--exec pkill --oldest --full garbd.*$galera_port_3 --sleep 5 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf index 821175220ac..303087dffbb 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf @@ -1,11 +1,11 @@ !include ../galera_3nodes.cnf [mysqld.1] -wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true;gcache.size=1M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' [mysqld.2] -wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true;gcache.size=1M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' [mysqld.3] -wsrep_provider_options='base_port=@mysqld.3.#galera_port;pc.ignore_sb=true;gcache.size=1M' +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test index a67b30e3fa1..ebc756d60b1 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test @@ -23,6 +23,7 @@ --let $node_3=node_3 --source ../galera/include/auto_increment_offset_save.inc +--connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); INSERT INTO t1 VALUES (01), (02), (03), (04), (05); diff --git a/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test index 88d0cfba4f4..b7b6c66e5ad 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test +++ b/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test @@ -1,8 +1,19 @@ # # Test the safe_to_bootstrap in grastate.dat # - --source include/galera_cluster.inc + +--let $galera_connection_name = node_3 +--let $galera_server_number = 3 +--source include/galera_connect.inc + +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc + +--connection node_1 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; # @@ -47,8 +58,6 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; # # Shut down one more node # - ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 --connection node_3 --source include/shutdown_mysqld.inc @@ -129,9 +138,9 @@ SET SESSION wsrep_on = OFF; # --error 1 ---exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' +--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster --wsrep-cluster-address='gcomm://' | grep 'This node is not safe to bootstrap the cluster' --error 1 ---exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' +--exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster --wsrep-cluster-address='gcomm://' | grep 'This node is not safe to bootstrap the cluster' # # Attempt to bootstrap starting from node #1, should succeed @@ -154,10 +163,23 @@ SET SESSION wsrep_on = OFF; --source include/wait_condition.inc --connection node_2 +CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible"); +CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node"); +CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7"); +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0"); CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); --connection node_3 +CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible"); +CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node"); +CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7"); +CALL mtr.add_suppression("Aborting"); +CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0"); CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); SHOW CREATE TABLE t1; DROP TABLE t1; + +# Restore original auto_increment_offset values. +--source ../galera/include/auto_increment_offset_restore.inc From 6caf9ec425a12ed54741cdf4c4a238c45cabd898 Mon Sep 17 00:00:00 2001 From: Kentoku Date: Tue, 20 Nov 2018 00:12:58 +0900 Subject: [PATCH 09/22] Update Spider to version 3.3.14. Add direct left outer join/right outer join/inner join feature --- storage/spider/ha_spider.cc | 191 +++- storage/spider/ha_spider.h | 94 +- storage/spider/hs_client/hs_compat.h | 2 +- .../include/direct_join_using_deinit.inc | 9 + .../spider/include/direct_join_using_init.inc | 13 + .../include/direct_left_join_deinit.inc | 9 + .../spider/include/direct_left_join_init.inc | 13 + .../direct_left_join_nullable_deinit.inc | 9 + .../direct_left_join_nullable_init.inc | 13 + ...direct_left_right_join_nullable_deinit.inc | 9 + .../direct_left_right_join_nullable_init.inc | 13 + ...t_left_right_left_join_nullable_deinit.inc | 9 + ...ect_left_right_left_join_nullable_init.inc | 13 + .../include/direct_right_join_deinit.inc | 9 + .../spider/include/direct_right_join_init.inc | 13 + .../direct_right_join_nullable_deinit.inc | 9 + .../direct_right_join_nullable_init.inc | 13 + ...direct_right_left_join_nullable_deinit.inc | 9 + .../direct_right_left_join_nullable_init.inc | 13 + ..._right_left_right_join_nullable_deinit.inc | 9 + ...ct_right_left_right_join_nullable_init.inc | 13 + .../mysql-test/spider/include/init_spider.inc | 42 +- .../spider/r/direct_join_using.result | 108 +++ .../spider/r/direct_left_join.result | 108 +++ .../spider/r/direct_left_join_nullable.result | 113 +++ .../r/direct_left_right_join_nullable.result | 113 +++ ...irect_left_right_left_join_nullable.result | 112 +++ .../spider/r/direct_right_join.result | 108 +++ .../r/direct_right_join_nullable.result | 113 +++ .../r/direct_right_left_join_nullable.result | 112 +++ ...rect_right_left_right_join_nullable.result | 113 +++ .../spider/r/show_system_tables.result | 37 + .../spider/t/direct_join_using.test | 197 ++++ .../mysql-test/spider/t/direct_left_join.test | 197 ++++ .../spider/t/direct_left_join_nullable.test | 212 ++++ .../t/direct_left_right_join_nullable.test | 212 ++++ .../direct_left_right_left_join_nullable.test | 212 ++++ .../spider/t/direct_right_join.test | 197 ++++ .../spider/t/direct_right_join_nullable.test | 212 ++++ .../t/direct_right_left_join_nullable.test | 212 ++++ ...direct_right_left_right_join_nullable.test | 212 ++++ .../spider/t/show_system_tables.test | 26 + storage/spider/scripts/install_spider.sql | 88 +- storage/spider/spd_conn.cc | 9 +- storage/spider/spd_conn.h | 4 +- storage/spider/spd_copy_tables.cc | 45 +- storage/spider/spd_db_conn.cc | 417 +++++--- storage/spider/spd_db_conn.h | 23 +- storage/spider/spd_db_handlersocket.cc | 105 +- storage/spider/spd_db_handlersocket.h | 7 +- storage/spider/spd_db_include.h | 10 +- storage/spider/spd_db_mysql.cc | 904 ++++++++++++++---- storage/spider/spd_db_mysql.h | 45 +- storage/spider/spd_db_oracle.cc | 288 ++++-- storage/spider/spd_db_oracle.h | 9 +- storage/spider/spd_direct_sql.cc | 79 +- storage/spider/spd_environ.h | 15 +- storage/spider/spd_group_by_handler.cc | 63 +- storage/spider/spd_i_s.cc | 4 +- storage/spider/spd_include.h | 85 +- storage/spider/spd_param.cc | 27 +- storage/spider/spd_param.h | 5 +- storage/spider/spd_ping_table.cc | 2 +- storage/spider/spd_sys_table.cc | 163 +++- storage/spider/spd_sys_table.h | 33 +- storage/spider/spd_table.cc | 42 +- storage/spider/spd_trx.cc | 14 +- 67 files changed, 5242 insertions(+), 697 deletions(-) create mode 100644 storage/spider/mysql-test/spider/include/direct_join_using_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_join_using_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_join_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_join_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_join_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_join_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc create mode 100644 storage/spider/mysql-test/spider/r/direct_join_using.result create mode 100644 storage/spider/mysql-test/spider/r/direct_left_join.result create mode 100644 storage/spider/mysql-test/spider/r/direct_left_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/direct_right_join.result create mode 100644 storage/spider/mysql-test/spider/r/direct_right_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result create mode 100644 storage/spider/mysql-test/spider/r/show_system_tables.result create mode 100644 storage/spider/mysql-test/spider/t/direct_join_using.test create mode 100644 storage/spider/mysql-test/spider/t/direct_left_join.test create mode 100644 storage/spider/mysql-test/spider/t/direct_left_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/direct_right_join.test create mode 100644 storage/spider/mysql-test/spider/t/direct_right_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test create mode 100644 storage/spider/mysql-test/spider/t/show_system_tables.test diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index bd302f155d2..8471af40289 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -64,6 +64,9 @@ extern HASH spider_open_tables; #endif extern pthread_mutex_t spider_lgtm_tblhnd_share_mutex; +/* UTC time zone for timestamp columns */ +extern Time_zone *UTC; + ha_spider::ha_spider( ) : handler(spider_hton_ptr, NULL) { @@ -7963,7 +7966,7 @@ int ha_spider::cmp_ref( if ((ret = (*field)->cmp_binary_offset((uint) ptr_diff))) { DBUG_PRINT("info",("spider different at %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); break; } } @@ -9959,21 +9962,38 @@ int ha_spider::end_bulk_update( DBUG_RETURN(0); } +#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int ha_spider::bulk_update_row( const uchar *old_data, const uchar *new_data, ha_rows *dup_key_found -) { +) +#else +int ha_spider::bulk_update_row( + const uchar *old_data, + uchar *new_data, + ha_rows *dup_key_found +) +#endif +{ DBUG_ENTER("ha_spider::bulk_update_row"); DBUG_PRINT("info",("spider this=%p", this)); *dup_key_found = 0; DBUG_RETURN(update_row(old_data, new_data)); } +#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int ha_spider::update_row( const uchar *old_data, const uchar *new_data -) { +) +#else +int ha_spider::update_row( + const uchar *old_data, + uchar *new_data +) +#endif +{ int error_num; THD *thd = ha_thd(); backup_error_status(); @@ -10064,10 +10084,24 @@ int ha_spider::update_row( #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::direct_update_rows_init(List *update_fields, uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, bool sorted, - const uchar *new_data) +#ifdef SPIDER_MDEV_16246 +int ha_spider::direct_update_rows_init( + List *update_fields, + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) +#else +int ha_spider::direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) +#endif { #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) int error_num; @@ -10095,8 +10129,13 @@ int ha_spider::direct_update_rows_init(List *update_fields, uint mode, pre_direct_init_result)); DBUG_RETURN(pre_direct_init_result); } +#ifdef SPIDER_MDEV_16246 DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( update_fields, mode, ranges, range_count, sorted, new_data)); +#else + DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( + mode, ranges, range_count, sorted, new_data)); +#endif } #endif direct_update_init( @@ -10200,6 +10239,7 @@ int ha_spider::direct_update_rows_init(List *update_fields, uint mode, DBUG_RETURN(HA_ERR_WRONG_COMMAND); } #else +#ifdef SPIDER_MDEV_16246 /** Perform initialization for a direct update request. @@ -10209,37 +10249,43 @@ int ha_spider::direct_update_rows_init(List *update_fields, uint mode, 0 Success. */ -int ha_spider::direct_update_rows_init(List *update_fields) +int ha_spider::direct_update_rows_init( + List *update_fields +) +#else +int ha_spider::direct_update_rows_init() +#endif { st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - List_iterator it(*update_fields); + List_iterator it(*direct_update_fields); Item *item; Field *field; THD *thd = trx->thd; DBUG_ENTER("ha_spider::direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); - - while ((item = it++)) + if (thd->variables.time_zone != UTC) { - if (item->type() == Item::FIELD_ITEM) + while ((item = it++)) { - field = ((Item_field *)item)->field; - - if (field->type() == FIELD_TYPE_TIMESTAMP && - field->flags & UNIQUE_KEY_FLAG) + if (item->type() == Item::FIELD_ITEM) { - /* - Spider cannot perform direct update on unique timestamp fields. - To avoid false duplicate key errors, the table needs to be - updated one row at a time. - */ - DBUG_RETURN(HA_ERR_WRONG_COMMAND); + field = ((Item_field *)item)->field; + + if (field->type() == FIELD_TYPE_TIMESTAMP && + field->flags & UNIQUE_KEY_FLAG) + { + /* + Spider cannot perform direct update on unique timestamp fields. + To avoid false duplicate key errors, the table needs to be + updated one row at a time. + */ + DBUG_RETURN(HA_ERR_WRONG_COMMAND); + } } } } - #ifdef HA_CAN_BULK_ACCESS if ( bulk_access_executing && @@ -10257,8 +10303,12 @@ int ha_spider::direct_update_rows_init(List *update_fields) pre_direct_init_result)); DBUG_RETURN(pre_direct_init_result); } +#ifdef SPIDER_MDEV_16246 DBUG_RETURN(bulk_access_link_exec_tgt->spider-> - direct_update_rows_init(List *update_fields)); + direct_update_rows_init(update_fields)); +#else + DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init()); +#endif } #endif direct_update_init( @@ -10329,30 +10379,54 @@ int ha_spider::direct_update_rows_init(List *update_fields) #ifdef HA_CAN_BULK_ACCESS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_update_rows_init(List *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, bool sorted, - const uchar *new_data) +#ifdef SPIDER_MDEV_16246 +int ha_spider::pre_direct_update_rows_init( + List *update_fields, + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) +#else +int ha_spider::pre_direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data +) +#endif { int error_num; DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); if (bulk_access_started) { +#ifdef SPIDER_MDEV_16246 error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init(update_fields, mode, ranges, range_count, - sorted, new_data); + pre_direct_update_rows_init( + update_fields, mode, ranges, range_count, sorted, new_data); +#else + error_num = bulk_access_link_current->spider-> + pre_direct_update_rows_init( + mode, ranges, range_count, sorted, new_data); +#endif bulk_access_link_current->spider->bulk_access_pre_called = TRUE; bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } - pre_direct_init_result = direct_update_rows_init(update_fields, mode, - ranges, range_count, - sorted, new_data); +#ifdef SPIDER_MDEV_16246 + pre_direct_init_result = direct_update_rows_init( + update_fields, mode, ranges, range_count, sorted, new_data); +#else + pre_direct_init_result = direct_update_rows_init( + mode, ranges, range_count, sorted, new_data); +#endif DBUG_RETURN(pre_direct_init_result); } #else +#ifdef SPIDER_MDEV_16246 /** Do initialization for performing parallel direct update for a handlersocket update request. @@ -10363,20 +10437,34 @@ int ha_spider::pre_direct_update_rows_init(List *update_fields, 0 Success. */ -int ha_spider::pre_direct_update_rows_init(List *update_fields) +int ha_spider::pre_direct_update_rows_init( + List *update_fields +) +#else +int ha_spider::pre_direct_update_rows_init() +#endif { int error_num; DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); if (bulk_access_started) { +#ifdef SPIDER_MDEV_16246 error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init(update_fields); + pre_direct_update_rows_init(update_fields); +#else + error_num = bulk_access_link_current->spider-> + pre_direct_update_rows_init(); +#endif bulk_access_link_current->spider->bulk_access_pre_called = TRUE; bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); } +#ifdef SPIDER_MDEV_16246 pre_direct_init_result = direct_update_rows_init(update_fields); +#else + pre_direct_init_result = direct_update_rows_init(); +#endif DBUG_RETURN(pre_direct_init_result); } #endif @@ -11305,7 +11393,7 @@ int ha_spider::create( DBUG_PRINT("info", ("spider alter_info.flags: %llu alter_info.partition_flags: %lu", - thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); + thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); if ((thd->lex->alter_info.partition_flags & ( SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP | @@ -11501,7 +11589,7 @@ int ha_spider::rename_table( DBUG_PRINT("info", ("spider alter_info.flags: %llu alter_info.partition_flags: %lu", - thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); + thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); if ( (thd->lex->alter_info.partition_flags & ( @@ -11697,7 +11785,7 @@ int ha_spider::delete_table( DBUG_PRINT("info", ("spider alter_info.flags: %llu alter_info.partition_flags: %lu", - thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); + thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags)); if ( sql_command == SQLCOM_ALTER_TABLE && (thd->lex->alter_info.partition_flags & @@ -13514,6 +13602,7 @@ void ha_spider::check_pre_call( bool use_parallel ) { THD* thd = ha_thd(); + LEX *lex = thd->lex; st_select_lex *select_lex = spider_get_select_lex(this); int skip_parallel_search = spider_param_skip_parallel_search(thd, share->skip_parallel_search); @@ -13522,11 +13611,15 @@ void ha_spider::check_pre_call( if ( ( (skip_parallel_search & 1) && - thd->lex && thd->lex->sql_command != SQLCOM_SELECT // such like insert .. select .. + lex->sql_command != SQLCOM_SELECT // such like insert .. select .. ) || ( (skip_parallel_search & 2) && +#ifdef SPIDER_SQL_CACHE_IS_IN_LEX + lex->sql_cache == LEX::SQL_NO_CACHE // for mysqldump +#else select_lex && select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE // for mysqldump +#endif ) ) { use_pre_call = FALSE; @@ -15672,12 +15765,23 @@ int ha_spider::mk_bulk_tmp_table_and_bulk_start() dbton_hdl->first_link_idx >= 0 && dbton_hdl->need_copy_for_update(roop_count) ) { +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor + LEX_CSTRING field_name = {STRING_WITH_LEN("a")}; + if ( + !tmp_table[roop_count] && + !(tmp_table[roop_count] = spider_mk_sys_tmp_table( + trx->thd, table, &result_list.upd_tmp_tbl_prms[roop_count], + &field_name, result_list.update_sqls[roop_count].charset())) + ) +#else if ( !tmp_table[roop_count] && !(tmp_table[roop_count] = spider_mk_sys_tmp_table( trx->thd, table, &result_list.upd_tmp_tbl_prms[roop_count], "a", result_list.update_sqls[roop_count].charset())) - ) { + ) +#endif + { error_num = HA_ERR_OUT_OF_MEM; goto error_2; } @@ -15775,8 +15879,7 @@ int ha_spider::print_item_type( if ( dbton_hdl->first_link_idx >= 0 && (error_num = spider_db_print_item_type(item, NULL, this, str, - alias, alias_length, dbton_id, - FALSE, NULL)) + alias, alias_length, dbton_id, FALSE, NULL)) ) { DBUG_RETURN(error_num); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 66e5cf8a452..d33d9a3a7dc 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -576,6 +576,7 @@ public: ha_rows *dup_key_found ); int end_bulk_update(); +#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int bulk_update_row( const uchar *old_data, const uchar *new_data, @@ -585,31 +586,92 @@ public: const uchar *old_data, const uchar *new_data ); +#else + int bulk_update_row( + const uchar *old_data, + uchar *new_data, + ha_rows *dup_key_found + ); + int update_row( + const uchar *old_data, + uchar *new_data + ); +#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int direct_update_rows_init(List *update_fields) - { +#ifdef SPIDER_MDEV_16246 + inline int direct_update_rows_init( + List *update_fields + ) { return direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); } - int direct_update_rows_init(List *update_fields, uint mode, - KEY_MULTI_RANGE *ranges, uint range_count, - bool sorted, const uchar *new_data); + int direct_update_rows_init( + List *update_fields, + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); #else - int direct_update_rows_init(List *update_fields); + inline int direct_update_rows_init() + { + return direct_update_rows_init(2, NULL, 0, FALSE, NULL); + } + int direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); +#endif +#else +#ifdef SPIDER_MDEV_16246 + int direct_update_rows_init( + List *update_fields + ); +#else + int direct_update_rows_init(); +#endif #endif #ifdef HA_CAN_BULK_ACCESS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_update_rows_init(List *update_fields) - { - return pre_direct_update_rows_init(update_fields, - 2, NULL, 0, FALSE, NULL); +#ifdef SPIDER_MDEV_16246 + inline int pre_direct_update_rows_init( + List *update_fields + ) { + return pre_direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); } - int pre_direct_update_rows_init(List *update_fields, - uint mode, KEY_MULTI_RANGE *ranges, - uint range_count, bool sorted, - uchar *new_data); + int pre_direct_update_rows_init( + List *update_fields, + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); #else - int pre_direct_update_rows_init(List *update_fields); + inline int pre_direct_update_rows_init() + { + return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL); + } + int pre_direct_update_rows_init( + uint mode, + KEY_MULTI_RANGE *ranges, + uint range_count, + bool sorted, + uchar *new_data + ); +#endif +#else +#ifdef SPIDER_MDEV_16246 + int pre_direct_update_rows_init( + List *update_fields + ); +#else + int pre_direct_update_rows_init(); +#endif #endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h index e832b2974da..a1b18fe1b38 100644 --- a/storage/spider/hs_client/hs_compat.h +++ b/storage/spider/hs_client/hs_compat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Kentoku Shiba +/* Copyright (C) 2013-2018 Kentoku Shiba 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 diff --git a/storage/spider/mysql-test/spider/include/direct_join_using_deinit.inc b/storage/spider/mysql-test/spider/include/direct_join_using_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_join_using_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_join_using_init.inc b/storage/spider/mysql-test/spider/include/direct_join_using_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_join_using_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_deinit.inc b/storage/spider/mysql-test/spider/include/direct_left_join_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_join_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_init.inc b/storage/spider/mysql-test/spider/include/direct_left_join_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_join_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_deinit.inc b/storage/spider/mysql-test/spider/include/direct_right_join_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_join_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_init.inc b/storage/spider/mysql-test/spider/include/direct_right_join_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_join_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_deinit.inc b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_deinit.inc new file mode 100644 index 00000000000..53bc29a0016 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_deinit.inc @@ -0,0 +1,9 @@ +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc new file mode 100644 index 00000000000..7e4947bf078 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc @@ -0,0 +1,13 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 diff --git a/storage/spider/mysql-test/spider/include/init_spider.inc b/storage/spider/mysql-test/spider/include/init_spider.inc index c4d171d418e..1da1ec970b5 100644 --- a/storage/spider/mysql-test/spider/include/init_spider.inc +++ b/storage/spider/mysql-test/spider/include/init_spider.inc @@ -103,10 +103,17 @@ if (!$VERSION_COMPILE_OS_WIN) ); } +let $SERVER_NAME= + `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '-', 2), '-', -1)`; +let $SERVER_MAJOR_VERSION= + `SELECT SUBSTRING_INDEX(version(), '.', 1)`; +let $SERVER_MINOR_VERSION= + `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '.', 2), '.', -1)`; let $PLUGIN_VERSION= `SELECT SUBSTRING_INDEX(plugin_version, '.', 1) FROM information_schema.plugins WHERE plugin_name = 'SPIDER'`; + if (`SELECT IF($PLUGIN_VERSION = 1, 1, 0)`) { DROP TABLE IF EXISTS mysql.spider_xa; @@ -245,7 +252,16 @@ if (`SELECT IF($PLUGIN_VERSION = 2, 1, 0)`) } if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) { + let $ENGINE_NAME= + `SELECT IF (STRCMP('$SERVER_NAME', 'MariaDB') = 0, + IF ($SERVER_MAJOR_VERSION = 10, + IF ($SERVER_MINOR_VERSION < 4, 'MyISAM', + 'Aria transactional=1'), + IF ($SERVER_MAJOR_VERSION < 10, 'MyISAM', + 'Aria transactional=1')), + 'MyISAM')`; DROP TABLE IF EXISTS mysql.spider_xa; + eval CREATE TABLE mysql.spider_xa( format_id int not null default 0, gtrid_length int not null default 0, @@ -254,8 +270,9 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) status char(8) not null default '', PRIMARY KEY (data, format_id, gtrid_length), KEY idx1 (status) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_xa_member; + eval CREATE TABLE mysql.spider_xa_member( format_id int not null default 0, gtrid_length int not null default 0, @@ -276,8 +293,9 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) default_file text default null, default_group char(64) default null, KEY idx1 (data, format_id, gtrid_length, host) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_xa_failed_log; + eval CREATE TABLE mysql.spider_xa_failed_log( format_id int not null default 0, gtrid_length int not null default 0, @@ -301,8 +319,9 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) status char(8) not null default '', failed_time timestamp not null default current_timestamp, key idx1 (data, format_id, gtrid_length, host) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_tables; + eval CREATE TABLE mysql.spider_tables( db_name char(64) not null default '', table_name char(199) not null default '', @@ -332,8 +351,9 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) PRIMARY KEY (db_name, table_name, link_id), KEY idx1 (priority), UNIQUE KEY uidx1 (db_name, table_name, static_link_id) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_link_mon_servers; + eval CREATE TABLE mysql.spider_link_mon_servers( db_name char(64) not null default '', table_name char(199) not null default '', @@ -355,15 +375,17 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) default_file text default null, default_group char(64) default null, PRIMARY KEY (db_name, table_name, link_id, sid) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_link_failed_log; + eval CREATE TABLE mysql.spider_link_failed_log( db_name char(64) not null default '', table_name char(199) not null default '', link_id char(64) not null default '', failed_time timestamp not null default current_timestamp - ) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery; + eval CREATE TABLE mysql.spider_table_position_for_recovery( db_name char(64) not null default '', table_name char(199) not null default '', @@ -373,8 +395,9 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) position text, gtid text, primary key (db_name, table_name, failed_link_id, source_link_id) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_table_sts; + eval CREATE TABLE mysql.spider_table_sts( db_name char(64) not null default '', table_name char(199) not null default '', @@ -387,15 +410,16 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`) create_time datetime not null default '0000-00-00 00:00:00', update_time datetime not null default '0000-00-00 00:00:00', primary key (db_name, table_name) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; DROP TABLE IF EXISTS mysql.spider_table_crd; + eval CREATE TABLE mysql.spider_table_crd( db_name char(64) not null default '', table_name char(199) not null default '', key_seq int unsigned not null default 0, cardinality bigint not null default 0, primary key (db_name, table_name, key_seq) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + ) ENGINE=$ENGINE_NAME DEFAULT CHARSET=utf8 COLLATE=utf8_bin; } SET spider_internal_sql_log_off= 0; diff --git a/storage/spider/mysql-test/spider/r/direct_join_using.result b/storage/spider/mysql-test/spider/r/direct_join_using.result new file mode 100644 index 00000000000..66ae1503f9f --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_join_using.result @@ -0,0 +1,108 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES5 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES5 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) ORDER BY a.b DESC; +a b c +5 50 500 +4 40 400 +3 30 300 +2 20 200 +1 10 100 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0,`auto_test_remote`.`ta_r_3` t1,`auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 +3 c 2000-01-03 00:00:00 +4 d 2000-01-04 00:00:00 +5 e 2000-01-05 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_left_join.result b/storage/spider/mysql-test/spider/r/direct_left_join.result new file mode 100644 index 00000000000..b63f0661b2e --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_join.result @@ -0,0 +1,108 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES5 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES5 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on a.a = c.a ORDER BY a.b DESC; +a b c +5 50 500 +4 40 400 +3 30 300 +2 20 200 +1 10 100 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 left join `auto_test_remote`.`ta_r_3` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_int` t2 on (t2.`a` = t0.`a`) where 1 order by t0.`b` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 +3 c 2000-01-03 00:00:00 +4 d 2000-01-04 00:00:00 +5 e 2000-01-05 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result new file mode 100644 index 00000000000..e646bc9bf38 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result @@ -0,0 +1,113 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_d a left join tbl_c b on a.a = b.a left join tbl_b c on b.c = c.c left join tbl_a d on c.b = d.b ORDER BY a.a DESC; +a b c a +5 NULL NULL NULL +4 NULL NULL NULL +3 c 2000-01-03 00:00:00 NULL +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on ((t1.`a` = t0.`a`) and (t0.`a` is not null)) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on ((t3.`b` = t2.`b`) and (t2.`b` is not null)) where 1 order by t0.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result new file mode 100644 index 00000000000..f3c6e189444 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result @@ -0,0 +1,113 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL NULL NULL 5 +NULL NULL NULL 4 +NULL NULL NULL 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null) and (t3.`b` is not null)) where 1 order by t3.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result new file mode 100644 index 00000000000..88205fb0f65 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result @@ -0,0 +1,112 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a left join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c left join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL d 2000-01-04 00:00:00 4 +NULL c 2000-01-03 00:00:00 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join (`auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_right_join.result b/storage/spider/mysql-test/spider/r/direct_right_join.result new file mode 100644 index 00000000000..8edfb682292 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_join.result @@ -0,0 +1,108 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES5 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES5 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +PRIMARY KEY(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b INT DEFAULT 10, +c INT DEFAULT 11, +PRIMARY KEY(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on a.a = c.a ORDER BY a.b DESC; +a b c +5 50 500 +4 40 400 +3 30 300 +2 20 200 +1 10 100 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r_int` t2 left join (`auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1) on ((t0.`a` = t2.`a`) and (t1.`a` = t2.`a`)) where 1 order by t0.`b` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 +3 c 2000-01-03 00:00:00 +4 d 2000-01-04 00:00:00 +5 e 2000-01-05 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result new file mode 100644 index 00000000000..a05781cb6d6 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result @@ -0,0 +1,113 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL NULL NULL 5 +NULL d 2000-01-04 00:00:00 4 +NULL c 2000-01-03 00:00:00 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on ((t2.`b` = t3.`b`) and (t3.`b` is not null)) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result new file mode 100644 index 00000000000..25e0913ba06 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result @@ -0,0 +1,112 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c left join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL d 2000-01-04 00:00:00 4 +NULL c 2000-01-03 00:00:00 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result new file mode 100644 index 00000000000..48cd9c2c75f --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result @@ -0,0 +1,113 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a left join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL NULL NULL 5 +NULL NULL NULL 4 +NULL c 2000-01-03 00:00:00 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/show_system_tables.result b/storage/spider/mysql-test/spider/r/show_system_tables.result new file mode 100644 index 00000000000..831d4578efe --- /dev/null +++ b/storage/spider/mysql-test/spider/r/show_system_tables.result @@ -0,0 +1,37 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +Show system tables on the Spider node +connection master_1; +SELECT table_name, engine FROM information_schema.tables +WHERE table_schema = 'mysql' AND table_name like '%spider_%'; +table_name engine +spider_link_failed_log MyISAM +spider_link_mon_servers MyISAM +spider_table_crd MyISAM +spider_table_position_for_recovery MyISAM +spider_table_sts MyISAM +spider_tables MyISAM +spider_xa MyISAM +spider_xa_failed_log MyISAM +spider_xa_member MyISAM + +deinit +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/t/direct_join_using.test b/storage/spider/mysql-test/spider/t/direct_join_using.test new file mode 100644 index 00000000000..819e56ff21c --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_join_using.test @@ -0,0 +1,197 @@ +--source ../include/direct_join_using_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES5; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) ORDER BY a.b DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_join_using_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_left_join.test b/storage/spider/mysql-test/spider/t/direct_left_join.test new file mode 100644 index 00000000000..e09b6a12488 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_left_join.test @@ -0,0 +1,197 @@ +--source ../include/direct_left_join_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES5; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on a.a = c.a ORDER BY a.b DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_left_join_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test new file mode 100644 index 00000000000..dc67a01b4b2 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_left_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_d a left join tbl_c b on a.a = b.a left join tbl_b c on b.c = c.c left join tbl_a d on c.b = d.b ORDER BY a.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_left_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test new file mode 100644 index 00000000000..9d5a990e0ba --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_left_right_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_left_right_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test new file mode 100644 index 00000000000..90e3666957d --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_left_right_left_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_a a left join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c left join tbl_d d on c.b = d.b ORDER BY d.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_left_right_left_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_right_join.test b/storage/spider/mysql-test/spider/t/direct_right_join.test new file mode 100644 index 00000000000..0c0496651d6 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_right_join.test @@ -0,0 +1,197 @@ +--source ../include/direct_right_join_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES5; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES5; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES5; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES5; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + PRIMARY KEY(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b INT DEFAULT 10, + c INT DEFAULT 11, + PRIMARY KEY(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); +insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on a.a = c.a ORDER BY a.b DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_right_join_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test new file mode 100644 index 00000000000..3ab4a30ea84 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_right_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_right_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test new file mode 100644 index 00000000000..fefe255890d --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_right_left_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on b.c = c.c left join tbl_d d on c.b = d.b ORDER BY d.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_right_left_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test new file mode 100644 index 00000000000..48882d27939 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test @@ -0,0 +1,212 @@ +--source ../include/direct_right_left_right_join_nullable_init.inc + +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo test select 1 +--connection master_1 +SELECT 1; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + SELECT 1; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_DROP_TABLES6; + echo CHILD2_1_DROP_TABLES4; + echo CHILD2_1_DROP_TABLES3; + echo CHILD2_1_CREATE_TABLES; + echo CHILD2_1_CREATE_TABLES6; + echo CHILD2_1_CREATE_TABLES4; + echo CHILD2_1_CREATE_TABLES3; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + eval $CHILD2_1_DROP_TABLES6; + eval $CHILD2_1_DROP_TABLES4; + eval $CHILD2_1_DROP_TABLES3; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + eval $CHILD2_1_CREATE_TABLES6; + eval $CHILD2_1_CREATE_TABLES4; + eval $CHILD2_1_CREATE_TABLES3; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1; +eval CREATE TABLE tbl_b ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1; +echo CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1; +eval CREATE TABLE tbl_c ( + a INT AUTO_INCREMENT, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10', + KEY idx0(a), + KEY idx1(b), + KEY idx2(c) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1; +echo CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1; +eval CREATE TABLE tbl_d ( + a INT DEFAULT 10, + b CHAR(1) DEFAULT 'c', + c DATETIME DEFAULT '1999-10-10 10:10:10' +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1; +--enable_query_log +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +--echo +--echo select test +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +SELECT a.a, c.b, c.c, d.a FROM tbl_a a right join tbl_b b on a.a = b.a left join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; + +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/direct_right_left_right_join_nullable_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/show_system_tables.test b/storage/spider/mysql-test/spider/t/show_system_tables.test new file mode 100644 index 00000000000..ae8259b01bc --- /dev/null +++ b/storage/spider/mysql-test/spider/t/show_system_tables.test @@ -0,0 +1,26 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings + +--echo +--echo Show system tables on the Spider node +--connection master_1 +--sorted_result +SELECT table_name, engine FROM information_schema.tables + WHERE table_schema = 'mysql' AND table_name like '%spider_%'; + +--echo +--echo deinit +--disable_warnings +--disable_query_log +--disable_result_log +--source test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings +--echo +--echo end of test diff --git a/storage/spider/scripts/install_spider.sql b/storage/spider/scripts/install_spider.sql index c5a86caa219..904288f4237 100644 --- a/storage/spider/scripts/install_spider.sql +++ b/storage/spider/scripts/install_spider.sql @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2016 Kentoku Shiba +# Copyright (C) 2010-2018 Kentoku Shiba # # 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 @@ -167,8 +167,8 @@ drop procedure if exists mysql.spider_fix_system_tables; delimiter // create procedure mysql.spider_fix_one_table (tab_name char(255) charset utf8 collate utf8_bin, - test_col_name char(255) charset utf8 collate utf8_bin, - _sql text charset utf8 collate utf8_bin) + test_col_name char(255) charset utf8 collate utf8_bin, + _sql text charset utf8 collate utf8_bin) begin set @col_exists := 0; select 1 into @col_exists from INFORMATION_SCHEMA.COLUMNS @@ -184,6 +184,13 @@ end;// create procedure mysql.spider_fix_system_tables() begin + select substring_index(substring_index(version(), '-', 2), '-', -1) + into @server_name; + select substring_index(version(), '.', 1) + into @server_major_version; + select substring_index(substring_index(version(), '.', 2), '.', -1) + into @server_minor_version; + -- Fix for 0.5 call mysql.spider_fix_one_table('spider_tables', 'server', 'alter table mysql.spider_tables @@ -400,6 +407,81 @@ begin alter table mysql.spider_table_crd modify table_name char(199) not null default ''; end if; + + -- Fix for MariaDB 10.4: Crash-Safe system tables + if @server_name = 'MariaDB' and + ( + @server_major_version > 10 or + ( + @server_major_version = 10 and + @server_minor_version >= 4 + ) + ) + then + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_link_failed_log'; + if @engine_name != 'Aria' then + alter table mysql.spider_link_failed_log + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_link_mon_servers'; + if @engine_name != 'Aria' then + alter table mysql.spider_link_mon_servers + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_table_crd'; + if @engine_name != 'Aria' then + alter table mysql.spider_table_crd + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_table_position_for_recovery'; + if @engine_name != 'Aria' then + alter table mysql.spider_table_position_for_recovery + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_table_sts'; + if @engine_name != 'Aria' then + alter table mysql.spider_table_sts + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_tables'; + if @engine_name != 'Aria' then + alter table mysql.spider_tables + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_xa'; + if @engine_name != 'Aria' then + alter table mysql.spider_xa + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_xa_failed_log'; + if @engine_name != 'Aria' then + alter table mysql.spider_xa_failed_log + engine=Aria transactional=1; + end if; + select ENGINE INTO @engine_name from INFORMATION_SCHEMA.TABLES + where TABLE_SCHEMA = 'mysql' + AND TABLE_NAME = 'spider_xa_member'; + if @engine_name != 'Aria' then + alter table mysql.spider_xa_member + engine=Aria transactional=1; + end if; + end if; end;// delimiter ; call mysql.spider_fix_system_tables; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 148ad43d337..d48ec1f2285 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -1439,9 +1439,10 @@ void spider_conn_queue_time_zone( DBUG_VOID_RETURN; } -void spider_conn_queue_UTC_time_zone(SPIDER_CONN *conn) -{ - DBUG_ENTER("spider_conn_queue_time_zone"); +void spider_conn_queue_UTC_time_zone( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_conn_queue_UTC_time_zone"); DBUG_PRINT("info", ("spider conn=%p", conn)); spider_conn_queue_time_zone(conn, UTC); DBUG_VOID_RETURN; diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index 998658c5353..0a9f99a1853 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -13,8 +13,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "tztime.h" - #define SPIDER_LOCK_MODE_NO_LOCK 0 #define SPIDER_LOCK_MODE_SHARED 1 #define SPIDER_LOCK_MODE_EXCLUSIVE 2 diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 82c0c490147..8dd9d968b99 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2017 Kentoku Shiba +/* Copyright (C) 2009-2018 Kentoku Shiba 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 @@ -53,10 +53,10 @@ int spider_udf_set_copy_tables_param_default( if (!copy_tables->database) { DBUG_PRINT("info",("spider create default database")); - copy_tables->database_length = copy_tables->trx->thd->db.length; + copy_tables->database_length = SPIDER_THD_db_length(copy_tables->trx->thd); if ( !(copy_tables->database = spider_create_string( - copy_tables->trx->thd->db.str, + SPIDER_THD_db_str(copy_tables->trx->thd), copy_tables->database_length)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); @@ -90,8 +90,7 @@ int spider_udf_set_copy_tables_param_default( start_ptr, TRUE, ¶m_string_parse))) \ copy_tables->SPIDER_PARAM_STR_LEN(param_name) = \ strlen(copy_tables->param_name); \ - else \ - { \ + else { \ error_num = param_string_parse.print_param_error(); \ goto error; \ } \ @@ -968,19 +967,25 @@ long long spider_copy_tables_body( goto error; table_list = ©_tables->spider_table_list; - table_list->db.str = copy_tables->spider_db_name; - table_list->db.length = copy_tables->spider_db_name_length; - table_list->alias.str = table_list->table_name.str = + SPIDER_TABLE_LIST_db_str(table_list) = copy_tables->spider_db_name; + SPIDER_TABLE_LIST_db_length(table_list) = copy_tables->spider_db_name_length; + SPIDER_TABLE_LIST_alias_str(table_list) = + SPIDER_TABLE_LIST_table_name_str(table_list) = copy_tables->spider_real_table_name; - table_list->table_name.length = copy_tables->spider_real_table_name_length; - table_list->alias.length= table_list->table_name.length; + SPIDER_TABLE_LIST_table_name_length(table_list) = + copy_tables->spider_real_table_name_length; +#ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias + SPIDER_TABLE_LIST_alias_length(table_list) = + SPIDER_TABLE_LIST_table_name_length(table_list); +#endif table_list->lock_type = TL_READ; - DBUG_PRINT("info",("spider db=%s", table_list->db.str)); - DBUG_PRINT("info",("spider db_length=%zd", table_list->db.length)); - DBUG_PRINT("info",("spider table_name=%s", table_list->table_name.str)); + DBUG_PRINT("info",("spider db=%s", SPIDER_TABLE_LIST_db_str(table_list))); + DBUG_PRINT("info",("spider db_length=%zd", SPIDER_TABLE_LIST_db_length(table_list))); + DBUG_PRINT("info",("spider table_name=%s", + SPIDER_TABLE_LIST_table_name_str(table_list))); DBUG_PRINT("info",("spider table_name_length=%zd", - table_list->table_name.length)); + SPIDER_TABLE_LIST_table_name_length(table_list))); reprepare_observer_backup = thd->m_reprepare_observer; thd->m_reprepare_observer = NULL; copy_tables->trx->trx_start = TRUE; @@ -991,8 +996,8 @@ long long spider_copy_tables_body( #else table_list->mdl_request.init( MDL_key::TABLE, - table_list->db.str, - table_list->table_name.str, + SPIDER_TABLE_LIST_db_str(table_list), + SPIDER_TABLE_LIST_table_name_str(table_list), MDL_SHARED_READ, MDL_TRANSACTION ); @@ -1004,8 +1009,9 @@ long long spider_copy_tables_body( copy_tables->trx->updated_in_this_trx = FALSE; DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE")); my_printf_error(ER_SPIDER_UDF_CANT_OPEN_TABLE_NUM, - ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), table_list->db, - table_list->table_name); + ER_SPIDER_UDF_CANT_OPEN_TABLE_STR, MYF(0), + SPIDER_TABLE_LIST_db_str(table_list), + SPIDER_TABLE_LIST_table_name_str(table_list)); goto error; } thd->m_reprepare_observer = reprepare_observer_backup; @@ -1019,7 +1025,8 @@ long long spider_copy_tables_body( { my_printf_error(ER_SPIDER_UDF_COPY_TABLE_NEED_PK_NUM, ER_SPIDER_UDF_COPY_TABLE_NEED_PK_STR, MYF(0), - table_list->db, table_list->table_name); + SPIDER_TABLE_LIST_db_str(table_list), + SPIDER_TABLE_LIST_table_name_str(table_list)); goto error; } key_info = &table->key_info[table_share->primary_key]; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index ac5701a8274..1e117b68728 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -77,7 +77,7 @@ pthread_mutex_t spider_open_conn_mutex; const char spider_dig_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* UTC time zone for timestamp columns */ -extern Time_zone *UTC; +Time_zone *UTC = 0; int spider_db_connect( const SPIDER_SHARE *share, @@ -1387,12 +1387,34 @@ int spider_db_unlock_tables( int spider_db_append_name_with_quote_str( spider_string *str, - char *name, + const char *name, uint dbton_id ) { - int error_num, length = strlen(name); - char *name_end, head_code; DBUG_ENTER("spider_db_append_name_with_quote_str"); + DBUG_RETURN(spider_db_append_name_with_quote_str_internal( + str, name, strlen(name), dbton_id)); +} + +int spider_db_append_name_with_quote_str( + spider_string *str, + LEX_CSTRING &name, + uint dbton_id +) { + DBUG_ENTER("spider_db_append_name_with_quote_str"); + DBUG_RETURN(spider_db_append_name_with_quote_str_internal( + str, name.str, name.length, dbton_id)); +} + +int spider_db_append_name_with_quote_str_internal( + spider_string *str, + const char *name, + int length, + uint dbton_id +) { + int error_num; + const char *name_end; + char head_code; + DBUG_ENTER("spider_db_append_name_with_quote_str_internal"); for (name_end = name + length; name < name_end; name += length) { head_code = *name; @@ -1695,8 +1717,13 @@ int spider_db_append_key_where_internal( if (sql_kind == SPIDER_SQL_KIND_HANDLER) { +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name const char *key_name = key_info->name.str; - key_name_length = key_info->name.length; + key_name_length = key_info->name.length; +#else + const char *key_name = key_info->name; + key_name_length = strlen(key_name); +#endif if (str->reserve(SPIDER_SQL_READ_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + key_name_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -2876,7 +2903,7 @@ int spider_db_fetch_row( THD *thd = field->table->in_use; Time_zone *saved_time_zone = thd->variables.time_zone; DBUG_ENTER("spider_db_fetch_row"); - DBUG_PRINT("info", ("spider field_name %s", field->field_name.str)); + DBUG_PRINT("info", ("spider field_name %s", SPIDER_field_name_str(field))); DBUG_PRINT("info", ("spider fieldcharset %s", field->charset()->csname)); thd->variables.time_zone = UTC; @@ -3013,7 +3040,7 @@ int spider_db_fetch_table( dbug_tmp_use_all_columns(table, table->write_set); #endif DBUG_PRINT("info", ("spider bitmap is set %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) DBUG_RETURN(error_num); @@ -3184,7 +3211,8 @@ int spider_db_fetch_key( my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, table->write_set); #endif - DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name.str)); + DBUG_PRINT("info", ("spider bitmap is set %s", + SPIDER_field_name_str(field))); if ((error_num = spider_db_fetch_row(share, field, row, ptr_diff))) DBUG_RETURN(error_num); @@ -3303,7 +3331,7 @@ int spider_db_fetch_minimum_columns( dbug_tmp_use_all_columns(table, table->write_set); #endif DBUG_PRINT("info", ("spider bitmap is set %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) DBUG_RETURN(error_num); #ifndef DBUG_OFF @@ -4011,9 +4039,18 @@ int spider_db_store_result( DBUG_PRINT("info",("spider store result to temporary table")); DBUG_ASSERT(!current->result_tmp_tbl); +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor + LEX_CSTRING field_name1 = {STRING_WITH_LEN("a")}; + LEX_CSTRING field_name2 = {STRING_WITH_LEN("b")}; + LEX_CSTRING field_name3 = {STRING_WITH_LEN("c")}; + if (!(current->result_tmp_tbl = spider_mk_sys_tmp_table_for_result( + thd, table, ¤t->result_tmp_tbl_prm, &field_name1, &field_name2, + &field_name3, &my_charset_bin))) +#else if (!(current->result_tmp_tbl = spider_mk_sys_tmp_table_for_result( thd, table, ¤t->result_tmp_tbl_prm, "a", "b", "c", &my_charset_bin))) +#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -5324,7 +5361,7 @@ int spider_db_seek_tmp_table( dbug_tmp_use_all_columns(table, table->write_set); #endif DBUG_PRINT("info", ("spider bitmap is set %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); if ((error_num = spider_db_fetch_row(spider->share, *field, row, ptr_diff))) DBUG_RETURN(error_num); @@ -5411,7 +5448,8 @@ int spider_db_seek_tmp_key( my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, table->write_set); #endif - DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name.str)); + DBUG_PRINT("info", ("spider bitmap is set %s", + SPIDER_field_name_str(field))); if ((error_num = spider_db_fetch_row(spider->share, field, row, ptr_diff))) DBUG_RETURN(error_num); @@ -5502,7 +5540,7 @@ int spider_db_seek_tmp_minimum_columns( dbug_tmp_use_all_columns(table, table->write_set); #endif DBUG_PRINT("info", ("spider bitmap is set %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); if ((error_num = spider_db_fetch_row(spider->share, *field, row, ptr_diff))) DBUG_RETURN(error_num); @@ -5514,7 +5552,7 @@ int spider_db_seek_tmp_minimum_columns( else if (bitmap_is_set(table->read_set, (*field)->field_index)) { DBUG_PRINT("info", ("spider bitmap is cleared %s", - (*field)->field_name.str)); + SPIDER_field_name_str(*field))); bitmap_clear_bit(table->read_set, (*field)->field_index); } } @@ -8478,11 +8516,14 @@ int spider_db_flush_logs( contains only one field; NULL otherwise. */ -Field *spider_db_find_field_in_item_list(Item **item_list, uint item_count, - uint start_item, spider_string *str, - const char *func_name, - int func_name_length) -{ +Field *spider_db_find_field_in_item_list( + Item **item_list, + uint item_count, + uint start_item, + spider_string *str, + const char *func_name, + int func_name_length +) { uint item_num; Item *item; Field *field = NULL; @@ -8530,11 +8571,17 @@ Field *spider_db_find_field_in_item_list(Item **item_list, uint item_count, @return Error code. */ -int spider_db_print_item_type(Item *item, Field *field, ha_spider *spider, - spider_string *str, const char *alias, - uint alias_length, uint dbton_id, - bool use_fields, spider_fields *fields) -{ +int spider_db_print_item_type( + Item *item, + Field *field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id, + bool use_fields, + spider_fields *fields +) { DBUG_ENTER("spider_db_print_item_type"); DBUG_PRINT("info",("spider COND type=%d", item->type())); @@ -8560,26 +8607,40 @@ int spider_db_print_item_type(Item *item, Field *field, ha_spider *spider, case Item::ROW_ITEM: DBUG_RETURN(spider_db_open_item_row((Item_row *) item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); +#ifdef SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM + case Item::CONST_ITEM: + { + switch (item->cmp_type()) { + case TIME_RESULT: + case STRING_RESULT: + DBUG_RETURN(spider_db_open_item_string(item, field, spider, str, + alias, alias_length, dbton_id, use_fields, fields)); + case INT_RESULT: + case REAL_RESULT: + case DECIMAL_RESULT: + DBUG_RETURN(spider_db_open_item_int(item, field, spider, str, + alias, alias_length, dbton_id, use_fields, fields)); + default: + DBUG_ASSERT(FALSE); + DBUG_RETURN(spider_db_print_item_type_default(item, spider, str)); + } + } +#else case Item::STRING_ITEM: DBUG_RETURN(spider_db_open_item_string(item, field, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); case Item::INT_ITEM: case Item::REAL_ITEM: case Item::DECIMAL_ITEM: DBUG_RETURN(spider_db_open_item_int(item, field, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); +#endif case Item::CACHE_ITEM: - DBUG_RETURN(spider_db_open_item_cache((Item_cache *) item, field, - spider, str, alias, alias_length, - dbton_id, use_fields, fields)); + DBUG_RETURN(spider_db_open_item_cache((Item_cache *) item, field, spider, + str, alias, alias_length, dbton_id, use_fields, fields)); case Item::INSERT_VALUE_ITEM: DBUG_RETURN(spider_db_open_item_insert_value((Item_insert_value *) item, - field, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields)); + field, spider, str, alias, alias_length, dbton_id, use_fields, fields)); case Item::SUBSELECT_ITEM: case Item::TRIGGER_FIELD_ITEM: #ifdef SPIDER_HAS_EXPR_CACHE_ITEM @@ -8587,31 +8648,40 @@ int spider_db_print_item_type(Item *item, Field *field, ha_spider *spider, #endif DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); default: - THD *thd = spider->trx->thd; - SPIDER_SHARE *share = spider->share; - if (spider_param_skip_default_condition(thd, - share->skip_default_condition)) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - if (str) - { - if (spider->share->access_charset->cset == system_charset_info->cset) - { -#if MYSQL_VERSION_ID < 50500 - item->print(str->get_str(), QT_IS); -#else - item->print(str->get_str(), QT_TO_SYSTEM_CHARSET); -#endif - } else { - item->print(str->get_str(), QT_ORDINARY); - } - str->mem_calc(); - } - break; + DBUG_RETURN(spider_db_print_item_type_default(item, spider, str)); } DBUG_RETURN(0); } +int spider_db_print_item_type_default( + Item *item, + ha_spider *spider, + spider_string *str +) { + DBUG_ENTER("spider_db_print_item_type_default"); + THD *thd = spider->trx->thd; + SPIDER_SHARE *share = spider->share; + if (spider_param_skip_default_condition(thd, + share->skip_default_condition)) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + if (str) + { + if (spider->share->access_charset->cset == system_charset_info->cset) + { +#if MYSQL_VERSION_ID < 50500 + item->print(str->get_str(), QT_IS); +#else + item->print(str->get_str(), QT_TO_SYSTEM_CHARSET); +#endif + } else { + item->print(str->get_str(), QT_ORDINARY); + } + str->mem_calc(); + } + DBUG_RETURN(0); +} + int spider_db_open_item_cond( Item_cond *item_cond, ha_spider *spider, @@ -8641,8 +8711,7 @@ restart_first: if (str) restart_pos = str->length(); if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) { if ( str && @@ -8676,8 +8745,7 @@ restart_first: } if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) { if ( str && @@ -8786,7 +8854,15 @@ int spider_db_open_item_ident( } if (str) { - field_name_length = item_ident->field_name.length; +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name + if (item_ident->field_name.str) + field_name_length = item_ident->field_name.length; +#else + if (item_ident->field_name) + field_name_length = strlen(item_ident->field_name); +#endif + else + field_name_length = 0; if (share->access_charset->cset == system_charset_info->cset) { if (str->reserve(alias_length + @@ -8795,8 +8871,13 @@ int spider_db_open_item_ident( DBUG_RETURN(HA_ERR_OUT_OF_MEM); } str->q_append(alias, alias_length); +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_name(str, item_ident->field_name.str, field_name_length))) +#else + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name(str, item_ident->field_name, field_name_length))) +#endif { DBUG_RETURN(error_num); } @@ -8804,9 +8885,15 @@ int spider_db_open_item_ident( if (str->reserve(alias_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_name_with_charset(str, item_ident->field_name.str, field_name_length, system_charset_info))) +#else + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name_with_charset(str, item_ident->field_name, + field_name_length, system_charset_info))) +#endif { DBUG_RETURN(error_num); } @@ -8891,31 +8978,50 @@ int spider_db_open_item_ref( DBUG_ENTER("spider_db_open_item_ref"); if (item_ref->ref) { +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ( (*(item_ref->ref))->type() != Item::CACHE_ITEM && item_ref->ref_type() != Item_ref::VIEW_REF && !item_ref->table_name && item_ref->name.str && item_ref->alias_name_used - ) { + ) +#else + if ( + (*(item_ref->ref))->type() != Item::CACHE_ITEM && + item_ref->ref_type() != Item_ref::VIEW_REF && + !item_ref->table_name && + item_ref->name && + item_ref->alias_name_used + ) +#endif + { if (str) { +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name uint length = item_ref->name.length; +#else + uint length = strlen(item_ref->name); +#endif if (str->reserve(length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_name(str, item_ref->name.str, length))) +#else + if ((error_num = spider_dbton[dbton_id].db_util-> + append_name(str, item_ref->name, length))) +#endif { DBUG_RETURN(error_num); } } DBUG_RETURN(0); } - DBUG_RETURN(spider_db_print_item_type(*(item_ref->ref), NULL, spider, - str, alias, alias_length, dbton_id, - use_fields, fields)); + DBUG_RETURN(spider_db_print_item_type(*(item_ref->ref), NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields)); } DBUG_RETURN(spider_db_open_item_ident((Item_ident *) item_ref, spider, str, alias, alias_length, dbton_id, use_fields, fields)); @@ -8945,8 +9051,7 @@ int spider_db_open_item_row( { item = item_row->element_index(roop_count); if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -8957,8 +9062,7 @@ int spider_db_open_item_row( } item = item_row->element_index(roop_count); if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -8987,12 +9091,17 @@ int spider_db_open_item_row( @return Error code. */ -int spider_db_open_item_string(Item *item, Field *field, ha_spider *spider, - spider_string *str, - const char *alias, uint alias_length, - uint dbton_id, - bool use_fields, spider_fields *fields) -{ +int spider_db_open_item_string( + Item *item, + Field *field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id, + bool use_fields, + spider_fields *fields +) { int error_num = 0; DBUG_ENTER("spider_db_open_item_string"); @@ -9002,10 +9111,10 @@ int spider_db_open_item_string(Item *item, Field *field, ha_spider *spider, TABLE *table; my_bitmap_map *saved_map; Time_zone *saved_time_zone; + String str_value; char tmp_buf[MAX_FIELD_WIDTH]; spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); String *tmp_str2; - String str_value; tmp_str.init_calc_mem(126); if (!(tmp_str2 = item->val_str(tmp_str.get_str()))) @@ -9013,16 +9122,17 @@ int spider_db_open_item_string(Item *item, Field *field, ha_spider *spider, if (str->reserve(SPIDER_SQL_NULL_LEN)) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); - } - else - { - if (field && field->type() == FIELD_TYPE_TIMESTAMP) - { + } else { + if ( + field && + field->type() == FIELD_TYPE_TIMESTAMP && + field->table->in_use->variables.time_zone != UTC + ) { /* - Store the string value in the field. This is necessary + Store the string value in the field. This is necessary when the statement contains more than one value for the same field. */ @@ -9039,15 +9149,14 @@ int spider_db_open_item_string(Item *item, Field *field, ha_spider *spider, if (!tmp_str2) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } } - if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + - tmp_str2->length() * 2)) + tmp_str2->length() * 2)) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } if (!thd) tmp_str.mem_calc(); @@ -9056,12 +9165,12 @@ int spider_db_open_item_string(Item *item, Field *field, ha_spider *spider, if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); } -error: +end: if (thd) { thd->variables.time_zone = saved_time_zone; @@ -9089,12 +9198,17 @@ error: @return Error code. */ -int spider_db_open_item_int(Item *item, Field *field, ha_spider *spider, - spider_string *str, - const char *alias, uint alias_length, - uint dbton_id, - bool use_fields, spider_fields *fields) -{ +int spider_db_open_item_int( + Item *item, + Field *field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id, + bool use_fields, + spider_fields *fields +) { int error_num = 0; DBUG_ENTER("spider_db_open_item_int"); @@ -9102,24 +9216,27 @@ int spider_db_open_item_int(Item *item, Field *field, ha_spider *spider, { THD *thd = NULL; TABLE *table; - bool print_quoted_string; my_bitmap_map *saved_map; Time_zone *saved_time_zone; + String str_value; + bool print_quoted_string; char tmp_buf[MAX_FIELD_WIDTH]; spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - String str_value; String *tmp_str2; tmp_str.init_calc_mem(127); if (!(tmp_str2 = item->val_str(tmp_str.get_str()))) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } tmp_str.mem_calc(); - if (field && field->type() == FIELD_TYPE_TIMESTAMP) - { + if ( + field && + field->type() == FIELD_TYPE_TIMESTAMP && + field->table->in_use->variables.time_zone != UTC + ) { /* Store the int value in the field. This is necessary when the statement contains more than one value for the @@ -9132,11 +9249,9 @@ int spider_db_open_item_int(Item *item, Field *field, ha_spider *spider, saved_time_zone = thd->variables.time_zone; thd->variables.time_zone = UTC; print_quoted_string = TRUE; - } - else - { + } else { #ifdef SPIDER_ITEM_HAS_CMP_TYPE - DBUG_PRINT("info", ("spider cmp_type=%u", item->cmp_type())); + DBUG_PRINT("info",("spider cmp_type=%u", item->cmp_type())); if (item->cmp_type() == TIME_RESULT) print_quoted_string = TRUE; else @@ -9154,23 +9269,24 @@ int spider_db_open_item_int(Item *item, Field *field, ha_spider *spider, if (!tmp_str2) { error_num = HA_ERR_OUT_OF_MEM; - goto error; + goto end; } } if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + tmp_str2->length())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + { + error_num = HA_ERR_OUT_OF_MEM; + goto end; + } str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); str->append(*tmp_str2); str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); - } - else - { + } else { if (str->append(*tmp_str2)) error_num = HA_ERR_OUT_OF_MEM; } -error: +end: if (thd) { thd->variables.time_zone = saved_time_zone; @@ -9198,12 +9314,17 @@ error: @return Error code. */ -int spider_db_open_item_cache(Item_cache *item_cache, Field *field, - ha_spider *spider, spider_string *str, - const char *alias, uint alias_length, - uint dbton_id, - bool use_fields, spider_fields *fields) -{ +int spider_db_open_item_cache( + Item_cache *item_cache, + Field *field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id, + bool use_fields, + spider_fields *fields +) { DBUG_ENTER("spider_db_open_item_cache"); if (!item_cache->const_item()) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); @@ -9213,8 +9334,7 @@ int spider_db_open_item_cache(Item_cache *item_cache, Field *field, { case STRING_RESULT: DBUG_RETURN(spider_db_open_item_string(item_cache, field, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); case ROW_RESULT: { int error_num; @@ -9229,11 +9349,9 @@ int spider_db_open_item_cache(Item_cache *item_cache, Field *field, for (roop_count = 0; roop_count < item_count; ++roop_count) { if ((error_num = spider_db_open_item_cache( - (Item_cache *) - item_cache_row->element_index(roop_count), - NULL, spider, str, alias, alias_length, - dbton_id, use_fields, fields))) - { + (Item_cache *) item_cache_row->element_index(roop_count), NULL, + spider, str, alias, alias_length, dbton_id, use_fields, fields + ))) { DBUG_RETURN(error_num); } if (str) @@ -9244,11 +9362,9 @@ int spider_db_open_item_cache(Item_cache *item_cache, Field *field, } } if ((error_num = spider_db_open_item_cache( - (Item_cache *) - item_cache_row->element_index(roop_count), - NULL, spider, str, alias, alias_length, - dbton_id, use_fields, fields))) - { + (Item_cache *) item_cache_row->element_index(roop_count), NULL, + spider, str, alias, alias_length, dbton_id, use_fields, fields + ))) { DBUG_RETURN(error_num); } if (str) @@ -9266,10 +9382,8 @@ int spider_db_open_item_cache(Item_cache *item_cache, Field *field, default: break; } - DBUG_RETURN(spider_db_open_item_int(item_cache, field, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); } /** @@ -9288,13 +9402,17 @@ int spider_db_open_item_cache(Item_cache *item_cache, Field *field, @return Error code. */ -int spider_db_open_item_insert_value(Item_insert_value *item_insert_value, - Field *field, ha_spider *spider, - spider_string *str, - const char *alias, uint alias_length, - uint dbton_id, - bool use_fields, spider_fields *fields) -{ +int spider_db_open_item_insert_value( + Item_insert_value *item_insert_value, + Field *field, + ha_spider *spider, + spider_string *str, + const char *alias, + uint alias_length, + uint dbton_id, + bool use_fields, + spider_fields *fields +) { int error_num; DBUG_ENTER("spider_db_open_item_insert_value"); @@ -9308,9 +9426,7 @@ int spider_db_open_item_insert_value(Item_insert_value *item_insert_value, str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); } if ((error_num = spider_db_print_item_type(item_insert_value->arg, field, - spider, str, alias, - alias_length, dbton_id, - use_fields, fields))) + spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -9375,10 +9491,9 @@ int spider_db_append_update_columns( while ((field = fi++)) { value = vi++; - if ((error_num = spider_db_print_item_type((Item *) field, NULL, spider, - str, alias, alias_length, - dbton_id, - use_fields, fields))) + if ((error_num = spider_db_print_item_type( + (Item *) field, NULL, spider, str, alias, alias_length, dbton_id, + use_fields, fields))) { if ( error_num == ER_SPIDER_COND_SKIP_NUM && @@ -9396,12 +9511,9 @@ int spider_db_append_update_columns( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); } - if ((error_num = spider_db_print_item_type((Item *) value, - ((Item_field *) field)->field, - spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + if ((error_num = spider_db_print_item_type( + (Item *) value, ((Item_field *) field)->field, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -10599,8 +10711,13 @@ int spider_db_udf_copy_key_row( ) { int error_num; DBUG_ENTER("spider_db_udf_copy_key_row"); +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_db_append_name_with_quote_str(str, (char *) field->field_name.str, dbton_id))) +#else + if ((error_num = spider_db_append_name_with_quote_str(str, + (char *) field->field_name, dbton_id))) +#endif DBUG_RETURN(error_num); if (str->reserve(joint_length + *length + SPIDER_SQL_AND_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index 879ab3540c1..6ff35b794cd 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -412,7 +412,20 @@ int spider_db_unlock_tables( int spider_db_append_name_with_quote_str( spider_string *str, - char *name, + const char *name, + uint dbton_id +); + +int spider_db_append_name_with_quote_str( + spider_string *str, + LEX_CSTRING &name, + uint dbton_id +); + +int spider_db_append_name_with_quote_str_internal( + spider_string *str, + const char *name, + int length, uint dbton_id ); @@ -859,6 +872,12 @@ int spider_db_print_item_type( spider_fields *fields ); +int spider_db_print_item_type_default( + Item *item, + ha_spider *spider, + spider_string *str +); + int spider_db_open_item_cond( Item_cond *item_cond, ha_spider *spider, diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc index dc4b9dd25ec..412450b96f8 100644 --- a/storage/spider/spd_db_handlersocket.cc +++ b/storage/spider/spd_db_handlersocket.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -2755,10 +2755,10 @@ int spider_db_handlersocket_util::open_item_func( Item *item, **item_list = item_func->arguments(); uint roop_count, item_count = item_func->argument_count(), start_item = 0; const char *func_name = SPIDER_SQL_NULL_CHAR_STR, - *separete_str = SPIDER_SQL_NULL_CHAR_STR, + *separator_str = SPIDER_SQL_NULL_CHAR_STR, *last_str = SPIDER_SQL_NULL_CHAR_STR; int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, - separete_str_length = SPIDER_SQL_NULL_CHAR_LEN, + separator_str_length = SPIDER_SQL_NULL_CHAR_LEN, last_str_length = SPIDER_SQL_NULL_CHAR_LEN; int use_pushdown_udf; bool merge_func = FALSE; @@ -2824,7 +2824,7 @@ int spider_db_handlersocket_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("case", func_name, func_name_length) @@ -2840,7 +2840,7 @@ int spider_db_handlersocket_util::open_item_func( if (item_func_case->first_expr_num != -1) { if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], spider, str, + item_list[item_func_case->first_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -2854,7 +2854,7 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count], spider, str, + item_list[roop_count], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -2864,7 +2864,7 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count + 1], spider, str, + item_list[roop_count + 1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -2877,7 +2877,7 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); } if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], spider, str, + item_list[item_func_case->else_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -2914,7 +2914,7 @@ int spider_db_handlersocket_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("convert", func_name, func_name_length) @@ -2939,7 +2939,7 @@ int spider_db_handlersocket_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if (func_name_length == 9 && !strncasecmp("isnottrue", func_name, func_name_length) @@ -2966,8 +2966,8 @@ int spider_db_handlersocket_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; break; } } else if (func_name_length == 12) @@ -3055,7 +3055,7 @@ int spider_db_handlersocket_util::open_item_func( { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { @@ -3118,7 +3118,7 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(interval_str, interval_len); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[0], spider, + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3127,7 +3127,7 @@ int spider_db_handlersocket_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[1], spider, + if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3381,8 +3381,8 @@ int spider_db_handlersocket_util::open_item_func( func_name = spider_db_timefunc_interval_str[ item_date_add_interval->int_type]; func_name_length = strlen(func_name); - if ((error_num = spider_db_print_item_type(item_list[0], spider, str, - alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -3398,8 +3398,8 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); } } - if ((error_num = spider_db_print_item_type(item_list[1], spider, str, - alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -3421,15 +3421,15 @@ int spider_db_handlersocket_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; case Item_func::NOW_FUNC: if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); case Item_func::CHAR_TYPECAST_FUNC: DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC")); @@ -3555,15 +3555,15 @@ int spider_db_handlersocket_util::open_item_func( { func_name = SPIDER_SQL_NOT_IN_STR; func_name_length = SPIDER_SQL_NOT_IN_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; } else { func_name = SPIDER_SQL_IN_STR; func_name_length = SPIDER_SQL_IN_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; } @@ -3573,13 +3573,13 @@ int spider_db_handlersocket_util::open_item_func( { func_name = SPIDER_SQL_NOT_BETWEEN_STR; func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; - separete_str = SPIDER_SQL_AND_STR; - separete_str_length = SPIDER_SQL_AND_LEN; + separator_str = SPIDER_SQL_AND_STR; + separator_str_length = SPIDER_SQL_AND_LEN; } else { func_name = (char*) item_func->func_name(); func_name_length = strlen(func_name); - separete_str = SPIDER_SQL_AND_STR; - separete_str_length = SPIDER_SQL_AND_LEN; + separator_str = SPIDER_SQL_AND_STR; + separator_str_length = SPIDER_SQL_AND_LEN; } break; case Item_func::UDF_FUNC: @@ -3600,8 +3600,8 @@ int spider_db_handlersocket_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3621,10 +3621,10 @@ int spider_db_handlersocket_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); if (item_func->result_type() == STRING_RESULT) - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); else - DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); case Item_func::FT_FUNC: if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) @@ -3636,8 +3636,8 @@ int spider_db_handlersocket_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); } - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3654,8 +3654,8 @@ int spider_db_handlersocket_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3686,8 +3686,8 @@ int spider_db_handlersocket_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3720,8 +3720,8 @@ int spider_db_handlersocket_util::open_item_func( } DBUG_PRINT("info",("spider func_name = %s", func_name)); DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - DBUG_PRINT("info",("spider separete_str = %s", separete_str)); - DBUG_PRINT("info",("spider separete_str_length = %d", separete_str_length)); + DBUG_PRINT("info",("spider separator_str = %s", separator_str)); + DBUG_PRINT("info",("spider separator_str_length = %d", separator_str_length)); DBUG_PRINT("info",("spider last_str = %s", last_str)); DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); if (item_count) @@ -3730,13 +3730,13 @@ int spider_db_handlersocket_util::open_item_func( for (roop_count = start_item; roop_count < item_count; roop_count++) { item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (roop_count == 1) { - func_name = separete_str; - func_name_length = separete_str_length; + func_name = separator_str; + func_name_length = separator_str_length; } if (str) { @@ -3748,7 +3748,7 @@ int spider_db_handlersocket_util::open_item_func( } } item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3762,7 +3762,7 @@ int spider_db_handlersocket_util::open_item_func( str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); } item = item_list[0]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3850,7 +3850,7 @@ int spider_db_handlersocket_util::open_item_sum_func( for (roop_count = 0; roop_count < item_count; roop_count++) { item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3861,7 +3861,7 @@ int spider_db_handlersocket_util::open_item_sum_func( } } item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3902,8 +3902,11 @@ int spider_db_handlersocket_util::append_escaped_util( #ifdef SPIDER_HAS_GROUP_BY_HANDLER int spider_db_handlersocket_util::append_from_and_tables( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + uint table_count ) { DBUG_ENTER("spider_db_handlersocket_util::append_from_and_tables"); DBUG_PRINT("info",("spider this=%p", this)); @@ -4209,7 +4212,7 @@ int spider_handlersocket_share::create_column_name_str() str->init_calc_mem(202); str->set_charset(spider_share->access_charset); if ((error_num = spider_db_append_name_with_quote_str(str, - (char *) (*field)->field_name.str, dbton_id))) + (*field)->field_name, dbton_id))) goto error; } DBUG_RETURN(0); diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h index 19138b22e1a..3767f0f3fac 100644 --- a/storage/spider/spd_db_handlersocket.h +++ b/storage/spider/spd_db_handlersocket.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -119,8 +119,11 @@ public: ); #ifdef SPIDER_HAS_GROUP_BY_HANDLER int append_from_and_tables( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + uint table_count ); int reappend_tables( spider_fields *fields, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index d19306b1b1a..7f1148655e3 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -17,7 +17,6 @@ #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #include "hstcpcli.hpp" #endif -#include "tztime.h" #define SPIDER_DBTON_SIZE 15 @@ -703,6 +702,8 @@ public: ); void set_pos_to_first_table_holder(); SPIDER_TABLE_HOLDER *get_next_table_holder(); + SPIDER_TABLE_HOLDER *get_table_holder(TABLE *table); + uint get_table_count(); int add_field(Field *field_arg); SPIDER_FIELD_HOLDER *create_field_holder(); void set_pos_to_first_field_holder(); @@ -888,8 +889,11 @@ public: ) = 0; #ifdef SPIDER_HAS_GROUP_BY_HANDLER virtual int append_from_and_tables( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + uint table_count ) = 0; virtual int reappend_tables( spider_fields *fields, diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ada9aa20821..8c17bc8970d 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -109,6 +109,15 @@ static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; #define SPIDER_SQL_UNLOCK_TABLE_STR "unlock tables" #define SPIDER_SQL_UNLOCK_TABLE_LEN (sizeof(SPIDER_SQL_UNLOCK_TABLE_STR) - 1) +#define SPIDER_SQL_LEFT_JOIN_STR " left join " +#define SPIDER_SQL_LEFT_JOIN_LEN (sizeof(SPIDER_SQL_LEFT_JOIN_STR) - 1) +#define SPIDER_SQL_RIGHT_JOIN_STR " right join " +#define SPIDER_SQL_RIGHT_JOIN_LEN (sizeof(SPIDER_SQL_RIGHT_JOIN_STR) - 1) +#define SPIDER_SQL_JOIN_STR " join " +#define SPIDER_SQL_JOIN_LEN (sizeof(SPIDER_SQL_JOIN_STR) - 1) +#define SPIDER_SQL_ON_STR " on " +#define SPIDER_SQL_ON_LEN (sizeof(SPIDER_SQL_ON_STR) - 1) + #define SPIDER_SQL_SHOW_TABLE_STATUS_STR "show table status from " #define SPIDER_SQL_SHOW_TABLE_STATUS_LEN sizeof(SPIDER_SQL_SHOW_TABLE_STATUS_STR) - 1 #define SPIDER_SQL_SELECT_TABLES_STATUS_STR "select `table_rows`,`avg_row_length`,`data_length`,`max_data_length`,`index_length`,`auto_increment`,`create_time`,`update_time`,`check_time` from `information_schema`.`tables` where `table_schema` = " @@ -180,7 +189,7 @@ static const char *spider_db_timefunc_interval_str[] = }; /* UTC time zone for timestamp columns */ -Time_zone *UTC = 0; +extern Time_zone *UTC; int spider_mysql_init() { @@ -713,8 +722,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[11], strlen(mysql_row[11]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[11], strlen(mysql_row[11]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -738,8 +747,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[12], strlen(mysql_row[12]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[12], strlen(mysql_row[12]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -763,8 +772,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[13], strlen(mysql_row[13]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[13], strlen(mysql_row[13]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -831,8 +840,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[6], strlen(mysql_row[6]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[6], strlen(mysql_row[6]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -856,8 +865,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[7], strlen(mysql_row[7]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[7], strlen(mysql_row[7]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -881,8 +890,8 @@ int spider_db_mysql_result::fetch_table_status( #ifdef SPIDER_HAS_TIME_STATUS my_time_status_init(&time_status); #endif - str_to_datetime(mysql_row[8], strlen(mysql_row[8]), &mysql_time, 0, - &time_status); + SPIDER_str_to_datetime(mysql_row[8], strlen(mysql_row[8]), + &mysql_time, 0, &time_status); #ifdef MARIADB_BASE_VERSION check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -1524,7 +1533,7 @@ int spider_db_mysql_result::fetch_table_for_discover_table_structure( } DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - if (num_fields() != 18) + if (num_fields() < 18) { DBUG_PRINT("info",("spider num_fields != 18")); my_printf_error(ER_SPIDER_UNKNOWN_NUM, ER_SPIDER_UNKNOWN_STR, MYF(0)); @@ -3092,8 +3101,13 @@ void spider_db_mysql::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { - key_name = table->s->key_info[roop_count].name.str; +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name + key_name = table->s->key_info[roop_count].name.str; key_name_length = table->s->key_info[roop_count].name.length; +#else + key_name = table->s->key_info[roop_count].name; + key_name_length = strlen(key_name); +#endif } DBUG_PRINT("info",("spider key_name=%s", key_name)); if ( @@ -3212,8 +3226,7 @@ int spider_db_mysql_util::append_column_value( tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, &my_charset_bin); ptr = tmp_str.get_str(); - } - else if (field->type() == MYSQL_TYPE_GEOMETRY) + } else if (field->type() == MYSQL_TYPE_GEOMETRY) { /* uint mlength = SIZEOF_STORED_DOUBLE, lcnt; @@ -3290,15 +3303,11 @@ int spider_db_mysql_util::append_column_value( tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, SIZEOF_STORED_DOUBLE); ptr = tmp_str.get_str(); - } - else - { + } else { ptr = field->val_str(tmp_str.get_str(), new_ptr); tmp_str.mem_calc(); } - } - else - { + } else { ptr = field->val_str(tmp_str.get_str()); tmp_str.mem_calc(); } @@ -3350,8 +3359,7 @@ int spider_db_mysql_util::append_column_value( append_escaped_util(str, tmp_str2.get_str()) ) DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - else if (str->append(*ptr)) + } else if (str->append(*ptr)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3621,7 +3629,7 @@ int spider_db_mysql_util::open_item_func( int error_num; Item *item, **item_list = item_func->arguments(); Field *field; - uint loop_count, item_count = item_func->argument_count(), start_item = 0; + uint roop_count, item_count = item_func->argument_count(), start_item = 0; const char *func_name = SPIDER_SQL_NULL_CHAR_STR, *separator_str = SPIDER_SQL_NULL_CHAR_STR, *last_str = SPIDER_SQL_NULL_CHAR_STR; @@ -3693,8 +3701,7 @@ int spider_db_mysql_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("case", func_name, func_name_length) ) { @@ -3709,12 +3716,12 @@ int spider_db_mysql_util::open_item_func( if (item_func_case->first_expr_num != -1) { if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], spider, str, + item_list[item_func_case->first_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } - for (loop_count = 0; loop_count < item_func_case->ncases; - loop_count += 2) + for (roop_count = 0; roop_count < item_func_case->ncases; + roop_count += 2) { if (str) { @@ -3723,7 +3730,7 @@ int spider_db_mysql_util::open_item_func( str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[loop_count], spider, str, + item_list[roop_count], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3733,7 +3740,7 @@ int spider_db_mysql_util::open_item_func( str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[loop_count + 1], spider, str, + item_list[roop_count + 1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3746,7 +3753,7 @@ int spider_db_mysql_util::open_item_func( str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); } if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], spider, str, + item_list[item_func_case->else_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3784,9 +3791,7 @@ int spider_db_mysql_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("convert", func_name, func_name_length) ) { @@ -3811,8 +3816,7 @@ int spider_db_mysql_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); } else if (func_name_length == 9 && !strncasecmp("isnottrue", func_name, func_name_length) ) { @@ -3928,9 +3932,7 @@ int spider_db_mysql_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { #ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC @@ -3992,7 +3994,7 @@ int spider_db_mysql_util::open_item_func( str->q_append(interval_str, interval_len); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[0], spider, + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -4001,7 +4003,7 @@ int spider_db_mysql_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[1], spider, + if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -4255,11 +4257,8 @@ int spider_db_mysql_util::open_item_func( func_name = spider_db_timefunc_interval_str[ item_date_add_interval->int_type]; func_name_length = strlen(func_name); - if ((error_num = spider_db_print_item_type(item_list[0], NULL, - spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -4275,11 +4274,8 @@ int spider_db_mysql_util::open_item_func( str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); } } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, - spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -4309,9 +4305,8 @@ int spider_db_mysql_util::open_item_func( case Item_func::NOW_FUNC: if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields)); case Item_func::CHAR_TYPECAST_FUNC: DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC")); { @@ -4503,12 +4498,10 @@ int spider_db_mysql_util::open_item_func( str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); if (item_func->result_type() == STRING_RESULT) DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); else DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields)); + alias, alias_length, dbton_id, use_fields, fields)); case Item_func::FT_FUNC: if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); @@ -4607,7 +4600,6 @@ int spider_db_mysql_util::open_item_func( DBUG_PRINT("info",("spider separator_str_length = %d", separator_str_length)); DBUG_PRINT("info",("spider last_str = %s", last_str)); DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); - if (item_count) { /* Find the field in the list of items of the expression tree */ @@ -4615,23 +4607,18 @@ int spider_db_mysql_util::open_item_func( item_count, start_item, str, func_name, func_name_length); - item_count--; - /* Loop through the items of the current function expression to print its portion of the statement */ - for (loop_count = start_item; loop_count < item_count; loop_count++) + for (roop_count = start_item; roop_count < item_count; roop_count++) { - item = item_list[loop_count]; + item = item_list[roop_count]; if ((error_num = spider_db_print_item_type(item, field, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); - - if (loop_count == 1) + if (roop_count == 1) { /* Remaining operands need to be preceded by the separator */ func_name = separator_str; @@ -4648,11 +4635,9 @@ int spider_db_mysql_util::open_item_func( } /* Print the last operand value */ - item = item_list[loop_count]; + item = item_list[roop_count]; if ((error_num = spider_db_print_item_type(item, field, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -4667,8 +4652,7 @@ int spider_db_mysql_util::open_item_func( } item = item_list[0]; if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -4755,11 +4739,8 @@ int spider_db_mysql_util::open_item_sum_func( for (roop_count = 0; roop_count < item_count; roop_count++) { item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, - spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) { @@ -4770,9 +4751,7 @@ int spider_db_mysql_util::open_item_sum_func( } item = args[roop_count]; if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, - dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } if (str) @@ -4788,6 +4767,48 @@ int spider_db_mysql_util::open_item_sum_func( case Item_sum::SUM_DISTINCT_FUNC: case Item_sum::AVG_FUNC: case Item_sum::AVG_DISTINCT_FUNC: + { + if (!use_fields) + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); + const char *func_name = item_sum->func_name(); + uint func_name_length = strlen(func_name); + Item *item, **args = item_sum->get_args(); + if (str) + { + if (str->reserve(func_name_length)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(func_name, func_name_length); + } + if (item_count) + { + item_count--; + for (roop_count = 0; roop_count < item_count; roop_count++) + { + item = args[roop_count]; + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + item = args[roop_count]; + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + break; case Item_sum::STD_FUNC: case Item_sum::VARIANCE_FUNC: case Item_sum::SUM_BIT_FUNC: @@ -4813,59 +4834,529 @@ int spider_db_mysql_util::append_escaped_util( } #ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_db_mysql_util::append_from_and_tables( +int spider_db_mysql_util::append_table( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr, + bool top_down, + bool first ) { - SPIDER_TABLE_HOLDER *table_holder; int error_num; - uint dbton_id = spider_dbton_mysql.dbton_id, from_length; + bool use_cond_table_list = FALSE; spider_mysql_share *db_share; spider_mysql_handler *dbton_hdl; - ha_spider *spider; + SPIDER_TABLE_HOLDER *table_holder; + uint dbton_id = spider_dbton_mysql.dbton_id; + TABLE_LIST *cond_table_list = *cond_table_list_ptr; + ha_spider *spd; + DBUG_ENTER("spider_db_mysql_util::append_table"); + DBUG_PRINT("info",("spider table_list=%p", table_list)); + DBUG_PRINT("info",("spider table_list->outer_join=%u", + table_list->outer_join)); + DBUG_PRINT("info",("spider table_list->on_expr=%p", + table_list->on_expr)); + DBUG_PRINT("info",("spider table_list->join_using_fields=%p", + table_list->join_using_fields)); + DBUG_PRINT("info",("spider table_list->table=%p", + table_list->table)); + if (!top_down && table_list->embedding) + { + if ((error_num = append_embedding_tables(spider, fields, str, + table_list->embedding, used_table_list, current_pos, + cond_table_list_ptr))) + DBUG_RETURN(error_num); + } else if (!table_list->table) + { + if ((error_num = append_tables_top_down(spider, fields, str, table_list, + used_table_list, current_pos, cond_table_list_ptr))) + DBUG_RETURN(error_num); + } else { + if ( + table_list->outer_join || + table_list->on_expr || + table_list->join_using_fields + ) { + DBUG_PRINT("info",("spider use table_list")); + if (table_list->outer_join & JOIN_TYPE_LEFT) + { + if (str) + { + if (str->reserve(SPIDER_SQL_LEFT_JOIN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_LEFT_JOIN_STR, SPIDER_SQL_LEFT_JOIN_LEN); + } + } else { + if (str) + { + if (str->reserve(SPIDER_SQL_JOIN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); + } + } + } else if ( + cond_table_list && + ( + cond_table_list->outer_join || + cond_table_list->on_expr || + cond_table_list->join_using_fields + ) + ) { + DBUG_PRINT("info",("spider use cond_table_list")); + if (cond_table_list->outer_join & (JOIN_TYPE_LEFT | JOIN_TYPE_RIGHT)) + { + if (str) + { + if (str->reserve(SPIDER_SQL_LEFT_JOIN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_LEFT_JOIN_STR, SPIDER_SQL_LEFT_JOIN_LEN); + } + } else { + if (str) + { + if (str->reserve(SPIDER_SQL_JOIN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); + } + } + use_cond_table_list = TRUE; + } else if (*current_pos > 0 && !first) + { + DBUG_PRINT("info",("spider no condition")); + if (top_down) + { + if (str) + { + if (str->reserve(SPIDER_SQL_JOIN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); + } + } else { + if (str) + { + if (str->reserve(SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + } + } + + if (str) + { + table_holder = fields->get_table_holder(table_list->table); + spd = table_holder->spider; + db_share = (spider_mysql_share *) + spd->share->dbton_share[dbton_id]; + dbton_hdl = (spider_mysql_handler *) + spd->dbton_handler[dbton_id]; + + dbton_hdl->table_name_pos = str->length(); + + if (str->reserve( + db_share->db_nm_max_length + + SPIDER_SQL_DOT_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + + db_share->table_nm_max_length + SPIDER_SQL_SPACE_LEN + + table_holder->alias->length() - SPIDER_SQL_DOT_LEN + )) { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + + if ((error_num = db_share->append_table_name_with_adjusting(str, + spd->conn_link_idx[dbton_hdl->first_link_idx]))) + { + DBUG_RETURN(error_num); + } + str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); + str->q_append(table_holder->alias->ptr(), + table_holder->alias->length() - SPIDER_SQL_DOT_LEN); + } + used_table_list[(*current_pos)++] = table_list; + + if (str) + { + List *join_using_fields = table_list->join_using_fields; + if (!join_using_fields && cond_table_list) + { + join_using_fields = cond_table_list->join_using_fields; + } + + if (join_using_fields) + { + if (str->reserve(SPIDER_SQL_USING_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + List_iterator_fast it2(*join_using_fields); + String *ptr; + while ((ptr = it2++)) + { + if (str->reserve(ptr->length() + SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(ptr->ptr(), ptr->length()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + + Item *on_expr = table_list->on_expr; + if (!on_expr && cond_table_list) + { + on_expr = cond_table_list->on_expr; + } + + if (on_expr) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ON_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_ON_STR, SPIDER_SQL_ON_LEN); + } + if ((error_num = spider_db_print_item_type(on_expr, NULL, + spider, str, NULL, 0, dbton_id, TRUE, fields))) + { + DBUG_RETURN(error_num); + } + } + + if (use_cond_table_list) + { + (*cond_table_list_ptr) = NULL; + DBUG_PRINT("info",("spider cond_table_list=%p", (*cond_table_list_ptr))); + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_tables_top_down( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr +) { + int error_num; + uint outer_join_backup; + TABLE_LIST *cur_table_list, *prev_table_list = NULL, *cond_table_list = NULL; + bool first; + DBUG_ENTER("spider_db_mysql_util::append_tables_top_down"); + DBUG_PRINT("info",("spider this=%p", this)); + if ( + table_list->outer_join || + table_list->on_expr || + table_list->join_using_fields + ) { + DBUG_ASSERT(!(*cond_table_list_ptr)); + (*cond_table_list_ptr) = table_list; + DBUG_PRINT("info",("spider cond_table_list=%p", table_list)); + } + List_iterator_fast it1(table_list->nested_join->join_list); + cur_table_list = it1++; + if (cur_table_list->outer_join & JOIN_TYPE_RIGHT) + { + first = FALSE; + prev_table_list = cur_table_list; + cur_table_list = it1++; + } else if (*cond_table_list_ptr) + { + first = TRUE; + cond_table_list = (*cond_table_list_ptr); + (*cond_table_list_ptr) = NULL; + if (cond_table_list->outer_join & JOIN_TYPE_LEFT) + { + if (str) + { + if (str->reserve(SPIDER_SQL_LEFT_JOIN_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_LEFT_JOIN_STR, SPIDER_SQL_LEFT_JOIN_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + } else { + if (str) + { + if (str->reserve(SPIDER_SQL_JOIN_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_JOIN_STR, SPIDER_SQL_JOIN_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); + } + } + } + + do { + if (cur_table_list->outer_join & JOIN_TYPE_RIGHT) + { + prev_table_list = cur_table_list; + } else { + if ((error_num = append_table(spider, fields, str, cur_table_list, + used_table_list, current_pos, cond_table_list_ptr, TRUE, first))) + DBUG_RETURN(error_num); + first = FALSE; + if (prev_table_list) + { + outer_join_backup = prev_table_list->outer_join; + prev_table_list->outer_join = JOIN_TYPE_LEFT; + if ((error_num = append_table(spider, fields, str, prev_table_list, + used_table_list, current_pos, cond_table_list_ptr, TRUE, FALSE))) + { + prev_table_list->outer_join = outer_join_backup; + DBUG_RETURN(error_num); + } + prev_table_list->outer_join = outer_join_backup; + prev_table_list = NULL; + } + } + } while ((cur_table_list = it1++)); + + if (cond_table_list) + { + if (str) + { + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + + List *join_using_fields = cond_table_list->join_using_fields; + if (join_using_fields) + { + if (str->reserve(SPIDER_SQL_USING_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); + str->q_append(SPIDER_SQL_OPEN_PAREN_STR, + SPIDER_SQL_OPEN_PAREN_LEN); + List_iterator_fast it2(*join_using_fields); + String *ptr; + while ((ptr = it2++)) + { + if (str->reserve(ptr->length() + SPIDER_SQL_COMMA_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(ptr->ptr(), ptr->length()); + str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); + } + str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + } + + Item *on_expr = cond_table_list->on_expr; + if (on_expr) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ON_LEN)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_ON_STR, SPIDER_SQL_ON_LEN); + } + if ((error_num = spider_db_print_item_type(on_expr, NULL, + spider, str, NULL, 0, spider_dbton_mysql.dbton_id, TRUE, fields))) + { + DBUG_RETURN(error_num); + } + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_tables_top_down_check( + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos +) { + int error_num; + TABLE_LIST *cur_table_list; + DBUG_ENTER("spider_db_mysql_util::append_tables_top_down_check"); + DBUG_PRINT("info",("spider this=%p", this)); + List_iterator_fast it1(table_list->nested_join->join_list); + while ((cur_table_list = it1++)) + { + if (!cur_table_list->table) + { + if ((error_num = append_tables_top_down_check( + cur_table_list, used_table_list, current_pos))) + DBUG_RETURN(error_num); + } else { + used_table_list[(*current_pos)++] = cur_table_list; + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_embedding_tables( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr +) { + int error_num; + TABLE_LIST *embedding = table_list->embedding; + DBUG_ENTER("spider_db_mysql_util::append_embedding_tables"); + DBUG_PRINT("info",("spider this=%p", this)); + if (embedding) + { + DBUG_PRINT("info",("spider embedding=%p", embedding)); + DBUG_PRINT("info",("spider embedding->outer_join=%u", + embedding->outer_join)); + DBUG_PRINT("info",("spider embedding->on_expr=%p", + embedding->on_expr)); + DBUG_PRINT("info",("spider embedding->join_using_fields=%p", + embedding->join_using_fields)); + DBUG_PRINT("info",("spider embedding->table=%p", + embedding->table)); + if ((error_num = append_embedding_tables(spider, fields, str, embedding, + used_table_list, current_pos, cond_table_list_ptr))) + DBUG_RETURN(error_num); + } else { + DBUG_PRINT("info",("spider table_list=%p", table_list)); + DBUG_PRINT("info",("spider table_list->outer_join=%u", + table_list->outer_join)); + DBUG_PRINT("info",("spider table_list->on_expr=%p", + table_list->on_expr)); + DBUG_PRINT("info",("spider table_list->join_using_fields=%p", + table_list->join_using_fields)); + DBUG_PRINT("info",("spider table_list->table=%p", + table_list->table)); + if (table_list->outer_join & JOIN_TYPE_RIGHT) + { + if ((error_num = append_tables_top_down_check(table_list, + used_table_list, current_pos))) + DBUG_RETURN(error_num); + DBUG_ASSERT(!(*cond_table_list_ptr)); + (*cond_table_list_ptr) = table_list; + DBUG_PRINT("info",("spider cond_table_list=%p", table_list)); + } else { + if ((error_num = append_tables_top_down(spider, fields, str, table_list, + used_table_list, current_pos, cond_table_list_ptr))) + DBUG_RETURN(error_num); + } + } + DBUG_RETURN(0); +} + +int spider_db_mysql_util::append_from_and_tables( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + uint table_count +) { + int error_num; + uint current_pos = 0, roop_count, backup_pos, outer_join_backup; + TABLE *table; + TABLE_LIST **used_table_list, *prev_table_list = NULL, + *cond_table_list = NULL; DBUG_ENTER("spider_db_mysql_util::append_from_and_tables"); DBUG_PRINT("info",("spider this=%p", this)); + used_table_list = (TABLE_LIST **) + my_alloca(sizeof(TABLE_LIST *) * table_count); + if (!used_table_list) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); - /* calculate from size */ - from_length = SPIDER_SQL_FROM_LEN; - fields->set_pos_to_first_table_holder(); - while ((table_holder = fields->get_next_table_holder())) + if (str) { - spider = table_holder->spider; - db_share = (spider_mysql_share *) - spider->share->dbton_share[dbton_id]; - from_length += - db_share->db_nm_max_length + - SPIDER_SQL_DOT_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4 + - db_share->table_nm_max_length + - SPIDER_SQL_SPACE_LEN + SPIDER_SQL_COMMA_LEN + - table_holder->alias->length() - SPIDER_SQL_DOT_LEN; + if (str->reserve(SPIDER_SQL_FROM_LEN)) + { + my_afree(used_table_list); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); } - if (str->reserve(from_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); + do { + table = table_list->table; + if (table->const_table) + continue; - fields->set_pos_to_first_table_holder(); - while ((table_holder = fields->get_next_table_holder())) - { - spider = table_holder->spider; - db_share = (spider_mysql_share *) - spider->share->dbton_share[dbton_id]; - dbton_hdl = (spider_mysql_handler *) - spider->dbton_handler[dbton_id]; - dbton_hdl->table_name_pos = str->length(); - if ((error_num = db_share->append_table_name_with_adjusting(str, - spider->conn_link_idx[dbton_hdl->first_link_idx]))) + for (roop_count = 0; roop_count < current_pos; ++roop_count) { + if (used_table_list[roop_count] == table_list) + break; + } + if (roop_count < current_pos) + continue; + + if (prev_table_list) + current_pos = backup_pos; + else + backup_pos = current_pos; + if ((error_num = append_table(spider, fields, str, table_list, used_table_list, + ¤t_pos, &cond_table_list, FALSE, FALSE))) + { + my_afree(used_table_list); DBUG_RETURN(error_num); } - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - str->q_append(table_holder->alias->ptr(), - table_holder->alias->length() - SPIDER_SQL_DOT_LEN); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); + if (prev_table_list) + { + outer_join_backup = prev_table_list->outer_join; + prev_table_list->outer_join = JOIN_TYPE_LEFT; + if ((error_num = append_table(spider, fields, str, prev_table_list, + used_table_list, ¤t_pos, &cond_table_list, FALSE, FALSE))) + { + prev_table_list->outer_join = outer_join_backup; + my_afree(used_table_list); + DBUG_RETURN(error_num); + } + prev_table_list->outer_join = outer_join_backup; + prev_table_list = NULL; + } + if (cond_table_list && (cond_table_list->outer_join & JOIN_TYPE_RIGHT)) + { + prev_table_list = cond_table_list; + cond_table_list = NULL; + DBUG_PRINT("info",("spider cond_table_list=%p", cond_table_list)); + } + } while ((table_list = table_list->next_local)); + my_afree(used_table_list); DBUG_RETURN(0); } @@ -5344,7 +5835,7 @@ int spider_mysql_share::create_column_name_str() str->init_calc_mem(89); str->set_charset(spider_share->access_charset); if ((error_num = spider_db_append_name_with_quote_str(str, - (char *) (*field)->field_name.str, dbton_id))) + (*field)->field_name, dbton_id))) goto error; } DBUG_RETURN(0); @@ -5613,6 +6104,10 @@ int spider_mysql_share::append_table_select() spider_string *str = table_select; TABLE_SHARE *table_share = spider_share->table_share; DBUG_ENTER("spider_mysql_share::append_table_select"); + + if (!*table_share->field) + DBUG_RETURN(0); + for (field = table_share->field; *field; field++) { field_length = column_name_str[(*field)->field_index].length(); @@ -5637,6 +6132,10 @@ int spider_mysql_share::append_key_select( TABLE_SHARE *table_share = spider_share->table_share; const KEY *key_info = &table_share->key_info[idx]; DBUG_ENTER("spider_mysql_share::append_key_select"); + + if (!spider_user_defined_key_parts(key_info)) + DBUG_RETURN(0); + for (key_part = key_info->key_part, part_num = 0; part_num < spider_user_defined_key_parts(key_info); key_part++, part_num++) { @@ -7276,16 +7775,28 @@ int spider_mysql_handler::append_select( if (result_list->lock_type != F_WRLCK && spider->lock_mode < 1) { /* no lock */ +#ifdef SPIDER_SQL_CACHE_IS_IN_LEX + LEX *lex = spider->trx->thd->lex; +#else st_select_lex *select_lex = &spider->trx->thd->lex->select_lex; +#endif if ( +#ifdef SPIDER_SQL_CACHE_IS_IN_LEX + lex->sql_cache == LEX::SQL_CACHE && +#else select_lex->sql_cache == SELECT_LEX::SQL_CACHE && +#endif (spider->share->query_cache_sync & 1) ) { if (str->reserve(SPIDER_SQL_SQL_CACHE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SQL_CACHE_STR, SPIDER_SQL_SQL_CACHE_LEN); } else if ( +#ifdef SPIDER_SQL_CACHE_IS_IN_LEX + lex->sql_cache == LEX::SQL_NO_CACHE && +#else select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE && +#endif (spider->share->query_cache_sync & 2) ) { if (str->reserve(SPIDER_SQL_SQL_NO_CACHE_LEN)) @@ -7652,8 +8163,7 @@ int spider_mysql_handler::check_item_type( DBUG_ENTER("spider_mysql_handler::check_item_type"); DBUG_PRINT("info",("spider this=%p", this)); error_num = spider_db_print_item_type(item, NULL, spider, NULL, NULL, 0, - spider_dbton_mysql.dbton_id, - FALSE, NULL); + spider_dbton_mysql.dbton_id, FALSE, NULL); DBUG_RETURN(error_num); } @@ -8276,22 +8786,67 @@ int spider_mysql_handler::append_update_where( ) { uint field_name_length; Field **field; + THD *thd = spider->trx->thd; SPIDER_SHARE *share = spider->share; + bool no_pk = (table->s->primary_key == MAX_KEY); DBUG_ENTER("spider_mysql_handler::append_update_where"); DBUG_PRINT("info", ("spider table->s->primary_key=%s", table->s->primary_key != MAX_KEY ? "TRUE" : "FALSE")); + uint str_len_bakup = str->length(); if (str->reserve(SPIDER_SQL_WHERE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); - for (field = table->field; *field; field++) - { - DBUG_PRINT("info", ("spider bitmap=%s", - bitmap_is_set(table->read_set, (*field)->field_index) ? - "TRUE" : "FALSE")); - if ( - table->s->primary_key == MAX_KEY || - bitmap_is_set(table->read_set, (*field)->field_index) + + if ( + no_pk || + spider_param_use_cond_other_than_pk_for_update(thd) + ) { + for (field = table->field; *field; field++) + { + if ( + no_pk || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + mysql_share->column_name_str[(*field)->field_index].length(); + if ((*field)->is_null(ptr_diff)) + { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_IS_NULL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + mysql_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + 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_mysql_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + (*field)->move_field_offset(-ptr_diff); + } + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } + } else { + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + uint part_num; + for ( + key_part = key_info->key_part, part_num = 0; + part_num < spider_user_defined_key_parts(key_info); + key_part++, part_num++ ) { + field = &key_part->field; field_name_length = mysql_share->column_name_str[(*field)->field_index].length(); if ((*field)->is_null(ptr_diff)) @@ -8322,7 +8877,13 @@ int spider_mysql_handler::append_update_where( str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); } } - str->length(str->length() - SPIDER_SQL_AND_LEN); + if (str->length() == str_len_bakup + SPIDER_SQL_WHERE_LEN) + { + /* no condition */ + str->length(str_len_bakup); + } else { + str->length(str->length() - SPIDER_SQL_AND_LEN); + } if (str->reserve(SPIDER_SQL_LIMIT1_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LIMIT1_STR, SPIDER_SQL_LIMIT1_LEN); @@ -8451,11 +9012,9 @@ int spider_mysql_handler::append_condition( str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); } } - if ((error_num = spider_db_print_item_type((Item *) tmp_cond->cond, - NULL, spider, str, - alias, alias_length, - spider_dbton_mysql.dbton_id, - FALSE, NULL))) + if ((error_num = spider_db_print_item_type( + (Item *) tmp_cond->cond, NULL, spider, str, alias, alias_length, + spider_dbton_mysql.dbton_id, FALSE, NULL))) { if (str && error_num == ER_SPIDER_COND_SKIP_NUM) { @@ -8778,9 +9337,7 @@ int spider_mysql_handler::append_group_by( for (; group; group = group->next) { if ((error_num = spider_db_print_item_type((*group->item), NULL, spider, - str, alias, alias_length, - spider_dbton_mysql.dbton_id, - FALSE, NULL))) + str, alias, alias_length, spider_dbton_mysql.dbton_id, FALSE, NULL))) { DBUG_RETURN(error_num); } @@ -8973,8 +9530,7 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( { if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, str, alias, - alias_length, spider_dbton_mysql.dbton_id, - FALSE, NULL))) + alias_length, spider_dbton_mysql.dbton_id, FALSE, NULL))) { DBUG_PRINT("info",("spider error=%d", error_num)); DBUG_RETURN(error_num); @@ -10602,8 +11158,14 @@ int spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start() DBUG_PRINT("info",("spider this=%p", this)); if (!upd_tmp_tbl) { +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor + LEX_CSTRING field_name = {STRING_WITH_LEN("a")}; + if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( + thd, table, &upd_tmp_tbl_prm, &field_name, update_sql.charset()))) +#else if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( thd, table, &upd_tmp_tbl_prm, "a", update_sql.charset()))) +#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -11295,8 +11857,7 @@ int spider_mysql_handler::show_table_status( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num || (error_num = spider_db_errorno(conn))) DBUG_RETURN(error_num); - else - { + else { my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), @@ -11496,7 +12057,6 @@ int spider_mysql_handler::show_table_status( DBUG_PRINT("info",("spider auto_increment_value=%llu", share->lgtm_tblhnd_share->auto_increment_value)); } - DBUG_RETURN(0); } @@ -12740,6 +13300,8 @@ int spider_mysql_handler::append_from_and_tables_part( ) { int error_num; spider_string *str; + SPIDER_TABLE_HOLDER *table_holder; + TABLE_LIST *table_list; DBUG_ENTER("spider_mysql_handler::append_from_and_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) @@ -12750,7 +13312,12 @@ int spider_mysql_handler::append_from_and_tables_part( default: DBUG_RETURN(0); } - error_num = spider_db_mysql_utility.append_from_and_tables(fields, str); + fields->set_pos_to_first_table_holder(); + table_holder = fields->get_next_table_holder(); + table_list = table_holder->table->pos_in_table_list; + error_num = spider_db_mysql_utility.append_from_and_tables( + table_holder->spider, fields, str, + table_list, fields->get_table_count()); DBUG_RETURN(error_num); } @@ -12834,9 +13401,7 @@ int spider_mysql_handler::append_item_type_part( DBUG_RETURN(0); } error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, - spider_dbton_mysql.dbton_id, - use_fields, fields); + alias, alias_length, spider_dbton_mysql.dbton_id, use_fields, fields); DBUG_RETURN(error_num); } @@ -12884,21 +13449,18 @@ int spider_mysql_handler::append_list_item_select( while ((item = it++)) { if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, - use_fields, fields))) + alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } field = *(fields->get_next_field_ptr()); if (field) { - item_name = field->field_name.str; - length = field->field_name.length; - } - else - { - item_name = item->name.str; - length = item->name.length; + item_name = SPIDER_field_name_str(field); + length = SPIDER_field_name_length(field); + } else { + item_name = SPIDER_item_name_str(item); + length = SPIDER_item_name_length(item); } if (str->reserve( SPIDER_SQL_COMMA_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + @@ -12907,7 +13469,7 @@ int spider_mysql_handler::append_list_item_select( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); if ((error_num = spider_db_mysql_utility.append_name(str, - item_name, length))) + item_name, length))) { DBUG_RETURN(error_num); } @@ -12962,9 +13524,7 @@ int spider_mysql_handler::append_group_by( for (; order; order = order->next) { if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, - str, alias, alias_length, - dbton_id, - use_fields, fields))) + str, alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } @@ -13022,9 +13582,7 @@ int spider_mysql_handler::append_order_by( for (; order; order = order->next) { if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, - str, alias, alias_length, - dbton_id, - use_fields, fields))) + str, alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } @@ -13147,7 +13705,7 @@ int spider_mysql_copy_table::append_table_columns( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) (*field)->field_name.str, spider_dbton_mysql.dbton_id))) + (*field)->field_name, spider_dbton_mysql.dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13276,7 +13834,7 @@ int spider_mysql_copy_table::append_key_order_str( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_mysql.dbton_id))) + field->field_name, spider_dbton_mysql.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13306,7 +13864,7 @@ int spider_mysql_copy_table::append_key_order_str( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_mysql.dbton_id))) + field->field_name, spider_dbton_mysql.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13438,7 +13996,7 @@ int spider_mysql_copy_table::copy_key_row( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_mysql.dbton_id))) + field->field_name, spider_dbton_mysql.dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length + SPIDER_SQL_AND_LEN)) diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 25cad01c66c..423ead89423 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -13,8 +13,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "tztime.h" - class spider_db_mysql_util: public spider_db_util { public: @@ -121,9 +119,46 @@ public: String *from ); #ifdef SPIDER_HAS_GROUP_BY_HANDLER - int append_from_and_tables( + int append_table( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr, + bool top_down, + bool first + ); + int append_tables_top_down( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr + ); + int append_tables_top_down_check( + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos + ); + int append_embedding_tables( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + TABLE_LIST **used_table_list, + uint *current_pos, + TABLE_LIST **cond_table_list_ptr + ); + int append_from_and_tables( + ha_spider *spider, + spider_fields *fields, + spider_string *str, + TABLE_LIST *table_list, + uint table_count ); int reappend_tables( spider_fields *fields, diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index b852a43282c..dfeafc58f13 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -152,6 +152,9 @@ static const int spider_db_table_lock_len[] = sizeof(" in exclusive mode") - 1 }; +/* UTC time zone for timestamp columns */ +extern Time_zone *UTC; + int spider_db_oracle_get_error( sword res, dvoid *hndlp, @@ -2410,8 +2413,13 @@ void spider_db_oracle::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { +#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name + key_name = (char *) table->s->key_info[roop_count].name.str; + key_name_length = table->s->key_info[roop_count].name.length; +#else key_name = table->s->key_info[roop_count].name; key_name_length = strlen(key_name); +#endif } memcpy(tmp_pos, key_name, key_name_length + 1); DBUG_PRINT("info",("spider key_name=%s", key_name)); @@ -2529,9 +2537,12 @@ int spider_db_oracle_util::append_column_value( spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); String *ptr; uint length; + Time_zone *saved_time_zone = thd->variables.time_zone; DBUG_ENTER("spider_db_oracle_util::append_column_value"); tmp_str.init_calc_mem(181); + thd->variables.time_zone = UTC; + if (new_ptr) { if ( @@ -2625,6 +2636,9 @@ int spider_db_oracle_util::append_column_value( ptr = field->val_str(tmp_str.get_str()); tmp_str.mem_calc(); } + + thd->variables.time_zone = saved_time_zone; + DBUG_PRINT("info", ("spider field->type() is %d", field->type())); DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); /* @@ -2909,12 +2923,13 @@ int spider_db_oracle_util::open_item_func( uint dbton_id = spider_dbton_oracle.dbton_id; int error_num; Item *item, **item_list = item_func->arguments(); + Field *field; uint roop_count, item_count = item_func->argument_count(), start_item = 0; const char *func_name = SPIDER_SQL_NULL_CHAR_STR, - *separete_str = SPIDER_SQL_NULL_CHAR_STR, + *separator_str = SPIDER_SQL_NULL_CHAR_STR, *last_str = SPIDER_SQL_NULL_CHAR_STR; int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, - separete_str_length = SPIDER_SQL_NULL_CHAR_LEN, + separator_str_length = SPIDER_SQL_NULL_CHAR_LEN, last_str_length = SPIDER_SQL_NULL_CHAR_LEN; int use_pushdown_udf; bool merge_func = FALSE; @@ -2980,7 +2995,7 @@ int spider_db_oracle_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("case", func_name, func_name_length) @@ -2996,7 +3011,7 @@ int spider_db_oracle_util::open_item_func( if (item_func_case->first_expr_num != -1) { if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], spider, str, + item_list[item_func_case->first_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3010,7 +3025,7 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count], spider, str, + item_list[roop_count], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3020,7 +3035,7 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count + 1], spider, str, + item_list[roop_count + 1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3033,7 +3048,7 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); } if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], spider, str, + item_list[item_func_case->else_expr_num], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -3070,7 +3085,7 @@ int spider_db_oracle_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if ( !strncasecmp("convert", func_name, func_name_length) @@ -3095,7 +3110,7 @@ int spider_db_oracle_util::open_item_func( ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if (func_name_length == 9 && !strncasecmp("isnottrue", func_name, func_name_length) @@ -3122,8 +3137,8 @@ int spider_db_oracle_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; break; } } else if (func_name_length == 12) @@ -3211,7 +3226,7 @@ int spider_db_oracle_util::open_item_func( { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { @@ -3274,7 +3289,7 @@ int spider_db_oracle_util::open_item_func( str->q_append(interval_str, interval_len); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[0], spider, + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3283,7 +3298,7 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } - if ((error_num = spider_db_print_item_type(item_list[1], spider, + if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -3549,8 +3564,9 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); } - if ((error_num = spider_db_print_item_type(item_list[0], spider, - str, alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[0], NULL, + spider, str, alias, alias_length, dbton_id, use_fields, + fields))) DBUG_RETURN(error_num); if (str) { @@ -3567,8 +3583,9 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } } - if ((error_num = spider_db_print_item_type(item_list[1], spider, - str, alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[1], NULL, + spider, str, alias, alias_length, dbton_id, use_fields, + fields))) DBUG_RETURN(error_num); if (str) { @@ -3613,8 +3630,9 @@ int spider_db_oracle_util::open_item_func( case INTERVAL_MINUTE: case INTERVAL_SECOND: case INTERVAL_MICROSECOND: - if ((error_num = spider_db_print_item_type(item_list[0], spider, - str, alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[0], NULL, + spider, str, alias, alias_length, dbton_id, use_fields, + fields))) DBUG_RETURN(error_num); if (str) { @@ -3629,8 +3647,9 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_PLUS_STR, SPIDER_SQL_PLUS_LEN); } } - if ((error_num = spider_db_print_item_type(item_list[1], spider, - str, alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type(item_list[1], NULL, + spider, str, alias, alias_length, dbton_id, use_fields, + fields))) DBUG_RETURN(error_num); if (str) { @@ -3709,15 +3728,15 @@ int spider_db_oracle_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; case Item_func::NOW_FUNC: if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); case Item_func::CHAR_TYPECAST_FUNC: DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC")); @@ -3843,15 +3862,15 @@ int spider_db_oracle_util::open_item_func( { func_name = SPIDER_SQL_NOT_IN_STR; func_name_length = SPIDER_SQL_NOT_IN_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; } else { func_name = SPIDER_SQL_IN_STR; func_name_length = SPIDER_SQL_IN_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; } @@ -3861,13 +3880,13 @@ int spider_db_oracle_util::open_item_func( { func_name = SPIDER_SQL_NOT_BETWEEN_STR; func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; - separete_str = SPIDER_SQL_AND_STR; - separete_str_length = SPIDER_SQL_AND_LEN; + separator_str = SPIDER_SQL_AND_STR; + separator_str_length = SPIDER_SQL_AND_LEN; } else { func_name = (char*) item_func->func_name(); func_name_length = strlen(func_name); - separete_str = SPIDER_SQL_AND_STR; - separete_str_length = SPIDER_SQL_AND_LEN; + separator_str = SPIDER_SQL_AND_STR; + separator_str_length = SPIDER_SQL_AND_LEN; } break; case Item_func::UDF_FUNC: @@ -3888,8 +3907,8 @@ int spider_db_oracle_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3909,10 +3928,10 @@ int spider_db_oracle_util::open_item_func( if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); if (item_func->result_type() == STRING_RESULT) - DBUG_RETURN(spider_db_open_item_string(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); else - DBUG_RETURN(spider_db_open_item_int(item_func, spider, str, + DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields)); case Item_func::FT_FUNC: if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) @@ -3924,8 +3943,8 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); } - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3942,8 +3961,8 @@ int spider_db_oracle_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -3974,8 +3993,8 @@ int spider_db_oracle_util::open_item_func( } func_name = SPIDER_SQL_COMMA_STR; func_name_length = SPIDER_SQL_COMMA_LEN; - separete_str = SPIDER_SQL_COMMA_STR; - separete_str_length = SPIDER_SQL_COMMA_LEN; + separator_str = SPIDER_SQL_COMMA_STR; + separator_str_length = SPIDER_SQL_COMMA_LEN; last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; @@ -4008,23 +4027,28 @@ int spider_db_oracle_util::open_item_func( } DBUG_PRINT("info",("spider func_name = %s", func_name)); DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - DBUG_PRINT("info",("spider separete_str = %s", separete_str)); - DBUG_PRINT("info",("spider separete_str_length = %d", separete_str_length)); + DBUG_PRINT("info",("spider separator_str = %s", separator_str)); + DBUG_PRINT("info",("spider separator_str_length = %d", separator_str_length)); DBUG_PRINT("info",("spider last_str = %s", last_str)); DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); if (item_count) { + /* Find the field in the list of items of the expression tree */ + field = spider_db_find_field_in_item_list(item_list, + item_count, start_item, + str, + func_name, func_name_length); item_count--; for (roop_count = start_item; roop_count < item_count; roop_count++) { item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (roop_count == 1) { - func_name = separete_str; - func_name_length = separete_str_length; + func_name = separator_str; + func_name_length = separator_str_length; } if (str) { @@ -4036,7 +4060,7 @@ int spider_db_oracle_util::open_item_func( } } item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -4050,7 +4074,7 @@ int spider_db_oracle_util::open_item_func( str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); } item = item_list[0]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -4138,7 +4162,7 @@ int spider_db_oracle_util::open_item_sum_func( for (roop_count = 0; roop_count < item_count; roop_count++) { item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -4149,7 +4173,7 @@ int spider_db_oracle_util::open_item_sum_func( } } item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -4209,8 +4233,11 @@ int spider_db_oracle_util::append_escaped_util( #ifdef SPIDER_HAS_GROUP_BY_HANDLER int spider_db_oracle_util::append_from_and_tables( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + uint table_count ) { SPIDER_TABLE_HOLDER *table_holder; int error_num; @@ -4745,7 +4772,7 @@ int spider_oracle_share::create_column_name_str() str->init_calc_mem(196); str->set_charset(spider_share->access_charset); if ((error_num = spider_db_append_name_with_quote_str(str, - (char *) (*field)->field_name.str, dbton_id))) + (*field)->field_name, dbton_id))) goto error; } DBUG_RETURN(0); @@ -5188,6 +5215,10 @@ int spider_oracle_share::append_table_select() spider_string *str = table_select; TABLE_SHARE *table_share = spider_share->table_share; DBUG_ENTER("spider_oracle_share::append_table_select"); + + if (!*table_share->field) + DBUG_RETURN(0); + for (field = table_share->field; *field; field++) { field_length = column_name_str[(*field)->field_index].length(); @@ -5212,6 +5243,10 @@ int spider_oracle_share::append_key_select( TABLE_SHARE *table_share = spider_share->table_share; const KEY *key_info = &table_share->key_info[idx]; DBUG_ENTER("spider_oracle_share::append_key_select"); + + if (!spider_user_defined_key_parts(key_info)) + DBUG_RETURN(0); + for (key_part = key_info->key_part, part_num = 0; part_num < spider_user_defined_key_parts(key_info); key_part++, part_num++) { @@ -6414,7 +6449,7 @@ int spider_oracle_handler::append_update_columns( { value = vi++; if ((error_num = spider_db_print_item_type( - (Item *) field, spider, str, alias, alias_length, + (Item *) field, NULL, spider, str, alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) { if ( @@ -6432,8 +6467,8 @@ int spider_oracle_handler::append_update_columns( str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); } if ((error_num = spider_db_print_item_type( - (Item *) value, spider, str, alias, alias_length, - spider_dbton_oracle.dbton_id, FALSE, NULL))) + (Item *) value, ((Item_field *) field)->field, spider, str, + alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) DBUG_RETURN(error_num); if (str) { @@ -6834,7 +6869,7 @@ int spider_oracle_handler::check_item_type( int error_num; DBUG_ENTER("spider_oracle_handler::check_item_type"); DBUG_PRINT("info",("spider this=%p", this)); - error_num = spider_db_print_item_type(item, spider, NULL, NULL, 0, + error_num = spider_db_print_item_type(item, NULL, spider, NULL, NULL, 0, spider_dbton_oracle.dbton_id, FALSE, NULL); DBUG_RETURN(error_num); } @@ -7437,17 +7472,64 @@ int spider_oracle_handler::append_update_where( ) { uint field_name_length; Field **field; + THD *thd = spider->trx->thd; SPIDER_SHARE *share = spider->share; + bool no_pk = (table->s->primary_key == MAX_KEY); DBUG_ENTER("spider_oracle_handler::append_update_where"); + uint str_len_bakup = str->length(); if (str->reserve(SPIDER_SQL_WHERE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN); - for (field = table->field; *field; field++) - { - if ( - table->s->primary_key == MAX_KEY || - bitmap_is_set(table->read_set, (*field)->field_index) + if ( + no_pk || + spider_param_use_cond_other_than_pk_for_update(thd) + ) { + for (field = table->field; *field; field++) + { + if ( + no_pk || + bitmap_is_set(table->read_set, (*field)->field_index) + ) { + field_name_length = + oracle_share->column_name_str[(*field)->field_index].length(); + if ((*field)->is_null(ptr_diff)) + { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_IS_NULL_LEN + SPIDER_SQL_AND_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_share->append_column_name(str, (*field)->field_index); + str->q_append(SPIDER_SQL_IS_NULL_STR, SPIDER_SQL_IS_NULL_LEN); + } else { + if (str->reserve(field_name_length + + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + + SPIDER_SQL_EQUAL_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + oracle_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_oracle_utility. + append_column_value(spider, str, *field, NULL, + share->access_charset) || + str->reserve(SPIDER_SQL_AND_LEN) + ) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + (*field)->move_field_offset(-ptr_diff); + } + str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); + } + } + } else { + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + uint part_num; + for ( + key_part = key_info->key_part, part_num = 0; + part_num < spider_user_defined_key_parts(key_info); + key_part++, part_num++ ) { + field = &key_part->field; field_name_length = oracle_share->column_name_str[(*field)->field_index].length(); if ((*field)->is_null(ptr_diff)) @@ -7478,9 +7560,13 @@ int spider_oracle_handler::append_update_where( str->q_append(SPIDER_SQL_AND_STR, SPIDER_SQL_AND_LEN); } } -/* - str->length(str->length() - SPIDER_SQL_AND_LEN); -*/ + if (str->length() == str_len_bakup + SPIDER_SQL_WHERE_LEN) + { + /* no condition */ + str->length(str_len_bakup); + } else { + str->length(str->length() - SPIDER_SQL_AND_LEN); + } if (str->reserve(SPIDER_SQL_LIMIT1_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_LIMIT1_STR, SPIDER_SQL_LIMIT1_LEN); @@ -7615,7 +7701,7 @@ int spider_oracle_handler::append_condition( } } if ((error_num = spider_db_print_item_type( - (Item *) tmp_cond->cond, spider, str, alias, alias_length, + (Item *) tmp_cond->cond, NULL, spider, str, alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) { if (str && error_num == ER_SPIDER_COND_SKIP_NUM) @@ -7937,8 +8023,8 @@ int spider_oracle_handler::append_group_by( str->q_append(SPIDER_SQL_GROUP_STR, SPIDER_SQL_GROUP_LEN); for (; group; group = group->next) { - if ((error_num = spider_db_print_item_type((*group->item), spider, str, - alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) + if ((error_num = spider_db_print_item_type((*group->item), NULL, spider, + str, alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) { DBUG_RETURN(error_num); } @@ -8276,8 +8362,8 @@ int spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias( order = order->next) { if ((error_num = - spider_db_print_item_type((*order->item), spider, &sql_part, alias, - alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) + spider_db_print_item_type((*order->item), NULL, spider, &sql_part, + alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) { DBUG_PRINT("info",("spider error=%d", error_num)); DBUG_RETURN(error_num); @@ -8367,7 +8453,7 @@ int spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias( order = order->next) { if ((error_num = - spider_db_print_item_type((*order->item), spider, str, alias, + spider_db_print_item_type((*order->item), NULL, spider, str, alias, alias_length, spider_dbton_oracle.dbton_id, FALSE, NULL))) { DBUG_PRINT("info",("spider error=%d", error_num)); @@ -10199,8 +10285,14 @@ int spider_oracle_handler::mk_bulk_tmp_table_and_bulk_start() DBUG_PRINT("info",("spider this=%p", this)); if (!upd_tmp_tbl) { +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor + LEX_CSTRING field_name = {STRING_WITH_LEN("a")}; + if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( + thd, table, &upd_tmp_tbl_prm, &field_name, update_sql.charset()))) +#else if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( thd, table, &upd_tmp_tbl_prm, "a", update_sql.charset()))) +#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -12454,6 +12546,8 @@ int spider_oracle_handler::append_from_and_tables_part( ) { int error_num; spider_string *str; + SPIDER_TABLE_HOLDER *table_holder; + TABLE_LIST *table_list; DBUG_ENTER("spider_oracle_handler::append_from_and_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) @@ -12464,7 +12558,11 @@ int spider_oracle_handler::append_from_and_tables_part( default: DBUG_RETURN(0); } - error_num = spider_db_oracle_utility.append_from_and_tables(fields, str); + fields->set_pos_to_first_table_holder(); + table_holder = fields->get_next_table_holder(); + table_list = table_holder->table->pos_in_table_list; + error_num = spider_db_oracle_utility.append_from_and_tables(fields, str, + table_list); DBUG_RETURN(error_num); } @@ -12547,8 +12645,8 @@ int spider_oracle_handler::append_item_type_part( default: DBUG_RETURN(0); } - error_num = spider_db_print_item_type(item, spider, str, alias, alias_length, - spider_dbton_oracle.dbton_id, use_fields, fields); + error_num = spider_db_print_item_type(item, NULL, spider, str, + alias, alias_length, spider_dbton_oracle.dbton_id, use_fields, fields); DBUG_RETURN(error_num); } @@ -12589,18 +12687,26 @@ int spider_oracle_handler::append_list_item_select( uint dbton_id = spider_dbton_oracle.dbton_id, length; List_iterator_fast it(*select); Item *item; - Field **field_ptr; + Field *field; + const char *item_name; DBUG_ENTER("spider_oracle_handler::append_list_item_select"); DBUG_PRINT("info",("spider this=%p", this)); while ((item = it++)) { - if ((error_num = spider_db_print_item_type(item, spider, str, + if ((error_num = spider_db_print_item_type(item, NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } - field_ptr = fields->get_next_field_ptr(); - length = strlen((*field_ptr)->field_name); + field = *(fields->get_next_field_ptr()); + if (field) + { + item_name = SPIDER_field_name_str(field); + length = SPIDER_field_name_length(field); + } else { + item_name = SPIDER_item_name_str(item); + length = SPIDER_item_name_length(item); + } if (str->reserve( SPIDER_SQL_COMMA_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_SPACE_LEN + length @@ -12608,7 +12714,7 @@ int spider_oracle_handler::append_list_item_select( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); if ((error_num = spider_db_oracle_utility.append_name(str, - (*field_ptr)->field_name, length))) + item_name, length))) { DBUG_RETURN(error_num); } @@ -12662,8 +12768,8 @@ int spider_oracle_handler::append_group_by( str->q_append(SPIDER_SQL_GROUP_STR, SPIDER_SQL_GROUP_LEN); for (; order; order = order->next) { - if ((error_num = spider_db_print_item_type((*order->item), spider, str, - alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } @@ -12720,8 +12826,8 @@ int spider_oracle_handler::append_order_by( str->q_append(SPIDER_SQL_ORDER_STR, SPIDER_SQL_ORDER_LEN); for (; order; order = order->next) { - if ((error_num = spider_db_print_item_type((*order->item), spider, str, - alias, alias_length, dbton_id, use_fields, fields))) + if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, + str, alias, alias_length, dbton_id, use_fields, fields))) { DBUG_RETURN(error_num); } @@ -12831,7 +12937,7 @@ int spider_oracle_copy_table::append_table_columns( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) (*field)->field_name.str, spider_dbton_oracle.dbton_id))) + (*field)->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -12977,7 +13083,7 @@ int spider_oracle_copy_table::append_key_order_str( sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql_part, - (char *) field->field_name.str, spider_dbton_oracle.dbton_id))) + field->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13011,7 +13117,7 @@ int spider_oracle_copy_table::append_key_order_str( sql_part.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql_part, - (char *) field->field_name.str, spider_dbton_oracle.dbton_id))) + field->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13075,7 +13181,7 @@ int spider_oracle_copy_table::append_key_order_str( sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_oracle.dbton_id))) + field->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13108,7 +13214,7 @@ int spider_oracle_copy_table::append_key_order_str( sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_oracle.dbton_id))) + field->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13316,7 +13422,7 @@ int spider_oracle_copy_table::copy_key_row( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (char *) field->field_name.str, spider_dbton_oracle.dbton_id))) + field->field_name, spider_dbton_oracle.dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length + SPIDER_SQL_AND_LEN)) diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index 6962ff4884f..9f9c75f0090 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -13,8 +13,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "tztime.h" - class spider_db_oracle; class spider_db_oracle_result; @@ -131,8 +129,11 @@ public: ); #ifdef SPIDER_HAS_GROUP_BY_HANDLER int append_from_and_tables( + ha_spider *spider, spider_fields *fields, - spider_string *str + spider_string *str, + TABLE_LIST *table_list, + uint table_count ); int reappend_tables( spider_fields *fields, diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index d56848f5dbd..65d5142e1f1 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2017 Kentoku Shiba +/* Copyright (C) 2009-2018 Kentoku Shiba 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 @@ -27,6 +27,7 @@ #include "sql_partition.h" #include "sql_base.h" #include "sql_servers.h" +#include "tztime.h" #endif #include "spd_err.h" #include "spd_param.h" @@ -65,6 +66,9 @@ extern pthread_mutex_t spider_conn_id_mutex; extern pthread_mutex_t spider_ipport_conn_mutex; extern ulonglong spider_conn_id; +/* UTC time zone for timestamp columns */ +extern Time_zone *UTC; + uint spider_udf_calc_hash( char *key, uint mod @@ -132,7 +136,7 @@ int spider_udf_direct_sql_create_table_list( &direct_sql->tables, sizeof(TABLE*) * table_count, &tmp_name_ptr, sizeof(char) * ( table_name_list_length + - thd->db.length * table_count + + SPIDER_THD_db_length(thd) * table_count + 2 * table_count ), &direct_sql->iop, sizeof(int) * table_count, @@ -163,11 +167,11 @@ int spider_udf_direct_sql_create_table_list( tmp_name_ptr += length + 1; tmp_ptr = tmp_ptr3 + 1; } else { - if (thd->db.str) + if (SPIDER_THD_db_str(thd)) { - memcpy(tmp_name_ptr, thd->db.str, - thd->db.length + 1); - tmp_name_ptr += thd->db.length + 1; + memcpy(tmp_name_ptr, SPIDER_THD_db_str(thd), + SPIDER_THD_db_length(thd) + 1); + tmp_name_ptr += SPIDER_THD_db_length(thd) + 1; } else { direct_sql->db_names[roop_count] = (char *) ""; } @@ -395,6 +399,13 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( int *need_mon; DBUG_ENTER("spider_udf_direct_sql_create_conn"); + if (unlikely(!UTC)) + { + /* UTC time zone for timestamp columns */ + String tz_00_name(STRING_WITH_LEN("+00:00"), &my_charset_bin); + UTC = my_tz_find(current_thd, &tz_00_name); + } + #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (direct_sql->access_mode == 0) { @@ -976,8 +987,7 @@ error: start_ptr, TRUE, ¶m_string_parse))) \ direct_sql->SPIDER_PARAM_STR_LEN(param_name) = \ strlen(direct_sql->param_name); \ - else \ - { \ + else { \ error_num = param_string_parse.print_param_error(); \ goto error; \ } \ @@ -1330,10 +1340,10 @@ int spider_udf_set_direct_sql_param_default( if (!direct_sql->tgt_default_db_name) { DBUG_PRINT("info",("spider create default tgt_default_db_name")); - direct_sql->tgt_default_db_name_length = trx->thd->db.length; + direct_sql->tgt_default_db_name_length = SPIDER_THD_db_length(trx->thd); if ( !(direct_sql->tgt_default_db_name = spider_create_string( - trx->thd->db.str, + SPIDER_THD_db_str(trx->thd), direct_sql->tgt_default_db_name_length)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); @@ -1686,14 +1696,29 @@ long long spider_direct_sql_body( for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) { #ifdef SPIDER_NEED_INIT_ONE_TABLE_FOR_FIND_TEMPORARY_TABLE - LEX_CSTRING db_name= { direct_sql->db_names[roop_count], - strlen(direct_sql->db_names[roop_count]) }; - LEX_CSTRING tbl_name= { direct_sql->table_names[roop_count], - strlen(direct_sql->table_names[roop_count]) }; +#ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias + LEX_CSTRING db_name = + { + direct_sql->db_names[roop_count], + strlen(direct_sql->db_names[roop_count]) + }; + LEX_CSTRING tbl_name = + { + direct_sql->table_names[roop_count], + strlen(direct_sql->table_names[roop_count]) + }; table_list.init_one_table(&db_name, &tbl_name, 0, TL_WRITE); #else - table_list.db = direct_sql->db_names[roop_count]; - table_list.table_name = direct_sql->table_names[roop_count]; + table_list.init_one_table(direct_sql->db_names[roop_count], + strlen(direct_sql->db_names[roop_count]), + direct_sql->table_names[roop_count], + strlen(direct_sql->table_names[roop_count]), + direct_sql->table_names[roop_count], TL_WRITE); +#endif +#else + SPIDER_TABLE_LIST_db_str(&table_list) = direct_sql->db_names[roop_count]; + SPIDER_TABLE_LIST_table_name_str(&table_list) = + direct_sql->table_names[roop_count]; #endif if (!(direct_sql->tables[roop_count] = SPIDER_find_temporary_table(thd, &table_list))) @@ -1706,16 +1731,28 @@ long long spider_direct_sql_body( error_num = ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM; my_printf_error(ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM, ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR, - MYF(0), table_list.db.str, table_list.table_name.str); + MYF(0), SPIDER_TABLE_LIST_db_str(&table_list), + SPIDER_TABLE_LIST_table_name_str(&table_list)); goto error; #if MYSQL_VERSION_ID < 50500 #else } TABLE_LIST *tables = &direct_sql->table_list[roop_count]; - - table_list.init_one_table(&table_list.db, &table_list.table_name, 0, TL_WRITE); - tables->mdl_request.init(MDL_key::TABLE, table_list.db.str, - table_list.table_name.str, MDL_SHARED_WRITE, MDL_TRANSACTION); +#ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias + table_list.init_one_table( + &table_list.db, &table_list.table_name, 0, TL_WRITE); +#else + tables->init_one_table( + SPIDER_TABLE_LIST_db_str(&table_list), + SPIDER_TABLE_LIST_db_length(&table_list), + SPIDER_TABLE_LIST_table_name_str(&table_list), + SPIDER_TABLE_LIST_table_name_length(&table_list), + SPIDER_TABLE_LIST_table_name_str(&table_list), TL_WRITE); +#endif + tables->mdl_request.init(MDL_key::TABLE, + SPIDER_TABLE_LIST_db_str(&table_list), + SPIDER_TABLE_LIST_table_name_str(&table_list), + MDL_SHARED_WRITE, MDL_TRANSACTION); if (!direct_sql->table_list_first) { direct_sql->table_list_first = tables; diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index ef7e6ff88c8..5e66a912582 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba & 2017 MariaDB corp +/* Copyright (C) 2008-2018 Kentoku Shiba & 2017 MariaDB corp 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 @@ -37,4 +37,17 @@ #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT #endif + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100300 +#define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA +#endif + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100309 +#define SPIDER_MDEV_16246 +#endif + +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100400 +#define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM +#define SPIDER_SQL_CACHE_IS_IN_LEX +#endif #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 0f8479b6ca6..86a9f8cba68 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -172,6 +172,7 @@ int spider_fields::make_link_idx_chain( add_link_idx_holder->table_link_idx_holder = dup_link_idx_holder->table_link_idx_holder; add_link_idx_holder->link_idx = dup_link_idx_holder->link_idx; + add_link_idx_holder->link_status = dup_link_idx_holder->link_status; link_idx_holder->next = add_link_idx_holder; } link_idx_holder = link_idx_holder->next; @@ -446,6 +447,8 @@ bool spider_fields::check_link_ok_chain( for (current_link_idx_chain = first_link_idx_chain; current_link_idx_chain; current_link_idx_chain = current_link_idx_chain->next) { + DBUG_PRINT("info",("spider current_link_idx_chain=%p", current_link_idx_chain)); + DBUG_PRINT("info",("spider current_link_idx_chain->link_status=%d", current_link_idx_chain->link_status)); if (current_link_idx_chain->link_status == SPIDER_LINK_STATUS_OK) { first_ok_link_idx_chain = current_link_idx_chain; @@ -924,8 +927,8 @@ SPIDER_TABLE_HOLDER *spider_fields::add_table( bool spider_fields::all_query_fields_are_query_table_members() { SPIDER_FIELD_HOLDER *field_holder; - DBUG_ENTER("spider_fields::all_fields_are_query_table_fields"); - DBUG_PRINT("info", ("spider this=%p", this)); + DBUG_ENTER("spider_fields::all_query_fields_are_query_table_members"); + DBUG_PRINT("info",("spider this=%p", this)); set_pos_to_first_field_holder(); while ((field_holder = get_next_field_holder())) @@ -977,6 +980,25 @@ SPIDER_TABLE_HOLDER *spider_fields::get_next_table_holder( DBUG_RETURN(return_table_holder); } +SPIDER_TABLE_HOLDER *spider_fields::get_table_holder(TABLE *table) +{ + uint table_num; + DBUG_ENTER("spider_fields::get_table_holder"); + DBUG_PRINT("info",("spider this=%p", this)); + for (table_num = 0; table_num < table_count; ++table_num) + { + if (table_holder[table_num].table == table) + DBUG_RETURN(&table_holder[table_num]); + } + DBUG_RETURN(NULL); +} + +uint spider_fields::get_table_count() +{ + DBUG_ENTER("spider_fields::get_table_count"); + DBUG_RETURN(table_count); +} + int spider_fields::add_field( Field *field_arg ) { @@ -1191,7 +1213,8 @@ int spider_group_by_handler::init_scan() *field; field++ ) { - DBUG_PRINT("info",("spider field_name=%s", (*field)->field_name.str)); + DBUG_PRINT("info",("spider field_name=%s", + SPIDER_field_name_str(*field))); } #endif @@ -1757,7 +1780,7 @@ group_by_handler *spider_create_group_by_handler( { DBUG_PRINT("info",("spider select item=%p", item)); if (spider_db_print_item_type(item, NULL, spider, NULL, NULL, 0, - roop_count, TRUE, fields_arg)) + roop_count, TRUE, fields_arg)) { DBUG_PRINT("info",("spider dbton_id=%d can't create select", roop_count)); spider_clear_bit(dbton_bitmap, roop_count); @@ -1766,13 +1789,22 @@ group_by_handler *spider_create_group_by_handler( } } if (keep_going) + { + if (spider_dbton[roop_count].db_util->append_from_and_tables( + spider, fields_arg, NULL, query->from, table_idx)) + { + DBUG_PRINT("info",("spider dbton_id=%d can't create from", roop_count)); + spider_clear_bit(dbton_bitmap, roop_count); + keep_going = FALSE; + } + } + if (keep_going) { DBUG_PRINT("info",("spider query->where=%p", query->where)); if (query->where) { - if (spider_db_print_item_type(query->where, NULL, spider, NULL, - NULL, 0, roop_count, - TRUE, fields_arg)) + if (spider_db_print_item_type(query->where, NULL, spider, NULL, NULL, 0, + roop_count, TRUE, fields_arg)) { DBUG_PRINT("info",("spider dbton_id=%d can't create where", roop_count)); spider_clear_bit(dbton_bitmap, roop_count); @@ -1787,9 +1819,8 @@ group_by_handler *spider_create_group_by_handler( { for (order = query->group_by; order; order = order->next) { - if (spider_db_print_item_type((*order->item), NULL, spider, NULL, - NULL, 0, roop_count, - TRUE, fields_arg)) + if (spider_db_print_item_type((*order->item), NULL, spider, NULL, NULL, 0, + roop_count, TRUE, fields_arg)) { DBUG_PRINT("info",("spider dbton_id=%d can't create group by", roop_count)); spider_clear_bit(dbton_bitmap, roop_count); @@ -1806,9 +1837,8 @@ group_by_handler *spider_create_group_by_handler( { for (order = query->order_by; order; order = order->next) { - if (spider_db_print_item_type((*order->item), NULL, spider, NULL, - NULL, 0, roop_count, - TRUE, fields_arg)) + if (spider_db_print_item_type((*order->item), NULL, spider, NULL, NULL, 0, + roop_count, TRUE, fields_arg)) { DBUG_PRINT("info",("spider dbton_id=%d can't create order by", roop_count)); spider_clear_bit(dbton_bitmap, roop_count); @@ -1823,9 +1853,8 @@ group_by_handler *spider_create_group_by_handler( DBUG_PRINT("info",("spider query->having=%p", query->having)); if (query->having) { - if (spider_db_print_item_type(query->having, NULL, spider, NULL, - NULL, 0, roop_count, - TRUE, fields_arg)) + if (spider_db_print_item_type(query->having, NULL, spider, NULL, NULL, 0, + roop_count, TRUE, fields_arg)) { DBUG_PRINT("info",("spider dbton_id=%d can't create having", roop_count)); spider_clear_bit(dbton_bitmap, roop_count); diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index 8a7ad752bcd..9c9e066b62f 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2017 Kentoku Shiba +/* Copyright (C) 2012-2018 Kentoku Shiba 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 @@ -164,6 +164,6 @@ struct st_maria_plugin spider_i_s_alloc_mem_maria = NULL, NULL, "1.0", - MariaDB_PLUGIN_MATURITY_STABLE + MariaDB_PLUGIN_MATURITY_STABLE, }; #endif diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 79e030b0872..38ded445d44 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -13,9 +13,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "tztime.h" - -#define SPIDER_DETAIL_VERSION "3.3.13" +#define SPIDER_DETAIL_VERSION "3.3.14" #define SPIDER_HEX_VERSION 0x0303 #if MYSQL_VERSION_ID < 50500 @@ -76,12 +74,21 @@ #define spider_user_defined_key_parts(A) (A)->user_defined_key_parts #define spider_join_table_count(A) (A)->table_count #define SPIDER_CAN_BG_UPDATE (1LL << 39) -#define SPIDER_ALTER_PARTITION_ADD ALTER_PARTITION_ADD -#define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP -#define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE -#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE -#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG -#define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD +#if MYSQL_VERSION_ID >= 100304 +#define SPIDER_ALTER_PARTITION_ADD ALTER_PARTITION_ADD +#define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP +#define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE +#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE +#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG +#define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD +#else +#define SPIDER_ALTER_PARTITION_ADD Alter_info::ALTER_ADD_PARTITION +#define SPIDER_ALTER_PARTITION_DROP Alter_info::ALTER_DROP_PARTITION +#define SPIDER_ALTER_PARTITION_COALESCE Alter_info::ALTER_COALESCE_PARTITION +#define SPIDER_ALTER_PARTITION_REORGANIZE Alter_info::ALTER_REORGANIZE_PARTITION +#define SPIDER_ALTER_PARTITION_TABLE_REORG Alter_info::ALTER_TABLE_REORG +#define SPIDER_ALTER_PARTITION_REBUILD Alter_info::ALTER_REBUILD_PARTITION +#endif #define SPIDER_WARN_LEVEL_WARN Sql_condition::WARN_LEVEL_WARN #define SPIDER_WARN_LEVEL_NOTE Sql_condition::WARN_LEVEL_NOTE #define SPIDER_THD_KILL_CONNECTION KILL_CONNECTION @@ -100,12 +107,12 @@ #endif #define spider_user_defined_key_parts(A) (A)->key_parts #define spider_join_table_count(A) (A)->tables -#define SPIDER_ALTER_PARTITION_ADD ALTER_PARTITION_ADD -#define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP -#define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE -#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE -#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG -#define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD +#define SPIDER_ALTER_PARTITION_ADD ALTER_ADD_PARTITION +#define SPIDER_ALTER_PARTITION_DROP ALTER_DROP_PARTITION +#define SPIDER_ALTER_PARTITION_COALESCE ALTER_COALESCE_PARTITION +#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_REORGANIZE_PARTITION +#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_TABLE_REORG +#define SPIDER_ALTER_PARTITION_REBUILD ALTER_REBUILD_PARTITION #define SPIDER_WARN_LEVEL_WARN MYSQL_ERROR::WARN_LEVEL_WARN #define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE #define SPIDER_THD_KILL_CONNECTION THD::KILL_CONNECTION @@ -182,10 +189,56 @@ #define SPIDER_free_part_syntax(A,B) spider_my_free(A,B) #endif +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100306 +#define SPIDER_read_record_read_record(A) read_record() +#define SPIDER_has_Item_with_subquery +#define SPIDER_use_LEX_CSTRING_for_KEY_Field_name +#define SPIDER_use_LEX_CSTRING_for_Field_blob_constructor +#define SPIDER_use_LEX_CSTRING_for_database_tablename_alias +#define SPIDER_THD_db_str(A) (A)->db.str +#define SPIDER_THD_db_length(A) (A)->db.length +#define SPIDER_TABLE_LIST_db_str(A) (A)->db.str +#define SPIDER_TABLE_LIST_db_length(A) (A)->db.length +#define SPIDER_TABLE_LIST_table_name_str(A) (A)->table_name.str +#define SPIDER_TABLE_LIST_table_name_length(A) (A)->table_name.length +#define SPIDER_TABLE_LIST_alias_str(A) (A)->alias.str +#define SPIDER_TABLE_LIST_alias_length(A) (A)->alias.length +#define SPIDER_field_name_str(A) (A)->field_name.str +#define SPIDER_field_name_length(A) (A)->field_name.length +#define SPIDER_item_name_str(A) (A)->name.str +#define SPIDER_item_name_length(A) (A)->name.length +const LEX_CSTRING SPIDER_empty_string = {"", 0}; +#else +#define SPIDER_read_record_read_record(A) read_record(A) +#define SPIDER_THD_db_str(A) (A)->db +#define SPIDER_THD_db_length(A) (A)->db_length +#define SPIDER_TABLE_LIST_db_str(A) (A)->db +#define SPIDER_TABLE_LIST_db_length(A) (A)->db_length +#define SPIDER_TABLE_LIST_table_name_str(A) (A)->table_name +#define SPIDER_TABLE_LIST_table_name_length(A) (A)->table_name_length +#define SPIDER_TABLE_LIST_alias_str(A) (A)->alias +#define SPIDER_TABLE_LIST_alias_length(A) strlen((A)->alias) +#define SPIDER_field_name_str(A) (A)->field_name +#define SPIDER_field_name_length(A) strlen((A)->field_name) +#define SPIDER_item_name_str(A) (A)->name +#define SPIDER_item_name_length(A) strlen((A)->name) +const char SPIDER_empty_string = ""; +#endif + #if MYSQL_VERSION_ID >= 50500 #define SPIDER_HAS_HASH_VALUE_TYPE #endif +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100400 +#define SPIDER_date_mode_t(A) date_mode_t(A) +#define SPIDER_str_to_datetime(A,B,C,D,E) str_to_datetime_or_date(A,B,C,D,E) +#define SPIDER_get_linkage(A) A->get_linkage() +#else +#define SPIDER_date_mode_t(A) A +#define SPIDER_str_to_datetime(A,B,C,D,E) str_to_datetime(A,B,C,D,E) +#define SPIDER_get_linkage(A) A->linkage +#endif + #define spider_bitmap_size(A) ((A + 7) / 8) #define spider_set_bit(BITMAP, BIT) \ ((BITMAP)[(BIT) / 8] |= (1 << ((BIT) & 7))) diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 9c7aa4dcdcb..a90f628603e 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -3123,6 +3123,30 @@ int spider_param_bka_table_name_type( bka_table_name_type : THDVAR(thd, bka_table_name_type)); } +/* + -1 :use table parameter + 0 :off + 1 :on + */ +static MYSQL_THDVAR_INT( + use_cond_other_than_pk_for_update, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Use all conditions even if condition has pk", /* comment */ + NULL, /* check */ + NULL, /* update */ + 1, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +int spider_param_use_cond_other_than_pk_for_update( + THD *thd +) { + DBUG_ENTER("spider_param_reset_sql_alloc"); + DBUG_RETURN(THDVAR(thd, use_cond_other_than_pk_for_update)); +} + static int spider_store_last_sts; /* -1 : use table parameter @@ -3421,6 +3445,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(dry_access), MYSQL_SYSVAR(delete_all_rows_type), MYSQL_SYSVAR(bka_table_name_type), + MYSQL_SYSVAR(use_cond_other_than_pk_for_update), MYSQL_SYSVAR(connect_error_interval), #ifndef WITHOUT_SPIDER_BG_SEARCH MYSQL_SYSVAR(table_sts_thread_count), diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index 06df06a3129..e615fc672d4 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -397,6 +397,9 @@ int spider_param_bka_table_name_type( THD *thd, int bka_table_name_type ); +int spider_param_use_cond_other_than_pk_for_update( + THD *thd +); int spider_param_store_last_sts( int store_last_sts ); diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 680618e3087..f72487f034c 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2017 Kentoku Shiba +/* Copyright (C) 2009-2018 Kentoku Shiba 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 diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index ed25e4fcf32..14f80b41108 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -38,7 +38,6 @@ extern handlerton *spider_hton_ptr; extern Time_zone *spd_tz_system; -static const LEX_CSTRING empty_clex_string= {"", 0}; /** Insert a Spider system table row. @@ -155,15 +154,30 @@ TABLE *spider_open_sys_table( #if MYSQL_VERSION_ID < 50500 memset(&tables, 0, sizeof(TABLE_LIST)); - tables.db = (char*)"mysql"; - tables.db_length = sizeof("mysql") - 1; - tables.alias = tables.table_name = (char *) table_name; - tables.table_name_length = table_name_length; + SPIDER_TABLE_LIST_db_str(&tables) = (char*)"mysql"; + SPIDER_TABLE_LIST_db_length(&tables) = sizeof("mysql") - 1; + SPIDER_TABLE_LIST_alias_str(&tables) = + SPIDER_TABLE_LIST_table_name_str(&tables) = (char *) table_name; + SPIDER_TABLE_LIST_table_name_length(&tables) = table_name_length; tables.lock_type = (write ? TL_WRITE : TL_READ); #else - LEX_CSTRING db_name= { "mysql", sizeof("mysql") - 1 }; - LEX_CSTRING tbl_name= { table_name, (size_t) table_name_length }; - tables.init_one_table( &db_name, &tbl_name, 0, (write ? TL_WRITE : TL_READ)); +#ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias + LEX_CSTRING db_name = + { + "mysql", + sizeof("mysql") - 1 + }; + LEX_CSTRING tbl_name = + { + table_name, + (size_t) table_name_length + }; + tables.init_one_table(&db_name, &tbl_name, 0, (write ? TL_WRITE : TL_READ)); +#else + tables.init_one_table( + "mysql", sizeof("mysql") - 1, table_name, table_name_length, table_name, + (write ? TL_WRITE : TL_READ)); +#endif #endif #if MYSQL_VERSION_ID < 50500 @@ -371,14 +385,15 @@ TABLE *spider_sys_open_table( TABLE *table; ulonglong utime_after_lock_backup = thd->utime_after_lock; DBUG_ENTER("spider_sys_open_table"); - thd->reset_n_backup_open_tables_state(open_tables_backup); + if (open_tables_backup) + thd->reset_n_backup_open_tables_state(open_tables_backup); if ((table = open_ltable(thd, tables, tables->lock_type, MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT | MYSQL_LOCK_LOG_TABLE ))) { table->use_all_columns(); table->s->no_replicate = 1; - } else + } else if (open_tables_backup) thd->restore_backup_open_tables_state(open_tables_backup); thd->utime_after_lock = utime_after_lock_backup; DBUG_RETURN(table); @@ -504,7 +519,7 @@ int spider_get_sys_table_by_idx( ) { int error_num; uint key_length; - KEY *key_info = table->key_info; + KEY *key_info = table->key_info + idx; DBUG_ENTER("spider_get_sys_table_by_idx"); if ((error_num = spider_sys_index_init(table, idx, FALSE))) DBUG_RETURN(error_num); @@ -595,6 +610,28 @@ int spider_sys_index_first( DBUG_RETURN(0); } +int spider_sys_index_last( + TABLE *table, + const int idx +) { + int error_num; + DBUG_ENTER("spider_sys_index_last"); + if ((error_num = spider_sys_index_init(table, idx, FALSE))) + DBUG_RETURN(error_num); + + if ( +#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 + (error_num = table->file->ha_index_last(table->record[0])) +#else + (error_num = table->file->index_last(table->record[0])) +#endif + ) { + spider_sys_index_end(table); + DBUG_RETURN(error_num); + } + DBUG_RETURN(0); +} + int spider_sys_index_next( TABLE *table ) { @@ -1262,7 +1299,9 @@ int spider_insert_xa( spider_store_xa_bqual_length(table, xid); spider_store_xa_status(table, status); if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } else { my_message(ER_SPIDER_XA_EXISTS_NUM, ER_SPIDER_XA_EXISTS_STR, MYF(0)); DBUG_RETURN(ER_SPIDER_XA_EXISTS_NUM); @@ -1293,7 +1332,9 @@ int spider_insert_xa_member( table->use_all_columns(); spider_store_xa_member_info(table, xid, conn); if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } else { my_message(ER_SPIDER_XA_MEMBER_EXISTS_NUM, ER_SPIDER_XA_MEMBER_EXISTS_STR, MYF(0)); @@ -1324,7 +1365,9 @@ int spider_insert_tables( share->alter_table.tmp_link_statuses[roop_count] : SPIDER_LINK_STATUS_OK); if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } DBUG_RETURN(0); @@ -1335,9 +1378,8 @@ int spider_insert_sys_table( ) { int error_num; DBUG_ENTER("spider_insert_sys_table"); - if ((error_num = spider_write_sys_table_row(table))) - DBUG_RETURN(error_num); - DBUG_RETURN(0); + error_num = spider_write_sys_table_row(table); + DBUG_RETURN(error_num); } int spider_insert_or_update_table_sts( @@ -1378,7 +1420,9 @@ int spider_insert_or_update_table_sts( DBUG_RETURN(error_num); } if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } else { if ((error_num = spider_update_sys_table_row(table, FALSE))) { @@ -1415,7 +1459,9 @@ int spider_insert_or_update_table_crd( DBUG_RETURN(error_num); } if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } else { if ((error_num = spider_update_sys_table_row(table, FALSE))) { @@ -1444,7 +1490,9 @@ int spider_log_tables_link_failed( table->timestamp_field->set_time(); #endif if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } DBUG_RETURN(0); } @@ -1479,7 +1527,9 @@ int spider_log_xa_failed( table->timestamp_field->set_time(); #endif if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } DBUG_RETURN(0); } @@ -1509,7 +1559,9 @@ int spider_update_xa( table->use_all_columns(); spider_store_xa_status(table, status); if ((error_num = spider_update_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } DBUG_RETURN(0); @@ -1543,7 +1595,9 @@ int spider_update_tables_name( table->use_all_columns(); spider_store_tables_name(table, to, strlen(to)); if ((error_num = spider_update_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } roop_count++; } @@ -1588,7 +1642,9 @@ int spider_update_tables_priority( alter_table->tmp_link_statuses[roop_count] : SPIDER_LINK_STATUS_OK); if ((error_num = spider_write_sys_table_row(table))) + { DBUG_RETURN(error_num); + } roop_count++; } while (roop_count < (int) alter_table->all_link_count); DBUG_RETURN(0); @@ -1605,7 +1661,9 @@ int spider_update_tables_priority( spider_store_tables_link_status(table, alter_table->tmp_link_statuses[roop_count]); if ((error_num = spider_update_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } } while (TRUE) @@ -1624,7 +1682,9 @@ int spider_update_tables_priority( DBUG_RETURN(error_num); } if ((error_num = spider_delete_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } roop_count++; } @@ -1661,12 +1721,23 @@ int spider_update_tables_link_status( table->use_all_columns(); spider_store_tables_link_status(table, link_status); if ((error_num = spider_update_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } DBUG_RETURN(0); } +int spider_update_sys_table( + TABLE *table +) { + int error_num; + DBUG_ENTER("spider_update_sys_table"); + error_num = spider_update_sys_table_row(table); + DBUG_RETURN(error_num); +} + int spider_delete_xa( TABLE *table, XID *xid @@ -1689,7 +1760,9 @@ int spider_delete_xa( DBUG_RETURN(ER_SPIDER_XA_NOT_EXISTS_NUM); } else { if ((error_num = spider_delete_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } DBUG_RETURN(0); @@ -1752,7 +1825,9 @@ int spider_delete_tables( break; else { if ((error_num = spider_delete_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } roop_count++; } @@ -1783,7 +1858,9 @@ int spider_delete_table_sts( DBUG_RETURN(0); } else { if ((error_num = spider_delete_sys_table_row(table))) + { DBUG_RETURN(error_num); + } } DBUG_RETURN(0); @@ -2386,7 +2463,7 @@ void spider_get_sys_table_sts_info( *index_file_length = (ulonglong) table->field[4]->val_int(); *records = (ha_rows) table->field[5]->val_int(); *mean_rec_length = (ulong) table->field[6]->val_int(); - table->field[7]->get_date(&mysql_time, 0); + table->field[7]->get_date(&mysql_time, SPIDER_date_mode_t(0)); #ifdef MARIADB_BASE_VERSION *check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -2394,7 +2471,7 @@ void spider_get_sys_table_sts_info( *check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_my_bool); #endif - table->field[8]->get_date(&mysql_time, 0); + table->field[8]->get_date(&mysql_time, SPIDER_date_mode_t(0)); #ifdef MARIADB_BASE_VERSION *create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -2402,7 +2479,7 @@ void spider_get_sys_table_sts_info( *create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_my_bool); #endif - table->field[9]->get_date(&mysql_time, 0); + table->field[9]->get_date(&mysql_time, SPIDER_date_mode_t(0)); #ifdef MARIADB_BASE_VERSION *update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); @@ -3207,27 +3284,37 @@ error: DBUG_RETURN(error_num); } +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor +TABLE *spider_mk_sys_tmp_table( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const LEX_CSTRING *field_name, + CHARSET_INFO *cs +) +#else TABLE *spider_mk_sys_tmp_table( THD *thd, TABLE *table, TMP_TABLE_PARAM *tmp_tbl_prm, const char *field_name, CHARSET_INFO *cs -) { +) +#endif +{ Field_blob *field; Item_field *i_field; List i_list; TABLE *tmp_table; - LEX_CSTRING name= { field_name, strlen(field_name) }; DBUG_ENTER("spider_mk_sys_tmp_table"); #ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field = new (thd->mem_root) Field_blob( - (uint32) 4294967295U, FALSE, &name, cs, TRUE))) + 4294967295U, FALSE, field_name, cs, TRUE))) goto error_alloc_field; #else if (!(field = new Field_blob( - 4294967295U, FALSE, &name, cs, TRUE))) + 4294967295U, FALSE, field_name, cs, TRUE))) goto error_alloc_field; #endif field->init(table); @@ -3245,7 +3332,7 @@ TABLE *spider_mk_sys_tmp_table( if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, - HA_POS_ERROR, &empty_clex_string))) + HA_POS_ERROR, &SPIDER_empty_string))) goto error_create_tmp_table; DBUG_RETURN(tmp_table); @@ -3270,6 +3357,17 @@ void spider_rm_sys_tmp_table( DBUG_VOID_RETURN; } +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor +TABLE *spider_mk_sys_tmp_table_for_result( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const LEX_CSTRING *field_name1, + const LEX_CSTRING *field_name2, + const LEX_CSTRING *field_name3, + CHARSET_INFO *cs +) +#else TABLE *spider_mk_sys_tmp_table_for_result( THD *thd, TABLE *table, @@ -3278,23 +3376,22 @@ TABLE *spider_mk_sys_tmp_table_for_result( const char *field_name2, const char *field_name3, CHARSET_INFO *cs -) { +) +#endif +{ Field_blob *field1, *field2, *field3; Item_field *i_field1, *i_field2, *i_field3; List i_list; TABLE *tmp_table; - LEX_CSTRING name1= { field_name1, strlen(field_name1) }; - LEX_CSTRING name2= { field_name2, strlen(field_name2) }; - LEX_CSTRING name3= { field_name3, strlen(field_name3) }; DBUG_ENTER("spider_mk_sys_tmp_table_for_result"); #ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field1 = new (thd->mem_root) Field_blob( - (uint32) 4294967295U, FALSE, &name1, cs, TRUE))) + 4294967295U, FALSE, field_name1, cs, TRUE))) goto error_alloc_field1; #else if (!(field1 = new Field_blob( - 4294967295U, FALSE, &name1, cs, TRUE))) + 4294967295U, FALSE, field_name1, cs, TRUE))) goto error_alloc_field1; #endif field1->init(table); @@ -3312,11 +3409,11 @@ TABLE *spider_mk_sys_tmp_table_for_result( #ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field2 = new (thd->mem_root) Field_blob( - 4294967295U, FALSE, &name2, cs, TRUE))) + 4294967295U, FALSE, field_name2, cs, TRUE))) goto error_alloc_field2; #else if (!(field2 = new Field_blob( - 4294967295U, FALSE, &name2, cs, TRUE))) + 4294967295U, FALSE, field_name2, cs, TRUE))) goto error_alloc_field2; #endif field2->init(table); @@ -3334,7 +3431,7 @@ TABLE *spider_mk_sys_tmp_table_for_result( #ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR if (!(field3 = new (thd->mem_root) Field_blob( - 4294967295U, FALSE, &name3, cs, TRUE))) + 4294967295U, FALSE, field_name3, cs, TRUE))) goto error_alloc_field3; #else if (!(field3 = new Field_blob( @@ -3356,7 +3453,7 @@ TABLE *spider_mk_sys_tmp_table_for_result( if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, - HA_POS_ERROR, &empty_clex_string))) + HA_POS_ERROR, &SPIDER_empty_string))) goto error_create_tmp_table; DBUG_RETURN(tmp_table); diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h index 009ef2ac8ca..857109edb38 100644 --- a/storage/spider/spd_sys_table.h +++ b/storage/spider/spd_sys_table.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2016 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -173,6 +173,11 @@ int spider_sys_index_first( const int idx ); +int spider_sys_index_last( + TABLE *table, + const int idx +); + int spider_sys_index_next( TABLE *table ); @@ -386,6 +391,10 @@ int spider_update_tables_link_status( long link_status ); +int spider_update_sys_table( + TABLE *table +); + int spider_delete_xa( TABLE *table, XID *xid @@ -618,6 +627,15 @@ int spider_sys_replace( bool *modified_non_trans_table ); +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor +TABLE *spider_mk_sys_tmp_table( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const LEX_CSTRING *field_name, + CHARSET_INFO *cs +); +#else TABLE *spider_mk_sys_tmp_table( THD *thd, TABLE *table, @@ -625,6 +643,7 @@ TABLE *spider_mk_sys_tmp_table( const char *field_name, CHARSET_INFO *cs ); +#endif void spider_rm_sys_tmp_table( THD *thd, @@ -632,6 +651,17 @@ void spider_rm_sys_tmp_table( TMP_TABLE_PARAM *tmp_tbl_prm ); +#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor +TABLE *spider_mk_sys_tmp_table_for_result( + THD *thd, + TABLE *table, + TMP_TABLE_PARAM *tmp_tbl_prm, + const LEX_CSTRING *field_name1, + const LEX_CSTRING *field_name2, + const LEX_CSTRING *field_name3, + CHARSET_INFO *cs +); +#else TABLE *spider_mk_sys_tmp_table_for_result( THD *thd, TABLE *table, @@ -641,6 +671,7 @@ TABLE *spider_mk_sys_tmp_table_for_result( const char *field_name3, CHARSET_INFO *cs ); +#endif void spider_rm_sys_tmp_table_for_result( THD *thd, diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 1940dd5aad9..1f220b193e5 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -1721,8 +1721,7 @@ int st_spider_param_string_parse::print_param_error() if ((share->param_name = spider_get_string_between_quote( \ start_ptr, TRUE, &connect_string_parse))) \ share->SPIDER_PARAM_STR_LEN(param_name) = strlen(share->param_name); \ - else \ - { \ + else { \ error_num = connect_string_parse.print_param_error(); \ goto error; \ } \ @@ -5219,15 +5218,20 @@ SPIDER_SHARE *spider_get_share( } if (!share->link_status_init) { - if ( - ( - table_share->tmp_table == NO_TMP_TABLE && - sql_command != SQLCOM_DROP_TABLE && - sql_command != SQLCOM_SHOW_CREATE - ) || - /* for alter change link status */ - sql_command == SQLCOM_ALTER_TABLE - ) { + /* + The link statuses need to be refreshed from the spider_tables table + if the operation: + - Is not a DROP TABLE on a permanent table; or + - Is an ALTER TABLE. + + Note that SHOW CREATE TABLE is not excluded, because the commands + that follow it require up-to-date link statuses. + */ + if ((table_share->tmp_table == NO_TMP_TABLE && + sql_command != SQLCOM_DROP_TABLE) || + /* for alter change link status */ + sql_command == SQLCOM_ALTER_TABLE) + { SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); init_mem_root = TRUE; if ( @@ -8965,7 +8969,9 @@ bool spider_check_direct_order_limit( int spider_set_direct_limit_offset( ha_spider *spider ) { +#ifndef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON THD *thd = spider->trx->thd; +#endif st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -9037,7 +9043,11 @@ int spider_set_direct_limit_offset( DBUG_RETURN(FALSE); // ignore condition like 1=1 +#ifdef SPIDER_has_Item_with_subquery if (select_lex->where && select_lex->where->with_subquery()) +#else + if (select_lex->where && select_lex->where->with_subselect) +#endif DBUG_RETURN(FALSE); if ( @@ -9049,7 +9059,7 @@ int spider_set_direct_limit_offset( DBUG_RETURN(FALSE); // must not be derived table - if (&thd->lex->select_lex != select_lex) + if (SPIDER_get_linkage(select_lex) == DERIVED_TABLE_TYPE) DBUG_RETURN(FALSE); spider->direct_select_offset = offset_limit; @@ -9491,7 +9501,8 @@ int spider_discover_table_structure( uint collatelen = strlen(table_charset->name); if (str.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_DEFAULT_CHARSET_LEN + csnamelen + SPIDER_SQL_COLLATE_LEN + collatelen + - SPIDER_SQL_CONNECTION_LEN + SPIDER_SQL_VALUE_QUOTE_LEN + SPIDER_SQL_CONNECTION_LEN + SPIDER_SQL_VALUE_QUOTE_LEN + + (share->comment.length * 2) )) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -9504,7 +9515,8 @@ int spider_discover_table_structure( str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); str.append_escape_string(share->comment.str, share->comment.length); if (str.reserve(SPIDER_SQL_CONNECTION_LEN + - (SPIDER_SQL_VALUE_QUOTE_LEN * 2))) + (SPIDER_SQL_VALUE_QUOTE_LEN * 2) + + (share->connect_string.length * 2))) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index e09c7fa6c45..565665dc6f7 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2017 Kentoku Shiba +/* Copyright (C) 2008-2018 Kentoku Shiba 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 @@ -26,7 +26,6 @@ #include "sql_class.h" #include "sql_partition.h" #include "records.h" -#include "tztime.h" #endif #include "spd_err.h" #include "spd_param.h" @@ -1648,9 +1647,7 @@ int spider_check_and_set_sql_log_off( if (internal_sql_log_off) { spider_conn_queue_sql_log_off(conn, TRUE); - } - else - { + } else { spider_conn_queue_sql_log_off(conn, FALSE); } } @@ -2764,7 +2761,8 @@ int spider_initinal_xa_recover( FALSE, FALSE); } SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); - while ((!(read_record->read_record())) && cnt < (int) len) + while ((!(read_record->SPIDER_read_record_read_record(read_record))) && + cnt < (int) len) { spider_get_sys_xid(table_xa, &xid_list[cnt], &mem_root); cnt++; @@ -2813,7 +2811,7 @@ int spider_internal_xa_commit_by_xid( SPIDER_TRX *trx, XID* xid ) { - TABLE *table_xa, *table_xa_member= 0; + TABLE *table_xa, *table_xa_member = 0; int error_num; char xa_key[MAX_KEY_LENGTH]; char xa_member_key[MAX_KEY_LENGTH]; @@ -3048,7 +3046,7 @@ int spider_internal_xa_rollback_by_xid( SPIDER_TRX *trx, XID* xid ) { - TABLE *table_xa, *table_xa_member= 0; + TABLE *table_xa, *table_xa_member = 0; int error_num; char xa_key[MAX_KEY_LENGTH]; char xa_member_key[MAX_KEY_LENGTH]; From 3cb7c5f27bbd267e3efd69b1b312711754261801 Mon Sep 17 00:00:00 2001 From: Kentoku Date: Tue, 20 Nov 2018 05:43:49 +0900 Subject: [PATCH 10/22] MDEV-16279 Spider crashes on CHECKSUM TABLE with spider_quick_mode=3 The fields of the temporary table were not created in create_tmp_table function. Because item->const_item() was true. But the temporary tables that is created by Spider are always used all columns. So Spider should call create_tmp_table function with TMP_TABLE_ALL_COLUMNS flag. --- ...hecksum_table_with_quick_mode_3_deinit.inc | 14 ++ .../checksum_table_with_quick_mode_3_init.inc | 29 ++++ .../spider/mysql-test/spider/bugfix/my.cnf | 2 + .../mysql-test/spider/bugfix/my_1_1.cnf | 44 ++++++ .../mysql-test/spider/bugfix/my_2_1.cnf | 56 ++++++++ .../mysql-test/spider/bugfix/my_2_2.cnf | 38 ++++++ .../mysql-test/spider/bugfix/my_2_3.cnf | 8 ++ .../mysql-test/spider/bugfix/my_3_1.cnf | 11 ++ .../mysql-test/spider/bugfix/my_3_2.cnf | 9 ++ .../mysql-test/spider/bugfix/my_3_3.cnf | 9 ++ .../mysql-test/spider/bugfix/my_4_1.cnf | 9 ++ .../r/checksum_table_with_quick_mode_3.result | 100 ++++++++++++++ .../spider/mysql-test/spider/bugfix/suite.opt | 1 + .../spider/mysql-test/spider/bugfix/suite.pm | 12 ++ .../t/checksum_table_with_quick_mode_3.cnf | 3 + .../t/checksum_table_with_quick_mode_3.test | 72 ++++++++++ ...hecksum_table_with_quick_mode_3_deinit.inc | 16 +++ .../checksum_table_with_quick_mode_3_init.inc | 33 +++++ .../r/checksum_table_with_quick_mode_3.result | 104 +++++++++++++++ .../t/checksum_table_with_quick_mode_3.test | 126 ++++++++++++++++++ storage/spider/spd_sys_table.cc | 6 +- 21 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/my.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_1_1.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_2_1.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_2_2.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_2_3.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_3_1.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_3_2.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_3_3.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/my_4_1.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result create mode 100644 storage/spider/mysql-test/spider/bugfix/suite.opt create mode 100644 storage/spider/mysql-test/spider/bugfix/suite.pm create mode 100644 storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test create mode 100644 storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc create mode 100644 storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result create mode 100644 storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_deinit.inc new file mode 100644 index 00000000000..47f6df9437e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_deinit.inc @@ -0,0 +1,14 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc new file mode 100644 index 00000000000..bf2d9163b9a --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc @@ -0,0 +1,29 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; diff --git a/storage/spider/mysql-test/spider/bugfix/my.cnf b/storage/spider/mysql-test/spider/bugfix/my.cnf new file mode 100644 index 00000000000..b7f76a630cc --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my.cnf @@ -0,0 +1,2 @@ +!include include/default_mysqld.cnf +!include my_1_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/my_1_1.cnf b/storage/spider/mysql-test/spider/bugfix/my_1_1.cnf new file mode 100644 index 00000000000..5f17295d895 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_1_1.cnf @@ -0,0 +1,44 @@ +[mysqld.1.1] +log-bin= master-bin +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[ENV] +USE_GEOMETRY_TEST= 1 +USE_FULLTEXT_TEST= 1 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 1 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci + +STR_SEMICOLON= ; + +#The followings are set in include/init_xxx.inc files +# MASTER_1_COMMENT_2_1 +# MASTER_1_COMMENT2_2_1 +# MASTER_1_COMMENT3_2_1 +# MASTER_1_COMMENT4_2_1 +# MASTER_1_COMMENT5_2_1 +# MASTER_1_COMMENT_P_2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/my_2_1.cnf b/storage/spider/mysql-test/spider/bugfix/my_2_1.cnf new file mode 100644 index 00000000000..24161645607 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_2_1.cnf @@ -0,0 +1,56 @@ +[mysqld.2.1] +loose_handlersocket_port= 20002 +loose_handlersocket_port_wr= 20003 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[ENV] +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.2.1.port +CHILD2_1_HSRPORT= 20002 +CHILD2_1_HSWPORT= 20003 +CHILD2_1_MYSOCK= @mysqld.2.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_1_FT_MYPORT= @mysqld.2.1.port +CHILD2_1_FT_MYSOCK= @mysqld.2.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.2.1.port +CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 + +#The followings are set in include/init_xxx.inc files +# CHILD2_1_DROP_TABLES +# CHILD2_1_CREATE_TABLES +# CHILD2_1_SELECT_TABLES +# CHILD2_1_DROP_TABLES2 +# CHILD2_1_CREATE_TABLES2 +# CHILD2_1_SELECT_TABLES2 +# CHILD2_1_DROP_TABLES3 +# CHILD2_1_CREATE_TABLES3 +# CHILD2_1_SELECT_TABLES3 +# CHILD2_1_DROP_TABLES4 +# CHILD2_1_CREATE_TABLES4 +# CHILD2_1_SELECT_TABLES4 +# CHILD2_1_DROP_TABLES5 +# CHILD2_1_CREATE_TABLES5 +# CHILD2_1_SELECT_TABLES5 +# CHILD2_1_DROP_TABLES6 +# CHILD2_1_CREATE_TABLES6 +# CHILD2_1_SELECT_TABLES6 diff --git a/storage/spider/mysql-test/spider/bugfix/my_2_2.cnf b/storage/spider/mysql-test/spider/bugfix/my_2_2.cnf new file mode 100644 index 00000000000..2d3c2a89a7d --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_2_2.cnf @@ -0,0 +1,38 @@ +[mysqld.2.2] +loose_handlersocket_port= 20004 +loose_handlersocket_port_wr= 20005 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[ENV] +CHILD2_2_MYPORT= @mysqld.2.2.port +CHILD2_2_HSRPORT= 20004 +CHILD2_2_HSWPORT= 20005 +CHILD2_2_MYSOCK= @mysqld.2.2.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.2.2.port +CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.2.2.port +CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 + +#The followings are set in include/init_xxx.inc files +# CHILD2_2_DROP_TABLES +# CHILD2_2_CREATE_TABLES +# CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/bugfix/my_2_3.cnf b/storage/spider/mysql-test/spider/bugfix/my_2_3.cnf new file mode 100644 index 00000000000..024da651e0c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_2_3.cnf @@ -0,0 +1,8 @@ +[mysqld.2.3] + +[ENV] +CHILD2_3_MYPORT= @mysqld.2.3.port +CHILD2_3_MYSOCK= @mysqld.2.3.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/my_3_1.cnf b/storage/spider/mysql-test/spider/bugfix/my_3_1.cnf new file mode 100644 index 00000000000..fad21607789 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_3_1.cnf @@ -0,0 +1,11 @@ +[mysqld.3.1] +loose_partition= 1 + +[ENV] +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/my_3_2.cnf b/storage/spider/mysql-test/spider/bugfix/my_3_2.cnf new file mode 100644 index 00000000000..6f027b6f525 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_3_2.cnf @@ -0,0 +1,9 @@ +[mysqld.3.2] +loose_partition= 1 + +[ENV] +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/my_3_3.cnf b/storage/spider/mysql-test/spider/bugfix/my_3_3.cnf new file mode 100644 index 00000000000..fbb33694738 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_3_3.cnf @@ -0,0 +1,9 @@ +[mysqld.3.3] +loose_partition= 1 + +[ENV] +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/my_4_1.cnf b/storage/spider/mysql-test/spider/bugfix/my_4_1.cnf new file mode 100644 index 00000000000..d1812a48b68 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/my_4_1.cnf @@ -0,0 +1,9 @@ +[mysqld.4.1] +loose_partition= 1 + +[ENV] +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result b/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result new file mode 100644 index 00000000000..eae4895411e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result @@ -0,0 +1,100 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; + +this test is for MDEV-16279 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +CHECKSUM TABLE tbl_a EXTENDED; +Table Checksum +auto_test_local.tbl_a 1061386331 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/suite.opt b/storage/spider/mysql-test/spider/bugfix/suite.opt new file mode 100644 index 00000000000..672a3b37d4f --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/suite.opt @@ -0,0 +1 @@ +--loose-innodb --loose-skip-performance-schema diff --git a/storage/spider/mysql-test/spider/bugfix/suite.pm b/storage/spider/mysql-test/spider/bugfix/suite.pm new file mode 100644 index 00000000000..f106147deb6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/suite.pm @@ -0,0 +1,12 @@ +package My::Suite::Spider; + +@ISA = qw(My::Suite); + +return "No Spider engine" unless $ENV{HA_SPIDER_SO}; +return "Not run for embedded server" if $::opt_embedded_server; +return "Test needs --big-test" unless $::opt_big_test; + +sub is_default { 1 } + +bless { }; + diff --git a/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.cnf b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.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/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test new file mode 100644 index 00000000000..5dc4a88c842 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test @@ -0,0 +1,72 @@ +--source ../include/checksum_table_with_quick_mode_3_init.inc +--echo +--echo this test is for MDEV-16279 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +CHECKSUM TABLE tbl_a EXTENDED; + +--connection child2_1 +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/checksum_table_with_quick_mode_3_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_deinit.inc b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_deinit.inc new file mode 100644 index 00000000000..d551f5a4af3 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_deinit.inc @@ -0,0 +1,16 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc new file mode 100644 index 00000000000..9ec61a1cb77 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc @@ -0,0 +1,33 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; diff --git a/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result b/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result new file mode 100644 index 00000000000..ee8e1f056f3 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result @@ -0,0 +1,104 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +CHECKSUM TABLE tbl_a EXTENDED; +Table Checksum +auto_test_local.tbl_a 1061386331 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test new file mode 100644 index 00000000000..d108fda7e41 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test @@ -0,0 +1,126 @@ +--source ../include/checksum_table_with_quick_mode_3_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_CREATE_TABLES; + } + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +--echo +--echo select test 1 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +CHECKSUM TABLE tbl_a EXTENDED; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/checksum_table_with_quick_mode_3_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index 14f80b41108..cd1c56a077e 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -3331,7 +3331,8 @@ TABLE *spider_mk_sys_tmp_table( goto error_push_item; if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, - i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, + i_list, (ORDER*) NULL, FALSE, FALSE, + (TMP_TABLE_FORCE_MYISAM | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, &SPIDER_empty_string))) goto error_create_tmp_table; DBUG_RETURN(tmp_table); @@ -3452,7 +3453,8 @@ TABLE *spider_mk_sys_tmp_table_for_result( goto error_push_item3; if (!(tmp_table = create_tmp_table(thd, tmp_tbl_prm, - i_list, (ORDER*) NULL, FALSE, FALSE, TMP_TABLE_FORCE_MYISAM, + i_list, (ORDER*) NULL, FALSE, FALSE, + (TMP_TABLE_FORCE_MYISAM | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, &SPIDER_empty_string))) goto error_create_tmp_table; DBUG_RETURN(tmp_table); From bef6b197fc2555be357642ec81851d240eec5aa7 Mon Sep 17 00:00:00 2001 From: Kentoku Date: Fri, 30 Nov 2018 03:17:08 +0900 Subject: [PATCH 11/22] MDEV-16520 Out-Of-Memory running big aggregate query on Spider Engine Change default value of the followings quick_mode 0 -> 3 quick_page_size 100 -> 1024 Add the following parameter for limiting result page size by byte - quick_page_byte(qpb) Number of bytes in a page when acquisition one by one. When quick_mode is 1 or 2, Spider stores at least 1 record even if quick_page_byte is smaller than 1 record. When quick_mode is 3, quick_page_byte is used for judging using temporary table. That is given to priority when server parameter spider_quick_page_byte is set. The default value is 10485760 Fix "out of sync" issue at using quick_mode = 1 or 2 --- storage/spider/ha_spider.cc | 2 + storage/spider/hs_client/hstcpcli.cpp | 25 +- storage/spider/hs_client/hstcpcli.hpp | 3 + .../spider/include/quick_mode_0_deinit.inc | 21 + .../spider/include/quick_mode_0_init.inc | 55 ++ .../spider/include/quick_mode_1_deinit.inc | 21 + .../spider/include/quick_mode_1_init.inc | 55 ++ .../spider/include/quick_mode_2_deinit.inc | 21 + .../spider/include/quick_mode_2_init.inc | 55 ++ .../spider/include/quick_mode_3_deinit.inc | 21 + .../spider/include/quick_mode_3_init.inc | 55 ++ .../mysql-test/spider/r/quick_mode_0.result | 515 ++++++++++++++++++ .../mysql-test/spider/r/quick_mode_1.result | 515 ++++++++++++++++++ .../mysql-test/spider/r/quick_mode_2.result | 515 ++++++++++++++++++ .../mysql-test/spider/r/quick_mode_3.result | 515 ++++++++++++++++++ .../mysql-test/spider/t/quick_mode_0.test | 309 +++++++++++ .../mysql-test/spider/t/quick_mode_1.test | 309 +++++++++++ .../mysql-test/spider/t/quick_mode_2.test | 309 +++++++++++ .../mysql-test/spider/t/quick_mode_3.test | 309 +++++++++++ storage/spider/spd_conn.cc | 1 + storage/spider/spd_db_conn.cc | 95 +++- storage/spider/spd_db_conn.h | 4 + storage/spider/spd_db_handlersocket.cc | 20 +- storage/spider/spd_db_handlersocket.h | 2 + storage/spider/spd_db_include.h | 2 + storage/spider/spd_db_mysql.cc | 35 +- storage/spider/spd_db_mysql.h | 2 + storage/spider/spd_db_oracle.cc | 11 + storage/spider/spd_db_oracle.h | 2 + storage/spider/spd_include.h | 1 + storage/spider/spd_param.cc | 26 + storage/spider/spd_param.h | 4 + storage/spider/spd_table.cc | 11 +- 33 files changed, 3816 insertions(+), 30 deletions(-) create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_0_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_0_init.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_1_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_1_init.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_2_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_2_init.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_3_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/quick_mode_3_init.inc create mode 100644 storage/spider/mysql-test/spider/r/quick_mode_0.result create mode 100644 storage/spider/mysql-test/spider/r/quick_mode_1.result create mode 100644 storage/spider/mysql-test/spider/r/quick_mode_2.result create mode 100644 storage/spider/mysql-test/spider/r/quick_mode_3.result create mode 100644 storage/spider/mysql-test/spider/t/quick_mode_0.test create mode 100644 storage/spider/mysql-test/spider/t/quick_mode_1.test create mode 100644 storage/spider/mysql-test/spider/t/quick_mode_2.test create mode 100644 storage/spider/mysql-test/spider/t/quick_mode_3.test diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 8471af40289..e60355958bd 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -7378,6 +7378,8 @@ int ha_spider::rnd_init( #endif if (quick_targets[roop_count]) { + spider_db_free_one_quick_result( + (SPIDER_RESULT *) result_list.current); DBUG_ASSERT(quick_targets[roop_count] == conns[roop_count]->quick_target); DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp index 2cb37c7be9d..4c93b5a3a49 100644 --- a/storage/spider/hs_client/hstcpcli.cpp +++ b/storage/spider/hs_client/hstcpcli.cpp @@ -67,6 +67,8 @@ struct hstcpcli : public hstcpcli_i, private noncopyable { virtual int get_result(hstresult& result); virtual const string_ref *get_next_row(); virtual const string_ref *get_next_row_from_result(hstresult& result); + virtual size_t get_row_size(); + virtual size_t get_row_size_from_result(hstresult& result); virtual void response_buf_remove(); virtual int get_error_code(); virtual String& get_error(); @@ -93,6 +95,7 @@ struct hstcpcli : public hstcpcli_i, private noncopyable { string_buffer writebuf; size_t response_end_offset; /* incl newline */ size_t cur_row_offset; + size_t cur_row_size; size_t num_flds; size_t num_req_bufd; /* buffered but not yet sent */ size_t num_req_sent; /* sent but not yet received */ @@ -104,8 +107,9 @@ struct hstcpcli : public hstcpcli_i, private noncopyable { }; hstcpcli::hstcpcli(const socket_args& args) - : sargs(args), response_end_offset(0), cur_row_offset(0), num_flds(0), - num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), error_code(0), errno_buf(0) + : sargs(args), response_end_offset(0), cur_row_offset(0), cur_row_size(0), + num_flds(0), num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), + error_code(0), errno_buf(0) { String err; SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME)); @@ -503,6 +507,7 @@ hstcpcli::response_recv(size_t& num_flds_r) } return set_error(resp_code, e); } + cur_row_size = 0; cur_row_offset = start - readbuf.begin(); DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n", String(readbuf.begin(), readbuf.begin() + response_end_offset) @@ -529,6 +534,7 @@ hstcpcli::get_result(hstresult& result) result.readbuf.space_wrote(response_end_offset); result.response_end_offset = response_end_offset; result.num_flds = num_flds; + result.cur_row_size = cur_row_size; result.cur_row_offset = cur_row_offset; if (result.flds.max_element < num_flds) { @@ -566,6 +572,7 @@ hstcpcli::get_next_row() ((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp); } } + cur_row_size = start - (readbuf.begin() + cur_row_offset); cur_row_offset = start - readbuf.begin(); return (string_ref *) flds.buffer; } @@ -597,10 +604,24 @@ hstcpcli::get_next_row_from_result(hstresult& result) ((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp); } } + result.cur_row_size = + start - (result.readbuf.begin() + result.cur_row_offset); result.cur_row_offset = start - result.readbuf.begin(); return (string_ref *) result.flds.buffer; } +size_t +hstcpcli::get_row_size() +{ + return cur_row_size; +} + +size_t +hstcpcli::get_row_size_from_result(hstresult& result) +{ + return result.cur_row_size; +} + void hstcpcli::response_buf_remove() { diff --git a/storage/spider/hs_client/hstcpcli.hpp b/storage/spider/hs_client/hstcpcli.hpp index d153b19cf9b..6894716e469 100644 --- a/storage/spider/hs_client/hstcpcli.hpp +++ b/storage/spider/hs_client/hstcpcli.hpp @@ -46,6 +46,7 @@ struct hstresult { size_t response_end_offset; size_t num_flds; size_t cur_row_offset; + size_t cur_row_size; DYNAMIC_ARRAY flds; }; @@ -71,6 +72,8 @@ struct hstcpcli_i { virtual int get_result(hstresult& result) = 0; virtual const string_ref *get_next_row() = 0; virtual const string_ref *get_next_row_from_result(hstresult& result) = 0; + virtual size_t get_row_size() = 0; + virtual size_t get_row_size_from_result(hstresult& result) = 0; virtual void response_buf_remove() = 0; virtual int get_error_code() = 0; virtual String& get_error() = 0; diff --git a/storage/spider/mysql-test/spider/include/quick_mode_0_deinit.inc b/storage/spider/mysql-test/spider/include/quick_mode_0_deinit.inc new file mode 100644 index 00000000000..72d09f54316 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_0_deinit.inc @@ -0,0 +1,21 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc new file mode 100644 index 00000000000..92afb3bf10b --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc @@ -0,0 +1,55 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 0; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/include/quick_mode_1_deinit.inc b/storage/spider/mysql-test/spider/include/quick_mode_1_deinit.inc new file mode 100644 index 00000000000..72d09f54316 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_1_deinit.inc @@ -0,0 +1,21 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc new file mode 100644 index 00000000000..cc5a847fdc0 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc @@ -0,0 +1,55 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 1; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/include/quick_mode_2_deinit.inc b/storage/spider/mysql-test/spider/include/quick_mode_2_deinit.inc new file mode 100644 index 00000000000..72d09f54316 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_2_deinit.inc @@ -0,0 +1,21 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc new file mode 100644 index 00000000000..3a16bb1dc63 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc @@ -0,0 +1,55 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 2; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/include/quick_mode_3_deinit.inc b/storage/spider/mysql-test/spider/include/quick_mode_3_deinit.inc new file mode 100644 index 00000000000..72d09f54316 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_3_deinit.inc @@ -0,0 +1,21 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc new file mode 100644 index 00000000000..df7d713c4c7 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc @@ -0,0 +1,55 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/r/quick_mode_0.result b/storage/spider/mysql-test/spider/r/quick_mode_0.result new file mode 100644 index 00000000000..1cf79124b8c --- /dev/null +++ b/storage/spider/mysql-test/spider/r/quick_mode_0.result @@ -0,0 +1,515 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 0; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_DROP_TABLES +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/quick_mode_1.result b/storage/spider/mysql-test/spider/r/quick_mode_1.result new file mode 100644 index 00000000000..1d56cff3e36 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/quick_mode_1.result @@ -0,0 +1,515 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 1; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_DROP_TABLES +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/quick_mode_2.result b/storage/spider/mysql-test/spider/r/quick_mode_2.result new file mode 100644 index 00000000000..5b0cd75af34 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/quick_mode_2.result @@ -0,0 +1,515 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 2; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_DROP_TABLES +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/quick_mode_3.result b/storage/spider/mysql-test/spider/r/quick_mode_3.result new file mode 100644 index 00000000000..4261cde2e36 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/quick_mode_3.result @@ -0,0 +1,515 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote2; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_DROP_TABLES +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/t/quick_mode_0.test b/storage/spider/mysql-test/spider/t/quick_mode_0.test new file mode 100644 index 00000000000..ffb665c0604 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/quick_mode_0.test @@ -0,0 +1,309 @@ +--source ../include/quick_mode_0_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/quick_mode_0_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/quick_mode_1.test b/storage/spider/mysql-test/spider/t/quick_mode_1.test new file mode 100644 index 00000000000..70d61d087e3 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/quick_mode_1.test @@ -0,0 +1,309 @@ +--source ../include/quick_mode_1_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/quick_mode_1_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/quick_mode_2.test b/storage/spider/mysql-test/spider/t/quick_mode_2.test new file mode 100644 index 00000000000..71e7b0338dc --- /dev/null +++ b/storage/spider/mysql-test/spider/t/quick_mode_2.test @@ -0,0 +1,309 @@ +--source ../include/quick_mode_2_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/quick_mode_2_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/t/quick_mode_3.test b/storage/spider/mysql-test/spider/t/quick_mode_3.test new file mode 100644 index 00000000000..000edd4fdff --- /dev/null +++ b/storage/spider/mysql-test/spider/t/quick_mode_3.test @@ -0,0 +1,309 @@ +--source ../include/quick_mode_3_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote2; + CREATE DATABASE auto_test_remote2; + USE auto_test_remote2; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_2_DROP_TABLES; + echo CHILD2_2_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_2_DROP_TABLES; + --enable_warnings + eval $CHILD2_2_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +DROP TABLE IF EXISTS tbl_b; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + --connection child2_2 + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + --connection child2_2 + if ($USE_GENERAL_LOG) + { + --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ + eval $CHILD2_2_SELECT_ARGUMENT1; + } + eval $CHILD2_2_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } + --connection child2_2 + DROP DATABASE IF EXISTS auto_test_remote2; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/quick_mode_3_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index d48ec1f2285..ba59acd64bc 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2087,6 +2087,7 @@ void spider_bg_all_conn_break( #endif if (spider->quick_targets[roop_count]) { + spider_db_free_one_quick_result((SPIDER_RESULT *) result_list->current); DBUG_ASSERT(spider->quick_targets[roop_count] == conn->quick_target); DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn)); conn->quick_target = NULL; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 1e117b68728..c2cd4beccdb 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -3473,6 +3473,22 @@ void spider_db_free_one_result( DBUG_VOID_RETURN; } +void spider_db_free_one_quick_result( + SPIDER_RESULT *result +) { + DBUG_ENTER("spider_db_free_one_quick_result"); + if (result && result->result) + { + result->result->free_result(); + if (!result->result_tmp_tbl) + { + delete result->result; + result->result = NULL; + } + } + DBUG_VOID_RETURN; +} + int spider_db_free_result( ha_spider *spider, bool final @@ -3999,11 +4015,22 @@ int spider_db_store_result( SPIDER_DB_ROW *tmp_row; uint field_count = current->result->num_fields(); SPIDER_POSITION *position; - longlong page_size = - !result_list->quick_page_size || - result_list->limit_num < result_list->quick_page_size ? - result_list->limit_num : result_list->quick_page_size; + longlong page_size; int roop_count = 0; + if (!result_list->quick_page_size) + { + if (result_list->quick_mode == 3) + { + page_size = 0; + } else { + result_list->quick_page_size = result_list->limit_num; + page_size = result_list->limit_num; + } + } else { + page_size = + result_list->limit_num < result_list->quick_page_size ? + result_list->limit_num : result_list->quick_page_size; + } current->field_count = field_count; if (!(position = (SPIDER_POSITION *) spider_bulk_malloc(spider_current_trx, 7, MYF(MY_WME | MY_ZEROFILL), @@ -4015,22 +4042,56 @@ int spider_db_store_result( current->pos_page_size = (int) page_size; current->first_position = position; current->tmp_tbl_row = tmp_row; - do { - if (!(position->row = row->clone())) + if (result_list->quick_mode == 3) + { + while (page_size > roop_count && row) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (result_list->quick_page_byte < row->get_byte_size()) + { + current->pos_page_size = roop_count; + page_size = roop_count; + result_list->quick_page_size = roop_count; + result_list->quick_page_byte = 0; + break; + } else { + result_list->quick_page_byte -= row->get_byte_size(); + } + if (!(position->row = row->clone())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + position++; + roop_count++; + row = current->result->fetch_row(); } - position++; - roop_count++; - } while ( - page_size > roop_count && - (row = current->result->fetch_row()) - ); + } else { + do { + if (!(position->row = row->clone())) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } + position++; + roop_count++; + if (result_list->quick_page_byte < row->get_byte_size()) + { + current->pos_page_size = roop_count; + page_size = roop_count; + result_list->quick_page_size = roop_count; + result_list->quick_page_byte = 0; + break; + } else { + result_list->quick_page_byte -= row->get_byte_size(); + } + } while ( + page_size > roop_count && + (row = current->result->fetch_row()) + ); + } if ( result_list->quick_mode == 3 && page_size == roop_count && result_list->limit_num > roop_count && - (row = current->result->fetch_row()) + row ) { THD *thd = current_thd; char buf[MAX_FIELD_WIDTH]; @@ -4076,7 +4137,11 @@ int spider_db_store_result( result_list->record_num += roop_count; if ( result_list->internal_limit <= result_list->record_num || - page_size > roop_count + page_size > roop_count || + ( + result_list->quick_mode == 3 && + result_list->limit_num > roop_count + ) ) { DBUG_PRINT("info",("spider set finish_flg point 4")); DBUG_PRINT("info",("spider current->finish_flg = TRUE")); diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index 6ff35b794cd..bf09d672685 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -579,6 +579,10 @@ void spider_db_free_one_result( SPIDER_RESULT *result ); +void spider_db_free_one_quick_result( + SPIDER_RESULT *result +); + int spider_db_free_result( ha_spider *spider, bool final diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc index 412450b96f8..4aebc7811b4 100644 --- a/storage/spider/spd_db_handlersocket.cc +++ b/storage/spider/spd_db_handlersocket.cc @@ -359,7 +359,7 @@ spider_string *spider_db_hs_str_buffer::add( spider_db_handlersocket_row::spider_db_handlersocket_row() : spider_db_row(spider_dbton_handlersocket.dbton_id), - hs_row(NULL), field_count(0), cloned(FALSE) + hs_row(NULL), field_count(0), row_size(0), cloned(FALSE) { DBUG_ENTER("spider_db_handlersocket_row::spider_db_handlersocket_row"); DBUG_PRINT("info",("spider this=%p", this)); @@ -497,18 +497,13 @@ SPIDER_DB_ROW *spider_db_handlersocket_row::clone() { spider_db_handlersocket_row *clone_row; char *tmp_char; - uint row_size, i; + uint i; DBUG_ENTER("spider_db_handlersocket_row::clone"); DBUG_PRINT("info",("spider this=%p", this)); if (!(clone_row = new spider_db_handlersocket_row())) { DBUG_RETURN(NULL); } - row_size = 0; - for (i = 0; i < field_count; i++) - { - row_size += hs_row_first[i].size(); - } if (!spider_bulk_malloc(spider_current_trx, 169, MYF(MY_WME), &clone_row->hs_row, sizeof(SPIDER_HS_STRING_REF) * field_count, &tmp_char, row_size, @@ -525,6 +520,7 @@ SPIDER_DB_ROW *spider_db_handlersocket_row::clone() } clone_row->hs_row_first = clone_row->hs_row; clone_row->cloned = TRUE;; + clone_row->row_size = row_size;; DBUG_RETURN(NULL); } @@ -560,6 +556,13 @@ int spider_db_handlersocket_row::store_to_tmp_table( DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); } +uint spider_db_handlersocket_row::get_byte_size() +{ + DBUG_ENTER("spider_db_handlersocket_row::get_byte_size"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(row_size); +} + spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer( ) : spider_db_result_buffer() @@ -676,6 +679,7 @@ SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row() } row.field_count = field_count; row.hs_row_first = row.hs_row; + row.row_size = (*hs_conn_p)->get_row_size(); DBUG_RETURN((SPIDER_DB_ROW *) &row); } @@ -694,6 +698,7 @@ SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_result_buffer( } row.field_count = field_count; row.hs_row_first = row.hs_row; + row.row_size = (*hs_conn_p)->get_row_size_from_result(hs_res_buf->hs_result); DBUG_RETURN((SPIDER_DB_ROW *) &row); } @@ -729,6 +734,7 @@ SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_tmp_table( } tmp_hs_row++; } + row.row_size = row_ptr - tmp_str2.ptr(); DBUG_RETURN((SPIDER_DB_ROW *) &row); } diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h index 3767f0f3fac..075f8720abf 100644 --- a/storage/spider/spd_db_handlersocket.h +++ b/storage/spider/spd_db_handlersocket.h @@ -145,6 +145,7 @@ public: SPIDER_HS_STRING_REF *hs_row; SPIDER_HS_STRING_REF *hs_row_first; uint field_count; + uint row_size; bool cloned; spider_db_handlersocket_row(); ~spider_db_handlersocket_row(); @@ -173,6 +174,7 @@ public: TABLE *tmp_table, spider_string *str ); + uint get_byte_size(); }; class spider_db_handlersocket_result_buffer: public spider_db_result_buffer diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 7f1148655e3..cc4d2bcd3a1 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -941,6 +941,7 @@ public: TABLE *tmp_table, spider_string *str ) = 0; + virtual uint get_byte_size() = 0; }; class spider_db_result_buffer @@ -1947,6 +1948,7 @@ typedef struct st_spider_result_list int max_order; int quick_mode; longlong quick_page_size; + longlong quick_page_byte; int low_mem_read; int bulk_update_mode; int bulk_update_size; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 8c17bc8970d..39f448e44c0 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -415,11 +415,17 @@ SPIDER_DB_ROW *spider_db_mysql_row::clone() { DBUG_RETURN(NULL); } - row_size = field_count; - for (i = 0; i < field_count; i++) + if (!record_size) { - row_size += *tmp_lengths; - tmp_lengths++; + row_size = field_count; + for (i = 0; i < field_count; i++) + { + row_size += *tmp_lengths; + tmp_lengths++; + } + record_size = row_size - field_count; + } else { + row_size = record_size + field_count; } if (!spider_bulk_malloc(spider_current_trx, 29, MYF(MY_WME), &clone_row->row, sizeof(char*) * field_count, @@ -451,6 +457,7 @@ SPIDER_DB_ROW *spider_db_mysql_row::clone() tmp_row++; } clone_row->field_count = field_count; + clone_row->record_size = record_size; clone_row->row_first = clone_row->row; clone_row->lengths_first = clone_row->lengths; clone_row->cloned = TRUE; @@ -493,6 +500,23 @@ int spider_db_mysql_row::store_to_tmp_table( DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); } +uint spider_db_mysql_row::get_byte_size() +{ + ulong *tmp_lengths = lengths_first; + uint i; + DBUG_ENTER("spider_db_mysql_row::get_byte_size"); + DBUG_PRINT("info",("spider this=%p", this)); + if (!record_size) + { + for (i = 0; i < field_count; i++) + { + record_size += *tmp_lengths; + tmp_lengths++; + } + } + DBUG_RETURN(record_size); +} + spider_db_mysql_result::spider_db_mysql_result(SPIDER_DB_CONN *in_db_conn) : spider_db_result(in_db_conn, spider_dbton_mysql.dbton_id), db_result(NULL) @@ -559,6 +583,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row() row.field_count = mysql_num_fields(db_result); row.row_first = row.row; row.lengths_first = row.lengths; + row.record_size = 0; DBUG_RETURN((SPIDER_DB_ROW *) &row); } @@ -582,6 +607,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_result_buffer( row.field_count = mysql_num_fields(db_result); row.row_first = row.row; row.lengths_first = row.lengths; + row.record_size = 0; DBUG_RETURN((SPIDER_DB_ROW *) &row); } @@ -614,6 +640,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_tmp_table( row.field_count = field_count; row.row_first = row.row; row.lengths_first = row.lengths; + row.record_size = tmp_str2.length(); for (i = 0; i < field_count; i++) { if (*tmp_row) diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 423ead89423..9a709f46c51 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -182,6 +182,7 @@ public: ulong *lengths; ulong *lengths_first; uint field_count; + uint record_size; bool cloned; spider_db_mysql_row(); ~spider_db_mysql_row(); @@ -210,6 +211,7 @@ public: TABLE *tmp_table, spider_string *str ); + uint get_byte_size(); }; class spider_db_mysql_result: public spider_db_result diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index dfeafc58f13..e5a68f1f8c1 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -519,6 +519,7 @@ SPIDER_DB_ROW *spider_db_oracle_row::clone() clone_row->db_conn = db_conn; clone_row->result = result; clone_row->field_count = field_count; + clone_row->record_size = record_size; clone_row->access_charset = access_charset; clone_row->cloned = TRUE; if (clone_row->init()) @@ -571,6 +572,13 @@ int spider_db_oracle_row::store_to_tmp_table( DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); } +uint spider_db_oracle_row::get_byte_size() +{ + DBUG_ENTER("spider_db_oracle_row::get_byte_size"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_RETURN(record_size); +} + int spider_db_oracle_row::init() { char *tmp_val; @@ -696,6 +704,7 @@ int spider_db_oracle_row::fetch() uint i; DBUG_ENTER("spider_db_oracle_row::fetch"); DBUG_PRINT("info",("spider this=%p", this)); + record_size = 0; for (i = 0; i < field_count; i++) { if (ind[i] == -1) @@ -757,6 +766,7 @@ int spider_db_oracle_row::fetch() } } row_size[i] = val_str[i].length(); + record_size += row_size[i]; } DBUG_RETURN(0); } @@ -911,6 +921,7 @@ SPIDER_DB_ROW *spider_db_oracle_result::fetch_row_from_tmp_table( str += row.row_size[i]; } } + row.record_size = tmp_str2.length(); DBUG_RETURN((SPIDER_DB_ROW *) &row); } diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index 9f9c75f0090..d0bd1757418 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -168,6 +168,7 @@ public: ub2 *coltp; ub2 *colsz; uint field_count; + uint record_size; ulong *row_size; ulong *row_size_first; CHARSET_INFO *access_charset; @@ -201,6 +202,7 @@ public: TABLE *tmp_table, spider_string *str ); + uint get_byte_size(); /* for oracle */ int init(); void deinit(); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 38ded445d44..23bbff22fbb 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -960,6 +960,7 @@ typedef struct st_spider_share longlong priority; int quick_mode; longlong quick_page_size; + longlong quick_page_byte; int low_mem_read; int table_count_mode; int select_column_mode; diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index a90f628603e..c10ed3aad80 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -1362,6 +1362,31 @@ longlong spider_param_quick_page_size( quick_page_size : THDVAR(thd, quick_page_size)); } +/* + -1 :use table parameter + 0-:the limitation of memory size + */ +static MYSQL_THDVAR_LONGLONG( + quick_page_byte, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "The limitation of memory size in a page when acquisition one by one", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 9223372036854775807LL, /* max */ + 0 /* blk */ +); + +longlong spider_param_quick_page_byte( + THD *thd, + longlong quick_page_byte +) { + DBUG_ENTER("spider_param_quick_page_byte"); + DBUG_RETURN(THDVAR(thd, quick_page_byte) < 0 ? + quick_page_byte : THDVAR(thd, quick_page_byte)); +} + /* -1 :use table parameter 0 :It doesn't use low memory mode. @@ -3354,6 +3379,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(net_write_timeout), MYSQL_SYSVAR(quick_mode), MYSQL_SYSVAR(quick_page_size), + MYSQL_SYSVAR(quick_page_byte), MYSQL_SYSVAR(low_mem_read), MYSQL_SYSVAR(select_column_mode), #ifndef WITHOUT_SPIDER_BG_SEARCH diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index e615fc672d4..7919b0c4837 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -171,6 +171,10 @@ longlong spider_param_quick_page_size( THD *thd, longlong quick_page_size ); +longlong spider_param_quick_page_byte( + THD *thd, + longlong quick_page_byte +); int spider_param_low_mem_read( THD *thd, int low_mem_read diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 1f220b193e5..fe5265184b6 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -2045,6 +2045,7 @@ int spider_parse_connect_info( share->priority = -1; share->quick_mode = -1; share->quick_page_size = -1; + share->quick_page_byte = -1; share->low_mem_read = -1; share->table_count_mode = -1; share->select_column_mode = -1; @@ -2290,6 +2291,7 @@ int spider_parse_connect_info( SPIDER_PARAM_INT_WITH_MAX("qch", query_cache, 0, 2); SPIDER_PARAM_INT_WITH_MAX("qcs", query_cache_sync, 0, 3); SPIDER_PARAM_INT_WITH_MAX("qmd", quick_mode, 0, 3); + SPIDER_PARAM_LONGLONG("qpb", quick_page_byte, 0); SPIDER_PARAM_LONGLONG("qps", quick_page_size, 0); SPIDER_PARAM_INT_WITH_MAX("rom", read_only_mode, 0, 1); SPIDER_PARAM_DOUBLE("rrt", read_rate, 0); @@ -2459,6 +2461,7 @@ int spider_parse_connect_info( SPIDER_PARAM_LONGLONG("internal_offset", internal_offset, 0); SPIDER_PARAM_INT_WITH_MAX("reset_sql_alloc", reset_sql_alloc, 0, 1); SPIDER_PARAM_INT_WITH_MAX("semi_table_lock", semi_table_lock, 0, 1); + SPIDER_PARAM_LONGLONG("quick_page_byte", quick_page_byte, 0); SPIDER_PARAM_LONGLONG("quick_page_size", quick_page_size, 0); #ifndef WITHOUT_SPIDER_BG_SEARCH SPIDER_PARAM_LONGLONG("bgs_second_read", bgs_second_read, 0); @@ -3824,9 +3827,11 @@ int spider_set_connect_info_default( if (share->priority == -1) share->priority = 1000000; if (share->quick_mode == -1) - share->quick_mode = 0; + share->quick_mode = 3; if (share->quick_page_size == -1) - share->quick_page_size = 100; + share->quick_page_size = 1024; + if (share->quick_page_byte == -1) + share->quick_page_byte = 10485760; if (share->low_mem_read == -1) share->low_mem_read = 1; if (share->table_count_mode == -1) @@ -7997,6 +8002,8 @@ void spider_set_result_list_param( spider_param_quick_mode(thd, share->quick_mode); result_list->quick_page_size = spider_param_quick_page_size(thd, share->quick_page_size); + result_list->quick_page_byte = + spider_param_quick_page_byte(thd, share->quick_page_byte); result_list->low_mem_read = spider_param_low_mem_read(thd, share->low_mem_read); DBUG_VOID_RETURN; From 6d80d35d9161287e6e72ac728338473c96f9fb22 Mon Sep 17 00:00:00 2001 From: Kentoku Date: Thu, 13 Dec 2018 03:11:57 +0900 Subject: [PATCH 12/22] MDEV-16787 optimistic parallel replication fails on spider Add a system variable spider_slave_trx_isolation. - spider_slave_trx_isolation The transaction isolation level when Spider table is used by slave SQL thread. -1 : OFF 0 : READ UNCOMMITTED 1 : READ COMMITTED 2 : REPEATABLE READ 3 : SERIALIZABLE The default value is -1 Miscellaneous Spider typos --- .../include/slave_trx_isolation_deinit.inc | 17 ++ .../include/slave_trx_isolation_init.inc | 39 ++++ .../spider/r/slave_trx_isolation.result | 110 ++++++++++++ .../spider/t/slave_trx_isolation.test | 166 ++++++++++++++++++ storage/spider/spd_db_mysql.cc | 2 +- storage/spider/spd_db_oracle.cc | 2 +- storage/spider/spd_group_by_handler.cc | 4 +- storage/spider/spd_param.cc | 28 +++ storage/spider/spd_param.h | 1 + storage/spider/spd_trx.cc | 24 +-- 10 files changed, 378 insertions(+), 15 deletions(-) create mode 100644 storage/spider/mysql-test/spider/include/slave_trx_isolation_deinit.inc create mode 100644 storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc create mode 100644 storage/spider/mysql-test/spider/r/slave_trx_isolation.result create mode 100644 storage/spider/mysql-test/spider/t/slave_trx_isolation.test diff --git a/storage/spider/mysql-test/spider/include/slave_trx_isolation_deinit.inc b/storage/spider/mysql-test/spider/include/slave_trx_isolation_deinit.inc new file mode 100644 index 00000000000..e5f585e5cca --- /dev/null +++ b/storage/spider/mysql-test/spider/include/slave_trx_isolation_deinit.inc @@ -0,0 +1,17 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP +--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP +--connection slave1_1 +set global spider_slave_trx_isolation= @old_spider_slave_trx_isolation; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../include/deinit_spider.inc +--source ../t/slave_test_deinit.inc +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc b/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc new file mode 100644 index 00000000000..94ccf1d3295 --- /dev/null +++ b/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc @@ -0,0 +1,39 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--source ../t/slave_test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 +--let $OUTPUT_CHILD_GROUP2= 1 +--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG +--let $USE_GENERAL_LOG= 1 +--connection slave1_1 +--disable_warnings +--disable_query_log +--disable_result_log +--source ../include/init_spider.inc +--enable_result_log +--enable_query_log +--enable_warnings +set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; +set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result new file mode 100644 index 00000000000..167739beaad --- /dev/null +++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result @@ -0,0 +1,110 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 +for slave1_1 +connection slave1_1; +set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; +set global spider_slave_trx_isolation= 1; + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection slave1_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +connection slave1_1; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +connection master_1; +SET SESSION sql_log_bin= 1; +connection slave1_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +connection master_1; +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +connection slave1_1; +connection master_1; +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +argument +set session time_zone = '+00:00' +SET NAMES utf8 +set session transaction isolation level read committed;set session autocommit = 1;start transaction +SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +connection slave1_1; +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection slave1_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection slave1_1; +set global spider_slave_trx_isolation= @old_spider_slave_trx_isolation; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test new file mode 100644 index 00000000000..d1dea8546b9 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test @@ -0,0 +1,166 @@ +--source ../include/slave_trx_isolation_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; + CREATE DATABASE auto_test_local; + USE auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SET @old_log_output = @@global.log_output; + SET GLOBAL log_output = 'TABLE,FILE'; + } + DROP DATABASE IF EXISTS auto_test_remote; + CREATE DATABASE auto_test_remote; + USE auto_test_remote; +} +--enable_warnings + +--echo +--echo create table and insert +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES; + echo CHILD2_1_CREATE_TABLES; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +--connection master_1 +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +--disable_warnings +DROP TABLE IF EXISTS tbl_a; +--enable_warnings +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +--connection master_1 +if ($USE_REPLICATION) +{ + SET SESSION sql_log_bin= 1; + --connection slave1_1 + --disable_warnings + DROP TABLE IF EXISTS tbl_a; + --enable_warnings + --disable_query_log + echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; + eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; + --enable_query_log + --connection master_1 +} +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +if ($USE_REPLICATION) +{ + save_master_pos; + --connection slave1_1 + sync_with_master; + --connection master_1 + --disable_query_log + SET SESSION sql_log_bin= 0; + --enable_query_log +} +if ($USE_CHILD_GROUP2) +{ + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + eval $CHILD2_1_SELECT_ARGUMENT1; + } + eval $CHILD2_1_SELECT_TABLES; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } +} +if ($USE_REPLICATION) +{ + --connection slave1_1 + SELECT pkey FROM tbl_a ORDER BY pkey; +} + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; +if ($USE_REPLICATION) +{ + --connection slave1_1 + DROP DATABASE IF EXISTS auto_test_local; +} +if ($USE_CHILD_GROUP2) +{ + --connection child2_1 + DROP DATABASE IF EXISTS auto_test_remote; + if ($USE_GENERAL_LOG) + { + SET GLOBAL log_output = @old_log_output; + } +} +--enable_warnings +--source ../include/slave_trx_isolation_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 39f448e44c0..ceb38f886aa 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5895,7 +5895,7 @@ int spider_mysql_share::convert_key_hint_str() DBUG_ENTER("spider_mysql_share::convert_key_hint_str"); if (spider_share->access_charset->cset != system_charset_info->cset) { - /* need convertion */ + /* need conversion */ for (roop_count = 0, tmp_key_hint = key_hint; roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) { diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index e5a68f1f8c1..82a1e9a0fbc 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -4816,7 +4816,7 @@ int spider_oracle_share::convert_key_hint_str() DBUG_ENTER("spider_oracle_share::convert_key_hint_str"); if (spider_share->access_charset->cset != system_charset_info->cset) { - /* need convertion */ + /* need conversion */ for (roop_count = 0, tmp_key_hint = key_hint; roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++) { diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 86a9f8cba68..3b57092c4ce 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -822,7 +822,7 @@ void spider_fields::choose_a_conn( current_conn_holder = first_conn_holder; } - DBUG_PRINT("info",("spider choosed connection is %p", + DBUG_PRINT("info",("spider chosen connection is %p", current_conn_holder->conn)); last_conn_holder = current_conn_holder; current_conn_holder = current_conn_holder->next; @@ -2065,7 +2065,7 @@ group_by_handler *spider_create_group_by_handler( fields->check_support_dbton(dbton_bitmap); if (!fields->has_conn_holder()) { - DBUG_PRINT("info",("spider all choosed connections can't match dbton_id")); + DBUG_PRINT("info",("spider all chosen connections can't match dbton_id")); delete fields; DBUG_RETURN(NULL); } diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index c10ed3aad80..6b237bbfff8 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -3328,6 +3328,33 @@ uint spider_param_table_crd_thread_count() } #endif +static int spider_slave_trx_isolation; +/* + -1 :off + 0 :read uncommitted + 1 :read committed + 2 :repeatable read + 3 :serializable + */ +static MYSQL_SYSVAR_INT( + slave_trx_isolation, + spider_slave_trx_isolation, + PLUGIN_VAR_RQCMDARG, + "Transaction isolation level when Spider table is used by slave SQL thread", + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_slave_trx_isolation() +{ + DBUG_ENTER("spider_param_slave_trx_isolation"); + DBUG_RETURN(spider_slave_trx_isolation); +} + static struct st_mysql_storage_engine spider_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; @@ -3477,6 +3504,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(table_sts_thread_count), MYSQL_SYSVAR(table_crd_thread_count), #endif + MYSQL_SYSVAR(slave_trx_isolation), NULL }; diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index 7919b0c4837..8fdf2e452b2 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -420,3 +420,4 @@ int spider_param_load_crd_at_startup( uint spider_param_table_sts_thread_count(); uint spider_param_table_crd_thread_count(); #endif +int spider_param_slave_trx_isolation(); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 565665dc6f7..6204ca9852c 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1586,21 +1586,23 @@ int spider_check_and_set_trx_isolation( SPIDER_CONN *conn, int *need_mon ) { + THD *thd = conn->thd; int trx_isolation; DBUG_ENTER("spider_check_and_set_trx_isolation"); - - trx_isolation = thd_tx_isolation(conn->thd); - DBUG_PRINT("info",("spider local trx_isolation=%d", trx_isolation)); -/* - DBUG_PRINT("info",("spider conn->trx_isolation=%d", conn->trx_isolation)); - if (conn->trx_isolation != trx_isolation) + if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) { -*/ - spider_conn_queue_trx_isolation(conn, trx_isolation); -/* - conn->trx_isolation = trx_isolation; + if ((trx_isolation = spider_param_slave_trx_isolation()) == -1) + { + trx_isolation = thd_tx_isolation(thd); + DBUG_PRINT("info",("spider local trx_isolation=%d", trx_isolation)); + } else { + DBUG_PRINT("info",("spider slave trx_isolation=%d", trx_isolation)); + } + } else { + trx_isolation = thd_tx_isolation(thd); + DBUG_PRINT("info",("spider local trx_isolation=%d", trx_isolation)); } -*/ + spider_conn_queue_trx_isolation(conn, trx_isolation); DBUG_RETURN(0); } From be556f817b88139502dd75cdbf22a28c2fe5806c Mon Sep 17 00:00:00 2001 From: Kentoku Date: Mon, 24 Dec 2018 23:40:33 +0900 Subject: [PATCH 13/22] remove unnecessary drop database/table from quick_mode.test add simplified quick_mode.test --- .../bugfix/include/quick_mode_0_deinit.inc | 19 + .../bugfix/include/quick_mode_0_init.inc | 51 ++ .../bugfix/include/quick_mode_1_deinit.inc | 19 + .../bugfix/include/quick_mode_1_init.inc | 51 ++ .../bugfix/include/quick_mode_2_deinit.inc | 19 + .../bugfix/include/quick_mode_2_init.inc | 51 ++ .../bugfix/include/quick_mode_3_deinit.inc | 19 + .../bugfix/include/quick_mode_3_init.inc | 51 ++ .../spider/bugfix/r/quick_mode_0.result | 504 ++++++++++++++++++ .../spider/bugfix/r/quick_mode_1.result | 504 ++++++++++++++++++ .../spider/bugfix/r/quick_mode_2.result | 504 ++++++++++++++++++ .../spider/bugfix/r/quick_mode_3.result | 504 ++++++++++++++++++ .../spider/bugfix/t/quick_mode_0.cnf | 4 + .../spider/bugfix/t/quick_mode_0.test | 156 ++++++ .../spider/bugfix/t/quick_mode_1.cnf | 4 + .../spider/bugfix/t/quick_mode_1.test | 156 ++++++ .../spider/bugfix/t/quick_mode_2.cnf | 4 + .../spider/bugfix/t/quick_mode_2.test | 156 ++++++ .../spider/bugfix/t/quick_mode_3.cnf | 4 + .../spider/bugfix/t/quick_mode_3.test | 157 ++++++ .../mysql-test/spider/r/quick_mode_0.result | 7 - .../mysql-test/spider/r/quick_mode_1.result | 7 - .../mysql-test/spider/r/quick_mode_2.result | 7 - .../mysql-test/spider/r/quick_mode_3.result | 7 - .../mysql-test/spider/t/quick_mode_0.test | 15 - .../mysql-test/spider/t/quick_mode_1.test | 15 - .../mysql-test/spider/t/quick_mode_2.test | 15 - .../mysql-test/spider/t/quick_mode_3.test | 15 - 28 files changed, 2937 insertions(+), 88 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_deinit.inc new file mode 100644 index 00000000000..42124a794ea --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_deinit.inc @@ -0,0 +1,19 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc new file mode 100644 index 00000000000..2656517216c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc @@ -0,0 +1,51 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 0; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_deinit.inc new file mode 100644 index 00000000000..42124a794ea --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_deinit.inc @@ -0,0 +1,19 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc new file mode 100644 index 00000000000..9a8de407569 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc @@ -0,0 +1,51 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 1; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_deinit.inc new file mode 100644 index 00000000000..42124a794ea --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_deinit.inc @@ -0,0 +1,19 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc new file mode 100644 index 00000000000..dbe3f703a2f --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc @@ -0,0 +1,51 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 2; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_deinit.inc new file mode 100644 index 00000000000..42124a794ea --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_deinit.inc @@ -0,0 +1,19 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $MASTER_1_COMMENT_2_2= $MASTER_1_COMMENT_2_2_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP +--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP +--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_SELECT_TABLES_BACKUP +--connection master_1 +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc new file mode 100644 index 00000000000..81239206dfc --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc @@ -0,0 +1,51 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $MASTER_1_COMMENT_2_2_BACKUP= $MASTER_1_COMMENT_2_2 +let $MASTER_1_COMMENT_2_2= + COMMENT='table "tbl_b", srv "s_2_2"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES +let $CHILD2_2_DROP_TABLES= + DROP TABLE IF EXISTS tbl_b; +--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES +let $CHILD2_2_CREATE_TABLES= + CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET; +--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES +let $CHILD2_2_SELECT_TABLES= + SELECT pkey FROM tbl_b ORDER BY pkey; +let $CHILD2_2_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +--connection master_1 +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; +let $MASTER_1_SET_QUICK_PAGE_BYTE_6= + set session spider_quick_page_byte= 6; +let $MASTER_1_SET_QUICK_PAGE_BYTE_0= + set session spider_quick_page_byte= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result new file mode 100644 index 00000000000..6e5a0052370 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result @@ -0,0 +1,504 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 0; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +this test is for MDEV-16520 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result new file mode 100644 index 00000000000..bca6d172a49 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result @@ -0,0 +1,504 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 1; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +this test is for MDEV-16520 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result new file mode 100644 index 00000000000..61a7764dddb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result @@ -0,0 +1,504 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 2; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +this test is for MDEV-16520 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result new file mode 100644 index 00000000000..38387a45509 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result @@ -0,0 +1,504 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +connection master_1; +set @old_spider_quick_mode= @@spider_quick_mode; +set session spider_quick_mode= 3; +set @old_spider_quick_page_size= @@spider_quick_page_size; +set session spider_quick_page_size= 3; +set @old_spider_quick_page_byte= @@spider_quick_page_byte; + +this test is for MDEV-16520 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +connection child2_2; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection child2_2; +CHILD2_2_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +CREATE TABLE tbl_b ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 6; + +select test 2 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection master_1; +set session spider_quick_page_byte= 0; + +select test 3 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection child2_2; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +connection child2_2; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 2 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 3 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 4 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 5 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 6 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 7 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 8 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 9 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 10 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 11 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 12 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 13 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 14 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 15 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 16 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 17 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 18 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 19 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 20 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 21 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 22 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 23 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 24 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 25 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 +select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_b ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection child2_2; +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; +connection master_1; +set session spider_quick_mode= @old_spider_quick_mode; +set session spider_quick_page_size= @old_spider_quick_page_size; +set session spider_quick_page_byte= @old_spider_quick_page_byte; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.cnf b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.cnf new file mode 100644 index 00000000000..e0ffb99c38e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.cnf @@ -0,0 +1,4 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf +!include ../my_2_2.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test new file mode 100644 index 00000000000..235edc10d12 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test @@ -0,0 +1,156 @@ +--source ../include/quick_mode_0_init.inc +--echo +--echo this test is for MDEV-16520 +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +--connection child2_2 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +--disable_query_log +echo CHILD2_2_CREATE_TABLES; +eval $CHILD2_2_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--connection child2_2 +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/quick_mode_0_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.cnf b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.cnf new file mode 100644 index 00000000000..e0ffb99c38e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.cnf @@ -0,0 +1,4 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf +!include ../my_2_2.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test new file mode 100644 index 00000000000..01fa0cb5128 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test @@ -0,0 +1,156 @@ +--source ../include/quick_mode_1_init.inc +--echo +--echo this test is for MDEV-16520 +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +--connection child2_2 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +--disable_query_log +echo CHILD2_2_CREATE_TABLES; +eval $CHILD2_2_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--connection child2_2 +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/quick_mode_1_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.cnf b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.cnf new file mode 100644 index 00000000000..e0ffb99c38e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.cnf @@ -0,0 +1,4 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf +!include ../my_2_2.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test new file mode 100644 index 00000000000..3ea8138e755 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test @@ -0,0 +1,156 @@ +--source ../include/quick_mode_2_init.inc +--echo +--echo this test is for MDEV-16520 +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +--connection child2_2 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +--disable_query_log +echo CHILD2_2_CREATE_TABLES; +eval $CHILD2_2_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--connection child2_2 +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/quick_mode_2_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.cnf b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.cnf new file mode 100644 index 00000000000..e0ffb99c38e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.cnf @@ -0,0 +1,4 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf +!include ../my_2_2.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test new file mode 100644 index 00000000000..bc926b0a296 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test @@ -0,0 +1,157 @@ +--source ../include/quick_mode_3_init.inc +--echo +--echo this test is for MDEV-16520 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +--connection child2_2 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote2; +USE auto_test_remote2; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +--disable_query_log +echo CHILD2_2_CREATE_TABLES; +eval $CHILD2_2_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +echo CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_2; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_b ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_2; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +INSERT INTO tbl_b (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_b (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_b (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_6; + +--echo +--echo select test 2 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--connection master_1 +eval $MASTER_1_SET_QUICK_PAGE_BYTE_0; + +--echo +--echo select test 3 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection child2_2 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; + +--connection child2_1 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection child2_2 +--replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +eval $CHILD2_2_SELECT_ARGUMENT1; +eval $CHILD2_2_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--connection child2_2 +DROP DATABASE IF EXISTS auto_test_remote2; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/quick_mode_3_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/r/quick_mode_0.result b/storage/spider/mysql-test/spider/r/quick_mode_0.result index 1cf79124b8c..239c3ee1175 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_0.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_0.result @@ -16,34 +16,27 @@ set @old_spider_quick_page_byte= @@spider_quick_page_byte; drop and create databases connection master_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection child2_1; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; connection child2_2; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; create table and insert connection child2_1; -CHILD2_1_DROP_TABLES CHILD2_1_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection child2_2; -CHILD2_2_DROP_TABLES CHILD2_2_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection master_1; -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) diff --git a/storage/spider/mysql-test/spider/r/quick_mode_1.result b/storage/spider/mysql-test/spider/r/quick_mode_1.result index 1d56cff3e36..d0db0729c39 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_1.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_1.result @@ -16,34 +16,27 @@ set @old_spider_quick_page_byte= @@spider_quick_page_byte; drop and create databases connection master_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection child2_1; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; connection child2_2; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; create table and insert connection child2_1; -CHILD2_1_DROP_TABLES CHILD2_1_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection child2_2; -CHILD2_2_DROP_TABLES CHILD2_2_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection master_1; -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) diff --git a/storage/spider/mysql-test/spider/r/quick_mode_2.result b/storage/spider/mysql-test/spider/r/quick_mode_2.result index 5b0cd75af34..538057e3cda 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_2.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_2.result @@ -16,34 +16,27 @@ set @old_spider_quick_page_byte= @@spider_quick_page_byte; drop and create databases connection master_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection child2_1; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; connection child2_2; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; create table and insert connection child2_1; -CHILD2_1_DROP_TABLES CHILD2_1_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection child2_2; -CHILD2_2_DROP_TABLES CHILD2_2_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection master_1; -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) diff --git a/storage/spider/mysql-test/spider/r/quick_mode_3.result b/storage/spider/mysql-test/spider/r/quick_mode_3.result index 4261cde2e36..9232dd152de 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_3.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_3.result @@ -16,34 +16,27 @@ set @old_spider_quick_page_byte= @@spider_quick_page_byte; drop and create databases connection master_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection child2_1; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; connection child2_2; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; create table and insert connection child2_1; -CHILD2_1_DROP_TABLES CHILD2_1_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection child2_2; -CHILD2_2_DROP_TABLES CHILD2_2_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection master_1; -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) diff --git a/storage/spider/mysql-test/spider/t/quick_mode_0.test b/storage/spider/mysql-test/spider/t/quick_mode_0.test index ffb665c0604..6945d97a049 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_0.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_0.test @@ -3,7 +3,6 @@ --echo drop and create databases --connection master_1 --disable_warnings -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; if ($USE_CHILD_GROUP2) @@ -14,7 +13,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; --connection child2_2 @@ -23,7 +21,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; } @@ -42,12 +39,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_1_DROP_TABLES; echo CHILD2_1_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_1_DROP_TABLES; - --enable_warnings eval $CHILD2_1_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -61,12 +54,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_2_DROP_TABLES; echo CHILD2_2_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_2_DROP_TABLES; - --enable_warnings eval $CHILD2_2_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -83,10 +72,6 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 ---disable_warnings -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; ---enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, diff --git a/storage/spider/mysql-test/spider/t/quick_mode_1.test b/storage/spider/mysql-test/spider/t/quick_mode_1.test index 70d61d087e3..d382d5dbe95 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_1.test @@ -3,7 +3,6 @@ --echo drop and create databases --connection master_1 --disable_warnings -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; if ($USE_CHILD_GROUP2) @@ -14,7 +13,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; --connection child2_2 @@ -23,7 +21,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; } @@ -42,12 +39,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_1_DROP_TABLES; echo CHILD2_1_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_1_DROP_TABLES; - --enable_warnings eval $CHILD2_1_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -61,12 +54,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_2_DROP_TABLES; echo CHILD2_2_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_2_DROP_TABLES; - --enable_warnings eval $CHILD2_2_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -83,10 +72,6 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 ---disable_warnings -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; ---enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, diff --git a/storage/spider/mysql-test/spider/t/quick_mode_2.test b/storage/spider/mysql-test/spider/t/quick_mode_2.test index 71e7b0338dc..ebb889868a6 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_2.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_2.test @@ -3,7 +3,6 @@ --echo drop and create databases --connection master_1 --disable_warnings -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; if ($USE_CHILD_GROUP2) @@ -14,7 +13,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; --connection child2_2 @@ -23,7 +21,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; } @@ -42,12 +39,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_1_DROP_TABLES; echo CHILD2_1_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_1_DROP_TABLES; - --enable_warnings eval $CHILD2_1_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -61,12 +54,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_2_DROP_TABLES; echo CHILD2_2_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_2_DROP_TABLES; - --enable_warnings eval $CHILD2_2_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -83,10 +72,6 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 ---disable_warnings -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; ---enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, diff --git a/storage/spider/mysql-test/spider/t/quick_mode_3.test b/storage/spider/mysql-test/spider/t/quick_mode_3.test index 000edd4fdff..5992284f301 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_3.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_3.test @@ -3,7 +3,6 @@ --echo drop and create databases --connection master_1 --disable_warnings -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; if ($USE_CHILD_GROUP2) @@ -14,7 +13,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; --connection child2_2 @@ -23,7 +21,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote2; CREATE DATABASE auto_test_remote2; USE auto_test_remote2; } @@ -42,12 +39,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_1_DROP_TABLES; echo CHILD2_1_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_1_DROP_TABLES; - --enable_warnings eval $CHILD2_1_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -61,12 +54,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_2_DROP_TABLES; echo CHILD2_2_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_2_DROP_TABLES; - --enable_warnings eval $CHILD2_2_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -83,10 +72,6 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 ---disable_warnings -DROP TABLE IF EXISTS tbl_a; -DROP TABLE IF EXISTS tbl_b; ---enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, From ea347fcb28167efc99db5c3f24c1baa2b57d6e86 Mon Sep 17 00:00:00 2001 From: Kentoku Date: Tue, 25 Dec 2018 00:22:45 +0900 Subject: [PATCH 14/22] remove unnecessary drop database/table from slave_trx_isolation.test add simplified slave_trx_isolation.test --- .../include/slave_trx_isolation_deinit.inc | 15 +++ .../include/slave_trx_isolation_init.inc | 35 +++++++ .../bugfix/r/slave_trx_isolation.result | 99 +++++++++++++++++++ .../spider/bugfix/t/slave_trx_isolation.cnf | 4 + .../spider/bugfix/t/slave_trx_isolation.test | 95 ++++++++++++++++++ .../spider/r/slave_trx_isolation.result | 9 +- .../spider/t/slave_trx_isolation.test | 18 ---- 7 files changed, 250 insertions(+), 25 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_deinit.inc new file mode 100644 index 00000000000..7c20b2bc99e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_deinit.inc @@ -0,0 +1,15 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--connection slave1_1 +set global spider_slave_trx_isolation= @old_spider_slave_trx_isolation; +--disable_warnings +--disable_query_log +--disable_result_log +--source ../include/deinit_spider.inc +--source ../t/slave_test_deinit.inc +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc new file mode 100644 index 00000000000..3a058a55303 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc @@ -0,0 +1,35 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--source ../t/slave_test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +--connection slave1_1 +--disable_warnings +--disable_query_log +--disable_result_log +--source ../include/init_spider.inc +--enable_result_log +--enable_query_log +--enable_warnings +set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; +set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result new file mode 100644 index 00000000000..06581a604a2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result @@ -0,0 +1,99 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +for slave1_1 +connection slave1_1; +set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; +set global spider_slave_trx_isolation= 1; + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection slave1_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +connection slave1_1; +connection master_1; +SET SESSION sql_log_bin= 0; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +SET SESSION sql_log_bin= 1; +connection slave1_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +connection master_1; +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +connection slave1_1; +connection master_1; +SET SESSION sql_log_bin= 0; +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +argument +set session time_zone = '+00:00' +SET NAMES utf8 +set session transaction isolation level read committed;set session autocommit = 1;start transaction +SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +connection slave1_1; +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection slave1_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +connection slave1_1; +set global spider_slave_trx_isolation= @old_spider_slave_trx_isolation; +for slave1_1 +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.cnf b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.cnf new file mode 100644 index 00000000000..45019d6c537 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.cnf @@ -0,0 +1,4 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf +!include ../my_4_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test new file mode 100644 index 00000000000..652fbb1c11c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test @@ -0,0 +1,95 @@ +--source ../include/slave_trx_isolation_init.inc +--echo +--echo drop and create databases +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection slave1_1 +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +save_master_pos; + +--connection slave1_1 +sync_with_master; + +--connection master_1 +SET SESSION sql_log_bin= 0; +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE2 $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +SET SESSION sql_log_bin= 1; + +--connection slave1_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log + +--connection master_1 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +save_master_pos; + +--connection slave1_1 +sync_with_master; + +--connection master_1 +SET SESSION sql_log_bin= 0; + +--connection child2_1 +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--connection slave1_1 +SELECT pkey FROM tbl_a ORDER BY pkey; + +--echo +--echo deinit +--disable_warnings +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection slave1_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/slave_trx_isolation_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result index 167739beaad..7d9ba40cab3 100644 --- a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result @@ -14,37 +14,31 @@ set global spider_slave_trx_isolation= 1; drop and create databases connection master_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection slave1_1; -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; connection child2_1; SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; -DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; create table and insert connection child2_1; -CHILD2_1_DROP_TABLES CHILD2_1_CREATE_TABLES TRUNCATE TABLE mysql.general_log; connection master_1; connection slave1_1; connection master_1; -DROP TABLE IF EXISTS tbl_a; +SET SESSION sql_log_bin= 0; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) ) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_COMMENT_2_1 -connection master_1; SET SESSION sql_log_bin= 1; connection slave1_1; -DROP TABLE IF EXISTS tbl_a; CREATE TABLE tbl_a ( pkey int NOT NULL, PRIMARY KEY (pkey) @@ -53,6 +47,7 @@ connection master_1; INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); connection slave1_1; connection master_1; +SET SESSION sql_log_bin= 0; connection child2_1; SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; argument diff --git a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test index d1dea8546b9..507e5340779 100644 --- a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test +++ b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test @@ -3,13 +3,11 @@ --echo drop and create databases --connection master_1 --disable_warnings -DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; if ($USE_REPLICATION) { --connection slave1_1 - DROP DATABASE IF EXISTS auto_test_local; CREATE DATABASE auto_test_local; USE auto_test_local; } @@ -21,7 +19,6 @@ if ($USE_CHILD_GROUP2) SET @old_log_output = @@global.log_output; SET GLOBAL log_output = 'TABLE,FILE'; } - DROP DATABASE IF EXISTS auto_test_remote; CREATE DATABASE auto_test_remote; USE auto_test_remote; } @@ -40,12 +37,8 @@ if ($USE_CHILD_GROUP2) if ($OUTPUT_CHILD_GROUP2) { --disable_query_log - echo CHILD2_1_DROP_TABLES; echo CHILD2_1_CREATE_TABLES; } - --disable_warnings - eval $CHILD2_1_DROP_TABLES; - --enable_warnings eval $CHILD2_1_CREATE_TABLES; if ($OUTPUT_CHILD_GROUP2) { @@ -68,13 +61,8 @@ if ($USE_REPLICATION) --connection slave1_1 sync_with_master; --connection master_1 - --disable_query_log SET SESSION sql_log_bin= 0; - --enable_query_log } ---disable_warnings -DROP TABLE IF EXISTS tbl_a; ---enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, @@ -85,14 +73,10 @@ eval CREATE TABLE tbl_a ( PRIMARY KEY (pkey) ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; --enable_query_log ---connection master_1 if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; --connection slave1_1 - --disable_warnings - DROP TABLE IF EXISTS tbl_a; - --enable_warnings --disable_query_log echo CREATE TABLE tbl_a ( pkey int NOT NULL, @@ -112,9 +96,7 @@ if ($USE_REPLICATION) --connection slave1_1 sync_with_master; --connection master_1 - --disable_query_log SET SESSION sql_log_bin= 0; - --enable_query_log } if ($USE_CHILD_GROUP2) { From 470c1b8d564bdc3574376d2c50a0dac783c5b3da Mon Sep 17 00:00:00 2001 From: Kentoku Date: Mon, 31 Dec 2018 23:42:49 +0900 Subject: [PATCH 15/22] Fix an error at using spider_direct_sql with temporary table --- .../direct_sql_with_tmp_table_deinit.inc | 7 ++++ .../direct_sql_with_tmp_table_init.inc | 9 +++++ .../bugfix/r/direct_sql_with_tmp_table.result | 33 +++++++++++++++++ .../bugfix/t/direct_sql_with_tmp_table.cnf | 3 ++ .../bugfix/t/direct_sql_with_tmp_table.test | 35 +++++++++++++++++++ storage/spider/spd_direct_sql.cc | 2 +- storage/spider/spd_include.h | 4 +-- storage/spider/spd_sys_table.cc | 17 +++++++++ storage/spider/spd_sys_table.h | 5 +++ 9 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.test diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_deinit.inc new file mode 100644 index 00000000000..ecb5622af14 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_deinit.inc @@ -0,0 +1,7 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc new file mode 100644 index 00000000000..7b58bd3e726 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc @@ -0,0 +1,9 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +let $DIRECT_SQL_COMMAND= + SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); diff --git a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result new file mode 100644 index 00000000000..65beb8a43dd --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result @@ -0,0 +1,33 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TEMPORARY TABLE tmp_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE2 +SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); +spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') +1 +SELECT pkey FROM tmp_a; +pkey +22 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.cnf b/storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.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/direct_sql_with_tmp_table.test b/storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.test new file mode 100644 index 00000000000..139af5c83c9 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/direct_sql_with_tmp_table.test @@ -0,0 +1,35 @@ +--source ../include/direct_sql_with_tmp_table_init.inc +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; +--enable_warnings + +--disable_query_log +echo CREATE TEMPORARY TABLE tmp_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE2; +eval CREATE TEMPORARY TABLE tmp_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE2; +--enable_query_log + +eval $DIRECT_SQL_COMMAND; +SELECT pkey FROM tmp_a; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--enable_warnings +--source ../include/direct_sql_with_tmp_table_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 65d5142e1f1..aee66d0336b 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1721,7 +1721,7 @@ long long spider_direct_sql_body( direct_sql->table_names[roop_count]; #endif if (!(direct_sql->tables[roop_count] = - SPIDER_find_temporary_table(thd, &table_list))) + spider_find_temporary_table(thd, &table_list))) { #if MYSQL_VERSION_ID < 50500 #else diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 23bbff22fbb..37ec2d8c608 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -160,9 +160,7 @@ #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100201 #define SPIDER_HAS_MY_CHARLEN -#define SPIDER_find_temporary_table(A,B) A->find_temporary_table(B) -#else -#define SPIDER_find_temporary_table(A,B) find_temporary_table(A,B) +#define SPIDER_open_temporary_table #endif #if defined(MARIADB_BASE_VERSION) diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index cd1c56a077e..8f8605b85bd 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -3489,3 +3489,20 @@ void spider_rm_sys_tmp_table_for_result( tmp_tbl_prm->field_count = 3; DBUG_VOID_RETURN; } + +TABLE *spider_find_temporary_table( + THD *thd, + TABLE_LIST *table_list +) { + DBUG_ENTER("spider_find_temporary_table"); +#ifdef SPIDER_open_temporary_table + if (thd->open_temporary_table(table_list)) + { + DBUG_RETURN(NULL); + } else { + DBUG_RETURN(table_list->table); + } +#else + DBUG_RETURN(find_temporary_table(A,B)); +#endif +} diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h index 857109edb38..0fdb8cde6a2 100644 --- a/storage/spider/spd_sys_table.h +++ b/storage/spider/spd_sys_table.h @@ -678,3 +678,8 @@ void spider_rm_sys_tmp_table_for_result( TABLE *tmp_table, TMP_TABLE_PARAM *tmp_tbl_prm ); + +TABLE *spider_find_temporary_table( + THD *thd, + TABLE_LIST *table_list +); From 4e599c74bb673e6d752bdacffbe014cbfd033b0a Mon Sep 17 00:00:00 2001 From: Kentoku Date: Wed, 30 Jan 2019 03:29:37 +0900 Subject: [PATCH 16/22] MDEV-18313 Supports 'wrapper mariadb' for connection information --- storage/spider/CMakeLists.txt | 2 +- .../bugfix/include/wrapper_mariadb_deinit.inc | 11 + .../bugfix/include/wrapper_mariadb_init.inc | 24 + .../spider/bugfix/r/wrapper_mariadb.result | 78 + .../spider/bugfix/t/wrapper_mariadb.cnf | 3 + .../spider/bugfix/t/wrapper_mariadb.test | 69 + storage/spider/spd_db_handlersocket.cc | 7 +- storage/spider/spd_db_include.cc | 51 + storage/spider/spd_db_include.h | 23 +- storage/spider/spd_db_mysql.cc | 2071 ++++++++++------- storage/spider/spd_db_mysql.h | 196 +- storage/spider/spd_db_oracle.cc | 9 +- storage/spider/spd_table.cc | 8 + 13 files changed, 1618 insertions(+), 934 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test create mode 100644 storage/spider/spd_db_include.cc diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index 21278dde3b3..62dfc968579 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -18,7 +18,7 @@ SET(SPIDER_SOURCES spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc - spd_group_by_handler.cc + spd_group_by_handler.cc spd_db_include.cc hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp ) diff --git a/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_deinit.inc new file mode 100644 index 00000000000..76b7582abfe --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_deinit.inc @@ -0,0 +1,11 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc new file mode 100644 index 00000000000..df3d44c39bc --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc @@ -0,0 +1,24 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1", wrapper "mariadb"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result new file mode 100644 index 00000000000..7c01421fa13 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result @@ -0,0 +1,78 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +this test is for MDEV-18313 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT * FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +select t0.`pkey` `pkey` from `auto_test_remote`.`tbl_a` t0 order by `pkey` +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.cnf b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.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/wrapper_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test new file mode 100644 index 00000000000..0102155b5ab --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test @@ -0,0 +1,69 @@ +--source ../include/wrapper_mariadb_init.inc +--echo +--echo this test is for MDEV-18313 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +--echo +--echo select test + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT * FROM tbl_a ORDER BY pkey; + +--connection child2_1 +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/wrapper_mariadb_deinit.inc +--echo +--echo end of test diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc index 4aebc7811b4..37bbe530723 100644 --- a/storage/spider/spd_db_handlersocket.cc +++ b/storage/spider/spd_db_handlersocket.cc @@ -500,7 +500,7 @@ SPIDER_DB_ROW *spider_db_handlersocket_row::clone() uint i; DBUG_ENTER("spider_db_handlersocket_row::clone"); DBUG_PRINT("info",("spider this=%p", this)); - if (!(clone_row = new spider_db_handlersocket_row())) + if (!(clone_row = new spider_db_handlersocket_row(dbton_id))) { DBUG_RETURN(NULL); } @@ -603,7 +603,7 @@ bool spider_db_handlersocket_result_buffer::check_size( spider_db_handlersocket_result::spider_db_handlersocket_result( SPIDER_DB_CONN *in_db_conn -) : spider_db_result(in_db_conn, spider_dbton_handlersocket.dbton_id) +) : spider_db_result(in_db_conn), row(in_db_conn->dbton_id) { DBUG_ENTER("spider_db_handlersocket_result::spider_db_handlersocket_result"); DBUG_PRINT("info",("spider this=%p", this)); @@ -3953,7 +3953,8 @@ int spider_db_handlersocket_util::append_having( spider_handlersocket_share::spider_handlersocket_share( st_spider_share *share ) : spider_db_share( - share + share, + spider_dbton_handlersocket.dbton_id ), table_names_str(NULL), db_names_str(NULL), diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc new file mode 100644 index 00000000000..2910aa97690 --- /dev/null +++ b/storage/spider/spd_db_include.cc @@ -0,0 +1,51 @@ +/* Copyright (C) 2018-2019 Kentoku Shiba + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER 1 +#include +#include "mysql_version.h" +#include "spd_environ.h" +#if MYSQL_VERSION_ID < 50500 +#include "mysql_priv.h" +#include +#else +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" +#endif +#include "sql_common.h" +#include +#include +#include "spd_err.h" +#include "spd_db_include.h" +#include "spd_include.h" + +spider_db_result::spider_db_result( + SPIDER_DB_CONN *in_db_conn +) : db_conn(in_db_conn), dbton_id(in_db_conn->dbton_id) +{ + DBUG_ENTER("spider_db_result::spider_db_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_conn::spider_db_conn( + SPIDER_CONN *in_conn +) : conn(in_conn), dbton_id(in_conn->dbton_id) +{ + DBUG_ENTER("spider_db_conn::spider_db_conn"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index cc4d2bcd3a1..64cee006c65 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -21,6 +21,7 @@ #define SPIDER_DBTON_SIZE 15 #define SPIDER_DB_WRAPPER_MYSQL "mysql" +#define SPIDER_DB_WRAPPER_MARIADB "mariadb" #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100204 #define PLUGIN_VAR_CAN_MEMALLOC @@ -795,6 +796,7 @@ struct st_spider_db_request_key class spider_db_util { public: + uint dbton_id; spider_db_util() {} virtual ~spider_db_util() {} virtual int append_name( @@ -961,8 +963,7 @@ protected: SPIDER_DB_CONN *db_conn; public: uint dbton_id; - spider_db_result(SPIDER_DB_CONN *in_db_conn, uint in_dbton_id) : - db_conn(in_db_conn), dbton_id(in_dbton_id) {} + spider_db_result(SPIDER_DB_CONN *in_db_conn); virtual ~spider_db_result() {} virtual bool has_result() = 0; virtual void free_result() = 0; @@ -1028,9 +1029,10 @@ class spider_db_conn protected: SPIDER_CONN *conn; public: + uint dbton_id; spider_db_conn( - SPIDER_CONN *conn - ) : conn(conn) {} + SPIDER_CONN *in_conn + ); virtual ~spider_db_conn() {} virtual int init() = 0; virtual bool is_connected() = 0; @@ -1229,8 +1231,12 @@ protected: const char *mem_calc_file_name; ulong mem_calc_line_no; public: + uint dbton_id; st_spider_share *spider_share; - spider_db_share(st_spider_share *share) : spider_share(share) {} + spider_db_share( + st_spider_share *share, + uint dbton_id + ) : dbton_id(dbton_id), spider_share(share) {} virtual ~spider_db_share() {} virtual int init() = 0; virtual uint get_column_name_length( @@ -1264,6 +1270,7 @@ protected: const char *mem_calc_file_name; ulong mem_calc_line_no; public: + uint dbton_id; ha_spider *spider; spider_db_share *db_share; int first_link_idx; @@ -1271,7 +1278,8 @@ public: SPIDER_LINK_IDX_CHAIN *link_idx_chain; #endif spider_db_handler(ha_spider *spider, spider_db_share *db_share) : - spider(spider), db_share(db_share), first_link_idx(-1) {} + dbton_id(db_share->dbton_id), spider(spider), db_share(db_share), + first_link_idx(-1) {} virtual ~spider_db_handler() {} virtual int init() = 0; virtual int append_index_hint( @@ -1750,9 +1758,10 @@ public: class spider_db_copy_table { public: + uint dbton_id; spider_db_share *db_share; spider_db_copy_table(spider_db_share *db_share) : - db_share(db_share) {} + dbton_id(db_share->dbton_id), db_share(db_share) {} virtual ~spider_db_copy_table() {} virtual int init() = 0; virtual void set_sql_charset( diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ceb38f886aa..262e47120ce 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -57,6 +57,9 @@ extern HASH spider_ipport_conns; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; extern const char spider_dig_upper[]; +spider_db_mysql_util spider_db_mysql_utility; +spider_db_mariadb_util spider_db_mariadb_utility; + #define SPIDER_SQL_NAME_QUOTE_STR "`" #define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; @@ -197,12 +200,24 @@ int spider_mysql_init() DBUG_RETURN(0); } +int spider_mariadb_init() +{ + DBUG_ENTER("spider_mariadb_init"); + DBUG_RETURN(0); +} + int spider_mysql_deinit() { DBUG_ENTER("spider_mysql_deinit"); DBUG_RETURN(0); } +int spider_mariadb_deinit() +{ + DBUG_ENTER("spider_mariadb_deinit"); + DBUG_RETURN(0); +} + spider_db_share *spider_mysql_create_share( SPIDER_SHARE *share ) { @@ -210,13 +225,29 @@ spider_db_share *spider_mysql_create_share( DBUG_RETURN(new spider_mysql_share(share)); } +spider_db_share *spider_mariadb_create_share( + SPIDER_SHARE *share +) { + DBUG_ENTER("spider_mariadb_create_share"); + DBUG_RETURN(new spider_mariadb_share(share)); +} + spider_db_handler *spider_mysql_create_handler( ha_spider *spider, spider_db_share *db_share ) { DBUG_ENTER("spider_mysql_create_handler"); DBUG_RETURN(new spider_mysql_handler(spider, - (spider_mysql_share *) db_share)); + (spider_mbase_share *) db_share)); +} + +spider_db_handler *spider_mariadb_create_handler( + ha_spider *spider, + spider_db_share *db_share +) { + DBUG_ENTER("spider_mariadb_create_handler"); + DBUG_RETURN(new spider_mariadb_handler(spider, + (spider_mbase_share *) db_share)); } spider_db_copy_table *spider_mysql_create_copy_table( @@ -224,7 +255,15 @@ spider_db_copy_table *spider_mysql_create_copy_table( ) { DBUG_ENTER("spider_mysql_create_copy_table"); DBUG_RETURN(new spider_mysql_copy_table( - (spider_mysql_share *) db_share)); + (spider_mbase_share *) db_share)); +} + +spider_db_copy_table *spider_mariadb_create_copy_table( + spider_db_share *db_share +) { + DBUG_ENTER("spider_mariadb_create_copy_table"); + DBUG_RETURN(new spider_mariadb_copy_table( + (spider_mbase_share *) db_share)); } SPIDER_DB_CONN *spider_mysql_create_conn( @@ -234,13 +273,24 @@ SPIDER_DB_CONN *spider_mysql_create_conn( DBUG_RETURN(new spider_db_mysql(conn)); } +SPIDER_DB_CONN *spider_mariadb_create_conn( + SPIDER_CONN *conn +) { + DBUG_ENTER("spider_mariadb_create_conn"); + DBUG_RETURN(new spider_db_mariadb(conn)); +} + bool spider_mysql_support_direct_join( ) { DBUG_ENTER("spider_mysql_support_direct_join"); DBUG_RETURN(TRUE); } -spider_db_mysql_util spider_db_mysql_utility; +bool spider_mariadb_support_direct_join( +) { + DBUG_ENTER("spider_mariadb_support_direct_join"); + DBUG_RETURN(TRUE); +} SPIDER_DBTON spider_dbton_mysql = { 0, @@ -256,18 +306,49 @@ SPIDER_DBTON spider_dbton_mysql = { &spider_db_mysql_utility }; -spider_db_mysql_row::spider_db_mysql_row() : - spider_db_row(spider_dbton_mysql.dbton_id), +SPIDER_DBTON spider_dbton_mariadb = { + 0, + SPIDER_DB_WRAPPER_MARIADB, + SPIDER_DB_ACCESS_TYPE_SQL, + spider_mariadb_init, + spider_mariadb_deinit, + spider_mariadb_create_share, + spider_mariadb_create_handler, + spider_mariadb_create_copy_table, + spider_mariadb_create_conn, + spider_mariadb_support_direct_join, + &spider_db_mariadb_utility +}; + +spider_db_mbase_row::spider_db_mbase_row( + uint dbton_id +) : spider_db_row(dbton_id), row(NULL), lengths(NULL), cloned(FALSE) +{ + DBUG_ENTER("spider_db_mbase_row::spider_db_mbase_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_row::spider_db_mysql_row() : + spider_db_mbase_row(spider_db_mysql_utility.dbton_id) { DBUG_ENTER("spider_db_mysql_row::spider_db_mysql_row"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } -spider_db_mysql_row::~spider_db_mysql_row() +spider_db_mariadb_row::spider_db_mariadb_row() : + spider_db_mbase_row(spider_db_mariadb_utility.dbton_id) { - DBUG_ENTER("spider_db_mysql_row::~spider_db_mysql_row"); + DBUG_ENTER("spider_db_mariadb_row::spider_db_mariadb_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mbase_row::~spider_db_mbase_row() +{ + DBUG_ENTER("spider_db_mbase_row::~spider_db_mbase_row"); DBUG_PRINT("info",("spider this=%p", this)); if (cloned) { @@ -276,11 +357,25 @@ spider_db_mysql_row::~spider_db_mysql_row() DBUG_VOID_RETURN; } -int spider_db_mysql_row::store_to_field( +spider_db_mysql_row::~spider_db_mysql_row() +{ + DBUG_ENTER("spider_db_mysql_row::~spider_db_mysql_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mariadb_row::~spider_db_mariadb_row() +{ + DBUG_ENTER("spider_db_mariadb_row::~spider_db_mariadb_row"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_mbase_row::store_to_field( Field *field, CHARSET_INFO *access_charset ) { - DBUG_ENTER("spider_db_mysql_row::store_to_field"); + DBUG_ENTER("spider_db_mbase_row::store_to_field"); DBUG_PRINT("info",("spider this=%p", this)); if (!*row) { @@ -317,10 +412,10 @@ int spider_db_mysql_row::store_to_field( DBUG_RETURN(0); } -int spider_db_mysql_row::append_to_str( +int spider_db_mbase_row::append_to_str( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_row::append_to_str"); + DBUG_ENTER("spider_db_mbase_row::append_to_str"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(*lengths)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -328,11 +423,11 @@ int spider_db_mysql_row::append_to_str( DBUG_RETURN(0); } -int spider_db_mysql_row::append_escaped_to_str( +int spider_db_mbase_row::append_escaped_to_str( spider_string *str, uint dbton_id ) { - DBUG_ENTER("spider_db_mysql_row::append_escaped_to_str"); + DBUG_ENTER("spider_db_mbase_row::append_escaped_to_str"); DBUG_PRINT("info",("spider this=%p", this)); spider_string tmp_str(*row, *lengths + 1, str->charset()); tmp_str.init_calc_mem(133); @@ -343,50 +438,50 @@ int spider_db_mysql_row::append_escaped_to_str( DBUG_RETURN(0); } -void spider_db_mysql_row::first() +void spider_db_mbase_row::first() { - DBUG_ENTER("spider_db_mysql_row::first"); + DBUG_ENTER("spider_db_mbase_row::first"); DBUG_PRINT("info",("spider this=%p", this)); row = row_first; lengths = lengths_first; DBUG_VOID_RETURN; } -void spider_db_mysql_row::next() +void spider_db_mbase_row::next() { - DBUG_ENTER("spider_db_mysql_row::next"); + DBUG_ENTER("spider_db_mbase_row::next"); DBUG_PRINT("info",("spider this=%p", this)); row++; lengths++; DBUG_VOID_RETURN; } -bool spider_db_mysql_row::is_null() +bool spider_db_mbase_row::is_null() { - DBUG_ENTER("spider_db_mysql_row::is_null"); + DBUG_ENTER("spider_db_mbase_row::is_null"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(!(*row)); } -int spider_db_mysql_row::val_int() +int spider_db_mbase_row::val_int() { - DBUG_ENTER("spider_db_mysql_row::val_int"); + DBUG_ENTER("spider_db_mbase_row::val_int"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(*row ? atoi(*row) : 0); } -double spider_db_mysql_row::val_real() +double spider_db_mbase_row::val_real() { - DBUG_ENTER("spider_db_mysql_row::val_real"); + DBUG_ENTER("spider_db_mbase_row::val_real"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(*row ? my_atof(*row) : 0.0); } -my_decimal *spider_db_mysql_row::val_decimal( +my_decimal *spider_db_mbase_row::val_decimal( my_decimal *decimal_value, CHARSET_INFO *access_charset ) { - DBUG_ENTER("spider_db_mysql_row::val_decimal"); + DBUG_ENTER("spider_db_mbase_row::val_decimal"); DBUG_PRINT("info",("spider this=%p", this)); if (!*row) DBUG_RETURN(NULL); @@ -402,16 +497,16 @@ my_decimal *spider_db_mysql_row::val_decimal( DBUG_RETURN(decimal_value); } -SPIDER_DB_ROW *spider_db_mysql_row::clone() +SPIDER_DB_ROW *spider_db_mbase_row::clone() { - spider_db_mysql_row *clone_row; + spider_db_mbase_row *clone_row; char *tmp_char; MYSQL_ROW tmp_row = row_first, ctmp_row; ulong *tmp_lengths = lengths_first; uint row_size, i; - DBUG_ENTER("spider_db_mysql_row::clone"); + DBUG_ENTER("spider_db_mbase_row::clone"); DBUG_PRINT("info",("spider this=%p", this)); - if (!(clone_row = new spider_db_mysql_row())) + if (!(clone_row = new spider_db_mbase_row(dbton_id))) { DBUG_RETURN(NULL); } @@ -464,14 +559,14 @@ SPIDER_DB_ROW *spider_db_mysql_row::clone() DBUG_RETURN((SPIDER_DB_ROW *) clone_row); } -int spider_db_mysql_row::store_to_tmp_table( +int spider_db_mbase_row::store_to_tmp_table( TABLE *tmp_table, spider_string *str ) { uint i; MYSQL_ROW tmp_row = row; ulong *tmp_lengths = lengths; - DBUG_ENTER("spider_db_mysql_row::store_to_tmp_table"); + DBUG_ENTER("spider_db_mbase_row::store_to_tmp_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); for (i = 0; i < field_count; i++) @@ -500,11 +595,11 @@ int spider_db_mysql_row::store_to_tmp_table( DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); } -uint spider_db_mysql_row::get_byte_size() +uint spider_db_mbase_row::get_byte_size() { ulong *tmp_lengths = lengths_first; uint i; - DBUG_ENTER("spider_db_mysql_row::get_byte_size"); + DBUG_ENTER("spider_db_mbase_row::get_byte_size"); DBUG_PRINT("info",("spider this=%p", this)); if (!record_size) { @@ -517,18 +612,37 @@ uint spider_db_mysql_row::get_byte_size() DBUG_RETURN(record_size); } -spider_db_mysql_result::spider_db_mysql_result(SPIDER_DB_CONN *in_db_conn) : - spider_db_result(in_db_conn, spider_dbton_mysql.dbton_id), - db_result(NULL) +spider_db_mbase_result::spider_db_mbase_result( + SPIDER_DB_CONN *in_db_conn +) : spider_db_result(in_db_conn), + db_result(NULL), row(in_db_conn->dbton_id) +{ + DBUG_ENTER("spider_db_mbase_result::spider_db_mbase_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_result::spider_db_mysql_result( + SPIDER_DB_CONN *in_db_conn +) : spider_db_mbase_result(in_db_conn) { DBUG_ENTER("spider_db_mysql_result::spider_db_mysql_result"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } -spider_db_mysql_result::~spider_db_mysql_result() +spider_db_mariadb_result::spider_db_mariadb_result( + SPIDER_DB_CONN *in_db_conn +) : spider_db_mbase_result(in_db_conn) { - DBUG_ENTER("spider_db_mysql_result::~spider_db_mysql_result"); + DBUG_ENTER("spider_db_mariadb_result::spider_db_mariadb_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mbase_result::~spider_db_mbase_result() +{ + DBUG_ENTER("spider_db_mbase_result::~spider_db_mbase_result"); DBUG_PRINT("info",("spider this=%p", this)); if (db_result) { @@ -537,16 +651,30 @@ spider_db_mysql_result::~spider_db_mysql_result() DBUG_VOID_RETURN; } -bool spider_db_mysql_result::has_result() +spider_db_mysql_result::~spider_db_mysql_result() { - DBUG_ENTER("spider_db_mysql_result::has_result"); + DBUG_ENTER("spider_db_mysql_result::~spider_db_mysql_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mariadb_result::~spider_db_mariadb_result() +{ + DBUG_ENTER("spider_db_mariadb_result::~spider_db_mariadb_result"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +bool spider_db_mbase_result::has_result() +{ + DBUG_ENTER("spider_db_mbase_result::has_result"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(db_result); } -void spider_db_mysql_result::free_result() +void spider_db_mbase_result::free_result() { - DBUG_ENTER("spider_db_mysql_result::free_result"); + DBUG_ENTER("spider_db_mbase_result::free_result"); DBUG_PRINT("info",("spider this=%p", this)); /* need 2 times execution design */ if (db_result) @@ -557,24 +685,24 @@ void spider_db_mysql_result::free_result() DBUG_VOID_RETURN; } -SPIDER_DB_ROW *spider_db_mysql_result::current_row() +SPIDER_DB_ROW *spider_db_mbase_result::current_row() { - DBUG_ENTER("spider_db_mysql_result::current_row"); + DBUG_ENTER("spider_db_mbase_result::current_row"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); } -SPIDER_DB_ROW *spider_db_mysql_result::fetch_row() +SPIDER_DB_ROW *spider_db_mbase_result::fetch_row() { - DBUG_ENTER("spider_db_mysql_result::fetch_row"); + DBUG_ENTER("spider_db_mbase_result::fetch_row"); DBUG_PRINT("info",("spider this=%p", this)); if (!(row.row = mysql_fetch_row(db_result))) { - if (mysql_errno(((spider_db_mysql *) db_conn)->db_conn)) + if (mysql_errno(((spider_db_mbase *) db_conn)->db_conn)) { - store_error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn); + store_error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn); my_message(store_error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); } else store_error_num = HA_ERR_END_OF_FILE; DBUG_RETURN(NULL); @@ -587,18 +715,18 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row() DBUG_RETURN((SPIDER_DB_ROW *) &row); } -SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_result_buffer( +SPIDER_DB_ROW *spider_db_mbase_result::fetch_row_from_result_buffer( spider_db_result_buffer *spider_res_buf ) { - DBUG_ENTER("spider_db_mysql_result::fetch_row_from_result_buffer"); + DBUG_ENTER("spider_db_mbase_result::fetch_row_from_result_buffer"); DBUG_PRINT("info",("spider this=%p", this)); if (!(row.row = mysql_fetch_row(db_result))) { - if (mysql_errno(((spider_db_mysql *) db_conn)->db_conn)) + if (mysql_errno(((spider_db_mbase *) db_conn)->db_conn)) { - store_error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn); + store_error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn); my_message(store_error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); } else store_error_num = HA_ERR_END_OF_FILE; DBUG_RETURN(NULL); @@ -611,7 +739,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_result_buffer( DBUG_RETURN((SPIDER_DB_ROW *) &row); } -SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_tmp_table( +SPIDER_DB_ROW *spider_db_mbase_result::fetch_row_from_tmp_table( TABLE *tmp_table ) { uint i; @@ -620,7 +748,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_tmp_table( MYSQL_ROW tmp_row; ulong *tmp_lengths; uint field_count; - DBUG_ENTER("spider_db_mysql_result::fetch_row_from_tmp_table"); + DBUG_ENTER("spider_db_mbase_result::fetch_row_from_tmp_table"); DBUG_PRINT("info",("spider this=%p", this)); tmp_str1.init_calc_mem(117); tmp_str2.init_calc_mem(118); @@ -654,7 +782,7 @@ SPIDER_DB_ROW *spider_db_mysql_result::fetch_row_from_tmp_table( DBUG_RETURN((SPIDER_DB_ROW *) &row); } -int spider_db_mysql_result::fetch_table_status( +int spider_db_mbase_result::fetch_table_status( int mode, ha_rows &records, ulong &mean_rec_length, @@ -680,15 +808,15 @@ int spider_db_mysql_result::fetch_table_status( int time_status; #endif long not_used_long; - DBUG_ENTER("spider_db_mysql_result::fetch_table_status"); + DBUG_ENTER("spider_db_mbase_result::fetch_table_status"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); @@ -941,21 +1069,21 @@ int spider_db_mysql_result::fetch_table_status( DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_table_records( +int spider_db_mbase_result::fetch_table_records( int mode, ha_rows &records ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_table_records"); + DBUG_ENTER("spider_db_mbase_result::fetch_table_records"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); @@ -986,7 +1114,7 @@ int spider_db_mysql_result::fetch_table_records( DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_table_cardinality( +int spider_db_mbase_result::fetch_table_cardinality( int mode, TABLE *table, longlong *cardinality, @@ -996,16 +1124,16 @@ int spider_db_mysql_result::fetch_table_cardinality( int error_num; MYSQL_ROW mysql_row; Field *field; - DBUG_ENTER("spider_db_mysql_result::fetch_table_cardinality"); + DBUG_ENTER("spider_db_mbase_result::fetch_table_cardinality"); DBUG_PRINT("info",("spider this=%p", this)); memset((uchar *) cardinality_upd, 0, sizeof(uchar) * bitmap_size); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } /* no index */ @@ -1074,29 +1202,29 @@ int spider_db_mysql_result::fetch_table_cardinality( mysql_row = mysql_fetch_row(db_result); } } - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_table_mon_status( +int spider_db_mbase_result::fetch_table_mon_status( int &status ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_table_mon_status"); + DBUG_ENTER("spider_db_mbase_result::fetch_table_mon_status"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -1115,21 +1243,21 @@ int spider_db_mysql_result::fetch_table_mon_status( DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_show_master_status( +int spider_db_mbase_result::fetch_show_master_status( const char **binlog_file_name, const char **binlog_pos ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_show_master_status"); + DBUG_ENTER("spider_db_mbase_result::fetch_show_master_status"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); @@ -1146,20 +1274,20 @@ int spider_db_mysql_result::fetch_show_master_status( DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_select_binlog_gtid_pos( +int spider_db_mbase_result::fetch_select_binlog_gtid_pos( const char **gtid_pos ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_select_binlog_gtid_pos"); + DBUG_ENTER("spider_db_mbase_result::fetch_select_binlog_gtid_pos"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); @@ -1174,24 +1302,24 @@ int spider_db_mysql_result::fetch_select_binlog_gtid_pos( DBUG_RETURN(0); } -longlong spider_db_mysql_result::num_rows() +longlong spider_db_mbase_result::num_rows() { - DBUG_ENTER("spider_db_mysql_result::num_rows"); + DBUG_ENTER("spider_db_mbase_result::num_rows"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN((longlong) mysql_num_rows(db_result)); } -uint spider_db_mysql_result::num_fields() +uint spider_db_mbase_result::num_fields() { - DBUG_ENTER("spider_db_mysql_result::num_fields"); + DBUG_ENTER("spider_db_mbase_result::num_fields"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(mysql_num_fields(db_result)); } -void spider_db_mysql_result::move_to_pos( +void spider_db_mbase_result::move_to_pos( longlong pos ) { - DBUG_ENTER("spider_db_mysql_result::move_to_pos"); + DBUG_ENTER("spider_db_mbase_result::move_to_pos"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider pos=%lld", pos)); /* @@ -1201,31 +1329,31 @@ void spider_db_mysql_result::move_to_pos( DBUG_VOID_RETURN; } -int spider_db_mysql_result::get_errno() +int spider_db_mbase_result::get_errno() { - DBUG_ENTER("spider_db_mysql_result::get_errno"); + DBUG_ENTER("spider_db_mbase_result::get_errno"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); DBUG_RETURN(store_error_num); } #ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_db_mysql_result::fetch_columns_for_discover_table_structure( +int spider_db_mbase_result::fetch_columns_for_discover_table_structure( spider_string *str, CHARSET_INFO *access_charset ) { int error_num; uint length; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_columns_for_discover_table_structure"); + DBUG_ENTER("spider_db_mbase_result::fetch_columns_for_discover_table_structure"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -1327,30 +1455,30 @@ int spider_db_mysql_result::fetch_columns_for_discover_table_structure( } str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } while ((mysql_row = mysql_fetch_row(db_result))); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_index_for_discover_table_structure( +int spider_db_mbase_result::fetch_index_for_discover_table_structure( spider_string *str, CHARSET_INFO *access_charset ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_index_for_discover_table_structure"); + DBUG_ENTER("spider_db_mbase_result::fetch_index_for_discover_table_structure"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(0); @@ -1519,10 +1647,10 @@ int spider_db_mysql_result::fetch_index_for_discover_table_structure( else using_hash = FALSE; } while ((mysql_row = mysql_fetch_row(db_result))); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } if (!first) @@ -1540,22 +1668,22 @@ int spider_db_mysql_result::fetch_index_for_discover_table_structure( DBUG_RETURN(0); } -int spider_db_mysql_result::fetch_table_for_discover_table_structure( +int spider_db_mbase_result::fetch_table_for_discover_table_structure( spider_string *str, SPIDER_SHARE *spider_share, CHARSET_INFO *access_charset ) { int error_num; MYSQL_ROW mysql_row; - DBUG_ENTER("spider_db_mysql_result::fetch_table_for_discover_table_structure"); + DBUG_ENTER("spider_db_mbase_result::fetch_table_for_discover_table_structure"); DBUG_PRINT("info",("spider this=%p", this)); if (!(mysql_row = mysql_fetch_row(db_result))) { DBUG_PRINT("info",("spider fetch row is null")); - if ((error_num = mysql_errno(((spider_db_mysql *) db_conn)->db_conn))) + if ((error_num = mysql_errno(((spider_db_mbase *) db_conn)->db_conn))) { my_message(error_num, - mysql_error(((spider_db_mysql *) db_conn)->db_conn), MYF(0)); + mysql_error(((spider_db_mbase *) db_conn)->db_conn), MYF(0)); DBUG_RETURN(error_num); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -1581,20 +1709,39 @@ int spider_db_mysql_result::fetch_table_for_discover_table_structure( } #endif -spider_db_mysql::spider_db_mysql( - SPIDER_CONN *conn -) : spider_db_conn(conn), lock_table_hash_inited(FALSE), - handler_open_array_inited(FALSE) +spider_db_mbase::spider_db_mbase( + SPIDER_CONN *conn, + spider_db_mbase_util *spider_db_mbase_utility +) : spider_db_conn(conn), spider_db_mbase_utility(spider_db_mbase_utility), + lock_table_hash_inited(FALSE), handler_open_array_inited(FALSE) { - DBUG_ENTER("spider_db_mysql::spider_db_mysql"); + DBUG_ENTER("spider_db_mbase::spider_db_mbase"); DBUG_PRINT("info",("spider this=%p", this)); db_conn = NULL; DBUG_VOID_RETURN; } -spider_db_mysql::~spider_db_mysql() +spider_db_mysql::spider_db_mysql( + SPIDER_CONN *conn +) : spider_db_mbase(conn, &spider_db_mysql_utility) { - DBUG_ENTER("spider_db_mysql::~spider_db_mysql"); + DBUG_ENTER("spider_db_mysql::spider_db_mysql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mariadb::spider_db_mariadb( + SPIDER_CONN *conn +) : spider_db_mbase(conn, &spider_db_mariadb_utility) +{ + DBUG_ENTER("spider_db_mariadb::spider_db_mariadb"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mbase::~spider_db_mbase() +{ + DBUG_ENTER("spider_db_mbase::~spider_db_mbase"); DBUG_PRINT("info",("spider this=%p", this)); if (handler_open_array_inited) { @@ -1616,9 +1763,23 @@ spider_db_mysql::~spider_db_mysql() DBUG_VOID_RETURN; } -int spider_db_mysql::init() +spider_db_mysql::~spider_db_mysql() { - DBUG_ENTER("spider_db_mysql::init"); + DBUG_ENTER("spider_db_mysql::~spider_db_mysql"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mariadb::~spider_db_mariadb() +{ + DBUG_ENTER("spider_db_mariadb::~spider_db_mariadb"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_mbase::init() +{ + DBUG_ENTER("spider_db_mbase::init"); DBUG_PRINT("info",("spider this=%p", this)); if ( my_hash_init(&lock_table_hash, spd_charset_utf8_bin, 32, 0, 0, @@ -1648,21 +1809,21 @@ int spider_db_mysql::init() DBUG_RETURN(0); } -bool spider_db_mysql::is_connected() +bool spider_db_mbase::is_connected() { - DBUG_ENTER("spider_db_mysql::is_connected"); + DBUG_ENTER("spider_db_mbase::is_connected"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(db_conn); } -void spider_db_mysql::bg_connect() +void spider_db_mbase::bg_connect() { - DBUG_ENTER("spider_db_mysql::bg_connect"); + DBUG_ENTER("spider_db_mbase::bg_connect"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } -int spider_db_mysql::connect( +int spider_db_mbase::connect( char *tgt_host, char *tgt_username, char *tgt_password, @@ -1674,7 +1835,7 @@ int spider_db_mysql::connect( ) { int error_num; my_bool connect_mutex = spider_param_connect_mutex(); - DBUG_ENTER("spider_db_mysql::connect"); + DBUG_ENTER("spider_db_mbase::connect"); DBUG_PRINT("info",("spider this=%p", this)); while (TRUE) { @@ -1795,25 +1956,25 @@ int spider_db_mysql::connect( DBUG_RETURN(0); } -int spider_db_mysql::ping( +int spider_db_mbase::ping( ) { - DBUG_ENTER("spider_db_mysql::ping"); + DBUG_ENTER("spider_db_mbase::ping"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_param_dry_access()) DBUG_RETURN(0); DBUG_RETURN(simple_command(db_conn, COM_PING, 0, 0, 0)); } -void spider_db_mysql::bg_disconnect() +void spider_db_mbase::bg_disconnect() { - DBUG_ENTER("spider_db_mysql::bg_disconnect"); + DBUG_ENTER("spider_db_mbase::bg_disconnect"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } -void spider_db_mysql::disconnect() +void spider_db_mbase::disconnect() { - DBUG_ENTER("spider_db_mysql::disconnect"); + DBUG_ENTER("spider_db_mbase::disconnect"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider db_conn=%p", db_conn)); if (db_conn) @@ -1824,9 +1985,9 @@ void spider_db_mysql::disconnect() DBUG_VOID_RETURN; } -int spider_db_mysql::set_net_timeout() +int spider_db_mbase::set_net_timeout() { - DBUG_ENTER("spider_db_mysql::set_net_timeout"); + DBUG_ENTER("spider_db_mbase::set_net_timeout"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider conn=%p", conn)); my_net_set_read_timeout(&db_conn->net, conn->net_read_timeout); @@ -1834,14 +1995,14 @@ int spider_db_mysql::set_net_timeout() DBUG_RETURN(0); } -int spider_db_mysql::exec_query( +int spider_db_mbase::exec_query( const char *query, uint length, int quick_mode ) { int error_num = 0; uint log_result_errors = spider_param_log_result_errors(); - DBUG_ENTER("spider_db_mysql::exec_query"); + DBUG_ENTER("spider_db_mbase::exec_query"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_param_general_log()) { @@ -1945,30 +2106,30 @@ int spider_db_mysql::exec_query( DBUG_RETURN(error_num); } -int spider_db_mysql::get_errno() +int spider_db_mbase::get_errno() { - DBUG_ENTER("spider_db_mysql::get_errno"); + DBUG_ENTER("spider_db_mbase::get_errno"); DBUG_PRINT("info",("spider this=%p", this)); stored_error = mysql_errno(db_conn); DBUG_PRINT("info",("spider stored_error=%d", stored_error)); DBUG_RETURN(stored_error); } -const char *spider_db_mysql::get_error() +const char *spider_db_mbase::get_error() { const char *error_ptr; - DBUG_ENTER("spider_db_mysql::get_error"); + DBUG_ENTER("spider_db_mbase::get_error"); DBUG_PRINT("info",("spider this=%p", this)); error_ptr = mysql_error(db_conn); DBUG_PRINT("info",("spider error=%s", error_ptr)); DBUG_RETURN(error_ptr); } -bool spider_db_mysql::is_server_gone_error( +bool spider_db_mbase::is_server_gone_error( int error_num ) { bool server_gone; - DBUG_ENTER("spider_db_mysql::is_server_gone_error"); + DBUG_ENTER("spider_db_mbase::is_server_gone_error"); DBUG_PRINT("info",("spider this=%p", this)); server_gone = (error_num == CR_SERVER_GONE_ERROR || error_num == CR_SERVER_LOST); @@ -1976,11 +2137,11 @@ bool spider_db_mysql::is_server_gone_error( DBUG_RETURN(server_gone); } -bool spider_db_mysql::is_dup_entry_error( +bool spider_db_mbase::is_dup_entry_error( int error_num ) { bool dup_entry; - DBUG_ENTER("spider_db_mysql::is_dup_entry_error"); + DBUG_ENTER("spider_db_mbase::is_dup_entry_error"); DBUG_PRINT("info",("spider this=%p", this)); dup_entry = ( @@ -1992,11 +2153,11 @@ bool spider_db_mysql::is_dup_entry_error( DBUG_RETURN(dup_entry); } -bool spider_db_mysql::is_xa_nota_error( +bool spider_db_mbase::is_xa_nota_error( int error_num ) { bool xa_nota; - DBUG_ENTER("spider_db_mysql::is_xa_nota_error"); + DBUG_ENTER("spider_db_mbase::is_xa_nota_error"); DBUG_PRINT("info",("spider this=%p", this)); xa_nota = ( @@ -2008,10 +2169,10 @@ bool spider_db_mysql::is_xa_nota_error( DBUG_RETURN(xa_nota); } -void spider_db_mysql::print_warnings( +void spider_db_mbase::print_warnings( struct tm *l_time ) { - DBUG_ENTER("spider_db_mysql::print_warnings"); + DBUG_ENTER("spider_db_mbase::print_warnings"); DBUG_PRINT("info",("spider this=%p", this)); if (db_conn->status == MYSQL_STATUS_READY) { @@ -2083,16 +2244,16 @@ void spider_db_mysql::print_warnings( DBUG_VOID_RETURN; } -spider_db_result *spider_db_mysql::store_result( +spider_db_result *spider_db_mbase::store_result( spider_db_result_buffer **spider_res_buf, st_spider_db_request_key *request_key, int *error_num ) { - spider_db_mysql_result *result; - DBUG_ENTER("spider_db_mysql::store_result"); + spider_db_mbase_result *result; + DBUG_ENTER("spider_db_mbase::store_result"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(!spider_res_buf); - if ((result = new spider_db_mysql_result(this))) + if ((result = new spider_db_mbase_result(this))) { *error_num = 0; if ( @@ -2111,14 +2272,14 @@ spider_db_result *spider_db_mysql::store_result( DBUG_RETURN(result); } -spider_db_result *spider_db_mysql::use_result( +spider_db_result *spider_db_mbase::use_result( st_spider_db_request_key *request_key, int *error_num ) { - spider_db_mysql_result *result; - DBUG_ENTER("spider_db_mysql::use_result"); + spider_db_mbase_result *result; + DBUG_ENTER("spider_db_mbase::use_result"); DBUG_PRINT("info",("spider this=%p", this)); - if ((result = new spider_db_mysql_result(this))) + if ((result = new spider_db_mbase_result(this))) { *error_num = 0; if ( @@ -2136,10 +2297,10 @@ spider_db_result *spider_db_mysql::use_result( DBUG_RETURN(result); } -int spider_db_mysql::next_result() +int spider_db_mbase::next_result() { int status; - DBUG_ENTER("spider_db_mysql::next_result"); + DBUG_ENTER("spider_db_mbase::next_result"); DBUG_PRINT("info",("spider this=%p", this)); if (db_conn->status != MYSQL_STATUS_READY) { @@ -2165,10 +2326,10 @@ int spider_db_mysql::next_result() DBUG_RETURN(-1); } -uint spider_db_mysql::affected_rows() +uint spider_db_mbase::affected_rows() { MYSQL *last_used_con; - DBUG_ENTER("spider_db_mysql::affected_rows"); + DBUG_ENTER("spider_db_mbase::affected_rows"); DBUG_PRINT("info",("spider this=%p", this)); #if MYSQL_VERSION_ID < 50500 last_used_con = db_conn->last_used_con; @@ -2178,10 +2339,10 @@ uint spider_db_mysql::affected_rows() DBUG_RETURN((uint) last_used_con->affected_rows); } -ulonglong spider_db_mysql::last_insert_id() +ulonglong spider_db_mbase::last_insert_id() { MYSQL *last_used_con; - DBUG_ENTER("spider_db_mysql::last_insert_id"); + DBUG_ENTER("spider_db_mbase::last_insert_id"); DBUG_PRINT("info",("spider this=%p", this)); #if MYSQL_VERSION_ID < 50500 last_used_con = db_conn->last_used_con; @@ -2191,30 +2352,30 @@ ulonglong spider_db_mysql::last_insert_id() DBUG_RETURN((uint) last_used_con->insert_id); } -int spider_db_mysql::set_character_set( +int spider_db_mbase::set_character_set( const char *csname ) { - DBUG_ENTER("spider_db_mysql::set_character_set"); + DBUG_ENTER("spider_db_mbase::set_character_set"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_param_dry_access()) DBUG_RETURN(0); DBUG_RETURN(mysql_set_character_set(db_conn, csname)); } -int spider_db_mysql::select_db( +int spider_db_mbase::select_db( const char *dbname ) { - DBUG_ENTER("spider_db_mysql::select_db"); + DBUG_ENTER("spider_db_mbase::select_db"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_param_dry_access()) DBUG_RETURN(0); DBUG_RETURN(mysql_select_db(db_conn, dbname)); } -int spider_db_mysql::consistent_snapshot( +int spider_db_mbase::consistent_snapshot( int *need_mon ) { - DBUG_ENTER("spider_db_mysql::consistent_snapshot"); + DBUG_ENTER("spider_db_mbase::consistent_snapshot"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_db_query( conn, @@ -2229,17 +2390,17 @@ int spider_db_mysql::consistent_snapshot( DBUG_RETURN(0); } -bool spider_db_mysql::trx_start_in_bulk_sql() +bool spider_db_mbase::trx_start_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::trx_start_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::trx_start_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::start_transaction( +int spider_db_mbase::start_transaction( int *need_mon ) { - DBUG_ENTER("spider_db_mysql::start_transaction"); + DBUG_ENTER("spider_db_mbase::start_transaction"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_db_query( conn, @@ -2254,10 +2415,10 @@ int spider_db_mysql::start_transaction( DBUG_RETURN(0); } -int spider_db_mysql::commit( +int spider_db_mbase::commit( int *need_mon ) { - DBUG_ENTER("spider_db_mysql::commit"); + DBUG_ENTER("spider_db_mbase::commit"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_db_query( conn, @@ -2272,12 +2433,12 @@ int spider_db_mysql::commit( DBUG_RETURN(0); } -int spider_db_mysql::rollback( +int spider_db_mbase::rollback( int *need_mon ) { bool is_error; int error_num; - DBUG_ENTER("spider_db_mysql::rollback"); + DBUG_ENTER("spider_db_mbase::rollback"); DBUG_PRINT("info",("spider this=%p", this)); conn->mta_conn_mutex_unlock_later = TRUE; if (spider_db_query( @@ -2307,30 +2468,30 @@ int spider_db_mysql::rollback( DBUG_RETURN(0); } -int spider_db_mysql::xa_start( +int spider_db_mbase::xa_start( XID *xid, int *need_mon ) { - DBUG_ENTER("spider_db_mysql::xa_start"); + DBUG_ENTER("spider_db_mbase::xa_start"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -bool spider_db_mysql::xa_start_in_bulk_sql() +bool spider_db_mbase::xa_start_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::xa_start_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::xa_start_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::xa_end( +int spider_db_mbase::xa_end( XID *xid, int *need_mon ) { char sql_buf[SPIDER_SQL_XA_END_LEN + XIDDATASIZE + sizeof(long) + 9]; spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); - DBUG_ENTER("spider_db_mysql::xa_end"); + DBUG_ENTER("spider_db_mbase::xa_end"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(108); @@ -2350,13 +2511,13 @@ int spider_db_mysql::xa_end( DBUG_RETURN(0); } -int spider_db_mysql::xa_prepare( +int spider_db_mbase::xa_prepare( XID *xid, int *need_mon ) { char sql_buf[SPIDER_SQL_XA_PREPARE_LEN + XIDDATASIZE + sizeof(long) + 9]; spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); - DBUG_ENTER("spider_db_mysql::xa_prepare"); + DBUG_ENTER("spider_db_mbase::xa_prepare"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(109); @@ -2376,13 +2537,13 @@ int spider_db_mysql::xa_prepare( DBUG_RETURN(0); } -int spider_db_mysql::xa_commit( +int spider_db_mbase::xa_commit( XID *xid, int *need_mon ) { char sql_buf[SPIDER_SQL_XA_COMMIT_LEN + XIDDATASIZE + sizeof(long) + 9]; spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); - DBUG_ENTER("spider_db_mysql::xa_commit"); + DBUG_ENTER("spider_db_mbase::xa_commit"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(110); @@ -2402,13 +2563,13 @@ int spider_db_mysql::xa_commit( DBUG_RETURN(0); } -int spider_db_mysql::xa_rollback( +int spider_db_mbase::xa_rollback( XID *xid, int *need_mon ) { char sql_buf[SPIDER_SQL_XA_ROLLBACK_LEN + XIDDATASIZE + sizeof(long) + 9]; spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); - DBUG_ENTER("spider_db_mysql::xa_rollback"); + DBUG_ENTER("spider_db_mbase::xa_rollback"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(111); @@ -2428,18 +2589,18 @@ int spider_db_mysql::xa_rollback( DBUG_RETURN(0); } -bool spider_db_mysql::set_trx_isolation_in_bulk_sql() +bool spider_db_mbase::set_trx_isolation_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::set_trx_isolation_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::set_trx_isolation_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::set_trx_isolation( +int spider_db_mbase::set_trx_isolation( int trx_isolation, int *need_mon ) { - DBUG_ENTER("spider_db_mysql::set_trx_isolation"); + DBUG_ENTER("spider_db_mbase::set_trx_isolation"); DBUG_PRINT("info",("spider this=%p", this)); switch (trx_isolation) { @@ -2497,18 +2658,18 @@ int spider_db_mysql::set_trx_isolation( DBUG_RETURN(0); } -bool spider_db_mysql::set_autocommit_in_bulk_sql() +bool spider_db_mbase::set_autocommit_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::set_autocommit_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::set_autocommit_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::set_autocommit( +int spider_db_mbase::set_autocommit( bool autocommit, int *need_mon ) { - DBUG_ENTER("spider_db_mysql::set_autocommit"); + DBUG_ENTER("spider_db_mbase::set_autocommit"); DBUG_PRINT("info",("spider this=%p", this)); if (autocommit) { @@ -2537,18 +2698,18 @@ int spider_db_mysql::set_autocommit( DBUG_RETURN(0); } -bool spider_db_mysql::set_sql_log_off_in_bulk_sql() +bool spider_db_mbase::set_sql_log_off_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::set_sql_log_off_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::set_sql_log_off_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::set_sql_log_off( +int spider_db_mbase::set_sql_log_off( bool sql_log_off, int *need_mon ) { - DBUG_ENTER("spider_db_mysql::set_sql_log_off"); + DBUG_ENTER("spider_db_mbase::set_sql_log_off"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_log_off) { @@ -2577,21 +2738,21 @@ int spider_db_mysql::set_sql_log_off( DBUG_RETURN(0); } -bool spider_db_mysql::set_time_zone_in_bulk_sql() +bool spider_db_mbase::set_time_zone_in_bulk_sql() { - DBUG_ENTER("spider_db_mysql::set_time_zone_in_bulk_sql"); + DBUG_ENTER("spider_db_mbase::set_time_zone_in_bulk_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_db_mysql::set_time_zone( +int spider_db_mbase::set_time_zone( Time_zone *time_zone, int *need_mon ) { const String *tz_str = time_zone->get_name(); char sql_buf[MAX_FIELD_WIDTH]; spider_string sql_str(sql_buf, sizeof(sql_buf), &my_charset_bin); - DBUG_ENTER("spider_db_mysql::set_time_zone"); + DBUG_ENTER("spider_db_mbase::set_time_zone"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(214); sql_str.length(0); @@ -2614,7 +2775,7 @@ int spider_db_mysql::set_time_zone( DBUG_RETURN(0); } -int spider_db_mysql::exec_simple_sql_with_result( +int spider_db_mbase::exec_simple_sql_with_result( SPIDER_TRX *trx, SPIDER_SHARE *share, const char *sql, @@ -2624,7 +2785,7 @@ int spider_db_mysql::exec_simple_sql_with_result( SPIDER_DB_RESULT **res ) { int error_num; - DBUG_ENTER("spider_db_mysql::exec_simple_sql_with_result"); + DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result"); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; @@ -2714,7 +2875,7 @@ int spider_db_mysql::exec_simple_sql_with_result( DBUG_RETURN(0); } -int spider_db_mysql::show_master_status( +int spider_db_mbase::show_master_status( SPIDER_TRX *trx, SPIDER_SHARE *share, int all_link_idx, @@ -2728,7 +2889,7 @@ int spider_db_mysql::show_master_status( int error_num; const char *binlog_file_name, *binlog_pos; uint binlog_file_name_length, binlog_pos_length; - DBUG_ENTER("spider_db_mysql::show_master_status"); + DBUG_ENTER("spider_db_mbase::show_master_status"); if ((error_num = exec_simple_sql_with_result(trx, share, SPIDER_SQL_SHOW_MASTER_STATUS_STR, SPIDER_SQL_SHOW_MASTER_STATUS_LEN, all_link_idx, need_mon, res1)) @@ -2737,7 +2898,7 @@ int spider_db_mysql::show_master_status( DBUG_RETURN(error_num); } - if (!(error_num = ((spider_db_mysql_result *)*res1)->fetch_show_master_status( + if (!(error_num = ((spider_db_mbase_result *)*res1)->fetch_show_master_status( &binlog_file_name, &binlog_pos)) ) { binlog_file_name_length = strlen(binlog_file_name); @@ -2776,7 +2937,7 @@ int spider_db_mysql::show_master_status( DBUG_RETURN(0); } -int spider_db_mysql::select_binlog_gtid_pos( +int spider_db_mbase::select_binlog_gtid_pos( SPIDER_TRX *trx, SPIDER_SHARE *share, int all_link_idx, @@ -2792,7 +2953,7 @@ int spider_db_mysql::select_binlog_gtid_pos( int error_num; size_t length; const char *gtid_pos; - DBUG_ENTER("spider_db_mysql::select_binlog_gtid_pos"); + DBUG_ENTER("spider_db_mbase::select_binlog_gtid_pos"); str->length(0); if (str->reserve( SPIDER_SQL_BINLOG_GTID_POS_LEN + @@ -2829,7 +2990,7 @@ int spider_db_mysql::select_binlog_gtid_pos( DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); } - if (!(error_num = ((spider_db_mysql_result *)*res)->fetch_select_binlog_gtid_pos(>id_pos))) + if (!(error_num = ((spider_db_mbase_result *)*res)->fetch_select_binlog_gtid_pos(>id_pos))) { spider_store_binlog_pos_gtid(table, gtid_pos, strlen(gtid_pos), conn->access_charset); } @@ -2846,18 +3007,18 @@ int spider_db_mysql::select_binlog_gtid_pos( } #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_db_mysql::append_sql( +int spider_db_mbase::append_sql( char *sql, ulong sql_length, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_sql"); + DBUG_ENTER("spider_db_mbase::append_sql"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_db_mysql::append_open_handler( +int spider_db_mbase::append_open_handler( uint handler_id, const char *db_name, const char *table_name, @@ -2865,13 +3026,13 @@ int spider_db_mysql::append_open_handler( const char *sql, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_open_handler"); + DBUG_ENTER("spider_db_mbase::append_open_handler"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_db_mysql::append_select( +int spider_db_mbase::append_select( uint handler_id, spider_string *sql, SPIDER_DB_HS_STRING_REF_BUFFER *keys, @@ -2879,24 +3040,24 @@ int spider_db_mysql::append_select( int skip, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_select"); + DBUG_ENTER("spider_db_mbase::append_select"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_db_mysql::append_insert( +int spider_db_mbase::append_insert( uint handler_id, SPIDER_DB_HS_STRING_REF_BUFFER *upds, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_insert"); + DBUG_ENTER("spider_db_mbase::append_insert"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_db_mysql::append_update( +int spider_db_mbase::append_update( uint handler_id, spider_string *sql, SPIDER_DB_HS_STRING_REF_BUFFER *keys, @@ -2907,13 +3068,13 @@ int spider_db_mysql::append_update( bool decrement, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_update"); + DBUG_ENTER("spider_db_mbase::append_update"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_db_mysql::append_delete( +int spider_db_mbase::append_delete( uint handler_id, spider_string *sql, SPIDER_DB_HS_STRING_REF_BUFFER *keys, @@ -2921,27 +3082,27 @@ int spider_db_mysql::append_delete( int skip, st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::append_delete"); + DBUG_ENTER("spider_db_mbase::append_delete"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -void spider_db_mysql::reset_request_queue() +void spider_db_mbase::reset_request_queue() { - DBUG_ENTER("spider_db_mysql::reset_request_queue"); + DBUG_ENTER("spider_db_mbase::reset_request_queue"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_VOID_RETURN; } #endif -size_t spider_db_mysql::escape_string( +size_t spider_db_mbase::escape_string( char *to, const char *from, size_t from_length ) { - DBUG_ENTER("spider_db_mysql::escape_string"); + DBUG_ENTER("spider_db_mbase::escape_string"); DBUG_PRINT("info",("spider this=%p", this)); if (db_conn->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) DBUG_RETURN(escape_quotes_for_mysql(db_conn->charset, to, 0, @@ -2950,14 +3111,14 @@ size_t spider_db_mysql::escape_string( from, from_length)); } -bool spider_db_mysql::have_lock_table_list() +bool spider_db_mbase::have_lock_table_list() { - DBUG_ENTER("spider_db_mysql::have_lock_table_list"); + DBUG_ENTER("spider_db_mbase::have_lock_table_list"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(lock_table_hash.records); } -int spider_db_mysql::append_lock_tables( +int spider_db_mbase::append_lock_tables( spider_string *str ) { int error_num; @@ -2972,9 +3133,9 @@ int spider_db_mysql::append_lock_tables( const char *table_name; uint table_name_length; CHARSET_INFO *table_name_charset; - DBUG_ENTER("spider_db_mysql::lock_tables"); + DBUG_ENTER("spider_db_mbase::lock_tables"); DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_mysql_utility.append_lock_table_head(str))) + if ((error_num = spider_db_mbase_utility->append_lock_table_head(str))) { DBUG_RETURN(error_num); } @@ -3003,7 +3164,7 @@ int spider_db_mysql::append_lock_tables( DBUG_RETURN(0); } conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; - spider_mysql_share *db_share = (spider_mysql_share *) + spider_mbase_share *db_share = (spider_mbase_share *) tmp_spider->share->dbton_share[conn->dbton_id]; if (&db_share->db_names_str[conn_link_idx]) { @@ -3026,7 +3187,7 @@ int spider_db_mysql::append_lock_tables( tmp_spider->share->tgt_table_names_lengths[conn_link_idx]; table_name_charset = system_charset_info; } - if ((error_num = spider_db_mysql_utility. + if ((error_num = spider_db_mbase_utility-> append_lock_table_body( str, db_name, @@ -3048,54 +3209,54 @@ int spider_db_mysql::append_lock_tables( my_hash_delete(&lock_table_hash, (uchar*) tmp_link_for_hash); #endif } - if ((error_num = spider_db_mysql_utility.append_lock_table_tail(str))) + if ((error_num = spider_db_mbase_utility->append_lock_table_tail(str))) { DBUG_RETURN(error_num); } DBUG_RETURN(0); } -int spider_db_mysql::append_unlock_tables( +int spider_db_mbase::append_unlock_tables( spider_string *str ) { int error_num; - DBUG_ENTER("spider_db_mysql::append_unlock_tables"); + DBUG_ENTER("spider_db_mbase::append_unlock_tables"); DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_mysql_utility.append_unlock_table(str))) + if ((error_num = spider_db_mbase_utility->append_unlock_table(str))) { DBUG_RETURN(error_num); } DBUG_RETURN(0); } -uint spider_db_mysql::get_lock_table_hash_count() +uint spider_db_mbase::get_lock_table_hash_count() { - DBUG_ENTER("spider_db_mysql::get_lock_table_hash_count"); + DBUG_ENTER("spider_db_mbase::get_lock_table_hash_count"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(lock_table_hash.records); } -void spider_db_mysql::reset_lock_table_hash() +void spider_db_mbase::reset_lock_table_hash() { - DBUG_ENTER("spider_db_mysql::reset_lock_table_hash"); + DBUG_ENTER("spider_db_mbase::reset_lock_table_hash"); DBUG_PRINT("info",("spider this=%p", this)); my_hash_reset(&lock_table_hash); DBUG_VOID_RETURN; } -uint spider_db_mysql::get_opened_handler_count() +uint spider_db_mbase::get_opened_handler_count() { - DBUG_ENTER("spider_db_mysql::get_opened_handler_count"); + DBUG_ENTER("spider_db_mbase::get_opened_handler_count"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(handler_open_array.elements); } -void spider_db_mysql::reset_opened_handler() +void spider_db_mbase::reset_opened_handler() { ha_spider *tmp_spider; int tmp_link_idx; SPIDER_LINK_FOR_HASH **tmp_link_for_hash; - DBUG_ENTER("spider_db_mysql::reset_opened_handler"); + DBUG_ENTER("spider_db_mbase::reset_opened_handler"); DBUG_PRINT("info",("spider this=%p", this)); while ((tmp_link_for_hash = (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) @@ -3107,7 +3268,7 @@ void spider_db_mysql::reset_opened_handler() DBUG_VOID_RETURN; } -void spider_db_mysql::set_dup_key_idx( +void spider_db_mbase::set_dup_key_idx( ha_spider *spider, int link_idx ) { @@ -3116,7 +3277,7 @@ void spider_db_mysql::set_dup_key_idx( int key_name_length; int max_length = 0; const char *key_name; - DBUG_ENTER("spider_db_mysql::set_dup_key_idx"); + DBUG_ENTER("spider_db_mbase::set_dup_key_idx"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider error_str=%s", conn->error_str)); for (roop_count = 0; roop_count < table->s->keys; roop_count++) @@ -3156,21 +3317,42 @@ void spider_db_mysql::set_dup_key_idx( DBUG_VOID_RETURN; } -bool spider_db_mysql::cmp_request_key_to_snd( +bool spider_db_mbase::cmp_request_key_to_snd( st_spider_db_request_key *request_key ) { - DBUG_ENTER("spider_db_mysql::cmp_request_key_to_snd"); + DBUG_ENTER("spider_db_mbase::cmp_request_key_to_snd"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -spider_db_mysql_util::spider_db_mysql_util() : spider_db_util() +spider_db_mbase_util::spider_db_mbase_util() : spider_db_util() +{ + DBUG_ENTER("spider_db_mbase_util::spider_db_mbase_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mysql_util::spider_db_mysql_util() : spider_db_mbase_util() { DBUG_ENTER("spider_db_mysql_util::spider_db_mysql_util"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } +spider_db_mariadb_util::spider_db_mariadb_util() : spider_db_mbase_util() +{ + DBUG_ENTER("spider_db_mariadb_util::spider_db_mariadb_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_db_mbase_util::~spider_db_mbase_util() +{ + DBUG_ENTER("spider_db_mbase_util::~spider_db_mbase_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + spider_db_mysql_util::~spider_db_mysql_util() { DBUG_ENTER("spider_db_mysql_util::~spider_db_mysql_util"); @@ -3178,25 +3360,32 @@ spider_db_mysql_util::~spider_db_mysql_util() DBUG_VOID_RETURN; } -int spider_db_mysql_util::append_name( +spider_db_mariadb_util::~spider_db_mariadb_util() +{ + DBUG_ENTER("spider_db_mariadb_util::~spider_db_mariadb_util"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_db_mbase_util::append_name( spider_string *str, const char *name, uint name_length ) { - DBUG_ENTER("spider_db_mysql_util::append_name"); + DBUG_ENTER("spider_db_mbase_util::append_name"); str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); str->q_append(name, name_length); str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); DBUG_RETURN(0); } -int spider_db_mysql_util::append_name_with_charset( +int spider_db_mbase_util::append_name_with_charset( spider_string *str, const char *name, uint name_length, CHARSET_INFO *name_charset ) { - DBUG_ENTER("spider_db_mysql_util::append_name_with_charset"); + DBUG_ENTER("spider_db_mbase_util::append_name_with_charset"); if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); @@ -3207,17 +3396,17 @@ int spider_db_mysql_util::append_name_with_charset( DBUG_RETURN(0); } -bool spider_db_mysql_util::is_name_quote( +bool spider_db_mbase_util::is_name_quote( const char head_code ) { - DBUG_ENTER("spider_db_mysql_util::is_name_quote"); + DBUG_ENTER("spider_db_mbase_util::is_name_quote"); DBUG_RETURN(head_code == *name_quote_str); } -int spider_db_mysql_util::append_escaped_name_quote( +int spider_db_mbase_util::append_escaped_name_quote( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_escaped_name_quote"); + DBUG_ENTER("spider_db_mbase_util::append_escaped_name_quote"); if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); @@ -3225,7 +3414,7 @@ int spider_db_mysql_util::append_escaped_name_quote( DBUG_RETURN(0); } -int spider_db_mysql_util::append_column_value( +int spider_db_mbase_util::append_column_value( ha_spider *spider, spider_string *str, Field *field, @@ -3238,7 +3427,7 @@ int spider_db_mysql_util::append_column_value( uint length; THD *thd = field->table->in_use; Time_zone *saved_time_zone = thd->variables.time_zone; - DBUG_ENTER("spider_db_mysql_util::append_column_value"); + DBUG_ENTER("spider_db_mbase_util::append_column_value"); tmp_str.init_calc_mem(113); thd->variables.time_zone = UTC; @@ -3403,7 +3592,7 @@ int spider_db_mysql_util::append_column_value( DBUG_RETURN(0); } -int spider_db_mysql_util::append_from_with_alias( +int spider_db_mbase_util::append_from_with_alias( spider_string *str, const char **table_names, uint *table_name_lengths, @@ -3414,7 +3603,7 @@ int spider_db_mysql_util::append_from_with_alias( bool over_write ) { uint roop_count, length = 0; - DBUG_ENTER("spider_db_mysql_util::append_from_with_alias"); + DBUG_ENTER("spider_db_mbase_util::append_from_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); if (!over_write) { @@ -3437,11 +3626,11 @@ int spider_db_mysql_util::append_from_with_alias( DBUG_RETURN(0); } -int spider_db_mysql_util::append_trx_isolation( +int spider_db_mbase_util::append_trx_isolation( spider_string *str, int trx_isolation ) { - DBUG_ENTER("spider_db_mysql_util::append_trx_isolation"); + DBUG_ENTER("spider_db_mbase_util::append_trx_isolation"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN)) @@ -3474,11 +3663,11 @@ int spider_db_mysql_util::append_trx_isolation( DBUG_RETURN(0); } -int spider_db_mysql_util::append_autocommit( +int spider_db_mbase_util::append_autocommit( spider_string *str, bool autocommit ) { - DBUG_ENTER("spider_db_mysql_util::append_autocommit"); + DBUG_ENTER("spider_db_mbase_util::append_autocommit"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_AUTOCOMMIT_OFF_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3497,11 +3686,11 @@ int spider_db_mysql_util::append_autocommit( DBUG_RETURN(0); } -int spider_db_mysql_util::append_sql_log_off( +int spider_db_mbase_util::append_sql_log_off( spider_string *str, bool sql_log_off ) { - DBUG_ENTER("spider_db_mysql_util::append_sql_log_off"); + DBUG_ENTER("spider_db_mbase_util::append_sql_log_off"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_SQL_LOG_OFF_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3518,12 +3707,12 @@ int spider_db_mysql_util::append_sql_log_off( DBUG_RETURN(0); } -int spider_db_mysql_util::append_time_zone( +int spider_db_mbase_util::append_time_zone( spider_string *str, Time_zone *time_zone ) { const String *tz_str = time_zone->get_name(); - DBUG_ENTER("spider_db_mysql_util::append_time_zone"); + DBUG_ENTER("spider_db_mbase_util::append_time_zone"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_TIME_ZONE_LEN + tz_str->length() + SPIDER_SQL_VALUE_QUOTE_LEN)) @@ -3536,10 +3725,10 @@ int spider_db_mysql_util::append_time_zone( DBUG_RETURN(0); } -int spider_db_mysql_util::append_start_transaction( +int spider_db_mbase_util::append_start_transaction( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_start_transaction"); + DBUG_ENTER("spider_db_mbase_util::append_start_transaction"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_START_TRANSACTION_LEN)) @@ -3553,11 +3742,11 @@ int spider_db_mysql_util::append_start_transaction( DBUG_RETURN(0); } -int spider_db_mysql_util::append_xa_start( +int spider_db_mbase_util::append_xa_start( spider_string *str, XID *xid ) { - DBUG_ENTER("spider_db_mysql_util::append_xa_start"); + DBUG_ENTER("spider_db_mbase_util::append_xa_start"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SEMICOLON_LEN + SPIDER_SQL_XA_START_LEN + XIDDATASIZE + sizeof(long) + 9)) @@ -3571,10 +3760,10 @@ int spider_db_mysql_util::append_xa_start( DBUG_RETURN(0); } -int spider_db_mysql_util::append_lock_table_head( +int spider_db_mbase_util::append_lock_table_head( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_lock_table_head"); + DBUG_ENTER("spider_db_mbase_util::append_lock_table_head"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_LOCK_TABLE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3582,7 +3771,7 @@ int spider_db_mysql_util::append_lock_table_head( DBUG_RETURN(0); } -int spider_db_mysql_util::append_lock_table_body( +int spider_db_mbase_util::append_lock_table_body( spider_string *str, const char *db_name, uint db_name_length, @@ -3592,7 +3781,7 @@ int spider_db_mysql_util::append_lock_table_body( CHARSET_INFO *table_name_charset, int lock_type ) { - DBUG_ENTER("spider_db_mysql_util::append_lock_table_body"); + DBUG_ENTER("spider_db_mbase_util::append_lock_table_body"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) { @@ -3621,19 +3810,19 @@ int spider_db_mysql_util::append_lock_table_body( DBUG_RETURN(0); } -int spider_db_mysql_util::append_lock_table_tail( +int spider_db_mbase_util::append_lock_table_tail( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_lock_table_tail"); + DBUG_ENTER("spider_db_mbase_util::append_lock_table_tail"); DBUG_PRINT("info",("spider this=%p", this)); str->length(str->length() - SPIDER_SQL_COMMA_LEN); DBUG_RETURN(0); } -int spider_db_mysql_util::append_unlock_table( +int spider_db_mbase_util::append_unlock_table( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_unlock_table"); + DBUG_ENTER("spider_db_mbase_util::append_unlock_table"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_UNLOCK_TABLE_LEN)) { @@ -3643,7 +3832,7 @@ int spider_db_mysql_util::append_unlock_table( DBUG_RETURN(0); } -int spider_db_mysql_util::open_item_func( +int spider_db_mbase_util::open_item_func( Item_func *item_func, ha_spider *spider, spider_string *str, @@ -3652,7 +3841,6 @@ int spider_db_mysql_util::open_item_func( bool use_fields, spider_fields *fields ) { - uint dbton_id = spider_dbton_mysql.dbton_id; int error_num; Item *item, **item_list = item_func->arguments(); Field *field; @@ -3665,7 +3853,7 @@ int spider_db_mysql_util::open_item_func( last_str_length = SPIDER_SQL_NULL_CHAR_LEN; int use_pushdown_udf; bool merge_func = FALSE; - DBUG_ENTER("spider_db_mysql_util::open_item_func"); + DBUG_ENTER("spider_db_mbase_util::open_item_func"); if (str) { if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) @@ -4730,7 +4918,7 @@ int spider_db_mysql_util::open_item_func( } #ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_db_mysql_util::open_item_sum_func( +int spider_db_mbase_util::open_item_sum_func( Item_sum *item_sum, ha_spider *spider, spider_string *str, @@ -4739,10 +4927,9 @@ int spider_db_mysql_util::open_item_sum_func( bool use_fields, spider_fields *fields ) { - uint dbton_id = spider_dbton_mysql.dbton_id; uint roop_count, item_count = item_sum->get_arg_count(); int error_num; - DBUG_ENTER("spider_db_mysql_util::open_item_sum_func"); + DBUG_ENTER("spider_db_mbase_util::open_item_sum_func"); DBUG_PRINT("info",("spider Sumfunctype = %d", item_sum->sum_func())); switch (item_sum->sum_func()) { @@ -4848,11 +5035,11 @@ int spider_db_mysql_util::open_item_sum_func( } #endif -int spider_db_mysql_util::append_escaped_util( +int spider_db_mbase_util::append_escaped_util( spider_string *to, String *from ) { - DBUG_ENTER("spider_db_mysql_util::append_escaped_util"); + DBUG_ENTER("spider_db_mbase_util::append_escaped_util"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider from=%s", from->charset()->csname)); DBUG_PRINT("info",("spider to=%s", to->charset()->csname)); @@ -4861,7 +5048,7 @@ int spider_db_mysql_util::append_escaped_util( } #ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_db_mysql_util::append_table( +int spider_db_mbase_util::append_table( ha_spider *spider, spider_fields *fields, spider_string *str, @@ -4874,13 +5061,12 @@ int spider_db_mysql_util::append_table( ) { int error_num; bool use_cond_table_list = FALSE; - spider_mysql_share *db_share; - spider_mysql_handler *dbton_hdl; + spider_mbase_share *db_share; + spider_mbase_handler *dbton_hdl; SPIDER_TABLE_HOLDER *table_holder; - uint dbton_id = spider_dbton_mysql.dbton_id; TABLE_LIST *cond_table_list = *cond_table_list_ptr; ha_spider *spd; - DBUG_ENTER("spider_db_mysql_util::append_table"); + DBUG_ENTER("spider_db_mbase_util::append_table"); DBUG_PRINT("info",("spider table_list=%p", table_list)); DBUG_PRINT("info",("spider table_list->outer_join=%u", table_list->outer_join)); @@ -4987,9 +5173,9 @@ int spider_db_mysql_util::append_table( { table_holder = fields->get_table_holder(table_list->table); spd = table_holder->spider; - db_share = (spider_mysql_share *) + db_share = (spider_mbase_share *) spd->share->dbton_share[dbton_id]; - dbton_hdl = (spider_mysql_handler *) + dbton_hdl = (spider_mbase_handler *) spd->dbton_handler[dbton_id]; dbton_hdl->table_name_pos = str->length(); @@ -5084,7 +5270,7 @@ int spider_db_mysql_util::append_table( DBUG_RETURN(0); } -int spider_db_mysql_util::append_tables_top_down( +int spider_db_mbase_util::append_tables_top_down( ha_spider *spider, spider_fields *fields, spider_string *str, @@ -5097,7 +5283,7 @@ int spider_db_mysql_util::append_tables_top_down( uint outer_join_backup; TABLE_LIST *cur_table_list, *prev_table_list = NULL, *cond_table_list = NULL; bool first; - DBUG_ENTER("spider_db_mysql_util::append_tables_top_down"); + DBUG_ENTER("spider_db_mbase_util::append_tables_top_down"); DBUG_PRINT("info",("spider this=%p", this)); if ( table_list->outer_join || @@ -5223,7 +5409,7 @@ int spider_db_mysql_util::append_tables_top_down( str->q_append(SPIDER_SQL_ON_STR, SPIDER_SQL_ON_LEN); } if ((error_num = spider_db_print_item_type(on_expr, NULL, - spider, str, NULL, 0, spider_dbton_mysql.dbton_id, TRUE, fields))) + spider, str, NULL, 0, dbton_id, TRUE, fields))) { DBUG_RETURN(error_num); } @@ -5232,14 +5418,14 @@ int spider_db_mysql_util::append_tables_top_down( DBUG_RETURN(0); } -int spider_db_mysql_util::append_tables_top_down_check( +int spider_db_mbase_util::append_tables_top_down_check( TABLE_LIST *table_list, TABLE_LIST **used_table_list, uint *current_pos ) { int error_num; TABLE_LIST *cur_table_list; - DBUG_ENTER("spider_db_mysql_util::append_tables_top_down_check"); + DBUG_ENTER("spider_db_mbase_util::append_tables_top_down_check"); DBUG_PRINT("info",("spider this=%p", this)); List_iterator_fast it1(table_list->nested_join->join_list); while ((cur_table_list = it1++)) @@ -5256,7 +5442,7 @@ int spider_db_mysql_util::append_tables_top_down_check( DBUG_RETURN(0); } -int spider_db_mysql_util::append_embedding_tables( +int spider_db_mbase_util::append_embedding_tables( ha_spider *spider, spider_fields *fields, spider_string *str, @@ -5267,7 +5453,7 @@ int spider_db_mysql_util::append_embedding_tables( ) { int error_num; TABLE_LIST *embedding = table_list->embedding; - DBUG_ENTER("spider_db_mysql_util::append_embedding_tables"); + DBUG_ENTER("spider_db_mbase_util::append_embedding_tables"); DBUG_PRINT("info",("spider this=%p", this)); if (embedding) { @@ -5310,7 +5496,7 @@ int spider_db_mysql_util::append_embedding_tables( DBUG_RETURN(0); } -int spider_db_mysql_util::append_from_and_tables( +int spider_db_mbase_util::append_from_and_tables( ha_spider *spider, spider_fields *fields, spider_string *str, @@ -5322,7 +5508,7 @@ int spider_db_mysql_util::append_from_and_tables( TABLE *table; TABLE_LIST **used_table_list, *prev_table_list = NULL, *cond_table_list = NULL; - DBUG_ENTER("spider_db_mysql_util::append_from_and_tables"); + DBUG_ENTER("spider_db_mbase_util::append_from_and_tables"); DBUG_PRINT("info",("spider this=%p", this)); used_table_list = (TABLE_LIST **) my_alloca(sizeof(TABLE_LIST *) * table_count); @@ -5387,19 +5573,19 @@ int spider_db_mysql_util::append_from_and_tables( DBUG_RETURN(0); } -int spider_db_mysql_util::reappend_tables( +int spider_db_mbase_util::reappend_tables( spider_fields *fields, SPIDER_LINK_IDX_CHAIN *link_idx_chain, spider_string *str ) { int error_num; - uint dbton_id = spider_dbton_mysql.dbton_id, length; + uint32 length; ha_spider *spider; - spider_mysql_share *db_share; - spider_mysql_handler *dbton_hdl; + spider_mbase_share *db_share; + spider_mbase_handler *dbton_hdl; SPIDER_TABLE_HOLDER *table_holder; SPIDER_LINK_IDX_HOLDER *link_idx_holder; - DBUG_ENTER("spider_db_mysql_util::reappend_tables"); + DBUG_ENTER("spider_db_mbase_util::reappend_tables"); DBUG_PRINT("info",("spider this=%p", this)); length = str->length(); fields->set_pos_to_first_table_on_link_idx_chain(link_idx_chain); @@ -5409,11 +5595,11 @@ int spider_db_mysql_util::reappend_tables( link_idx_holder = fields->get_next_table_on_link_idx_chain(link_idx_chain); spider = table_holder->spider; - db_share = (spider_mysql_share *) + db_share = (spider_mbase_share *) spider->share->dbton_share[dbton_id]; if (!db_share->same_db_table_name) { - dbton_hdl = (spider_mysql_handler *) spider->dbton_handler[dbton_id]; + dbton_hdl = (spider_mbase_handler *) spider->dbton_handler[dbton_id]; str->length(dbton_hdl->table_name_pos); if ((error_num = db_share->append_table_name_with_adjusting(str, spider->conn_link_idx[link_idx_holder->link_idx]))) @@ -5426,10 +5612,10 @@ int spider_db_mysql_util::reappend_tables( DBUG_RETURN(0); } -int spider_db_mysql_util::append_where( +int spider_db_mbase_util::append_where( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_where"); + DBUG_ENTER("spider_db_mbase_util::append_where"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_WHERE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -5437,10 +5623,10 @@ int spider_db_mysql_util::append_where( DBUG_RETURN(0); } -int spider_db_mysql_util::append_having( +int spider_db_mbase_util::append_having( spider_string *str ) { - DBUG_ENTER("spider_db_mysql_util::append_having"); + DBUG_ENTER("spider_db_mbase_util::append_having"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_HAVING_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -5449,11 +5635,15 @@ int spider_db_mysql_util::append_having( } #endif -spider_mysql_share::spider_mysql_share( - st_spider_share *share +spider_mbase_share::spider_mbase_share( + st_spider_share *share, + uint dbton_id, + spider_db_mbase_util *spider_db_mbase_utility ) : spider_db_share( - share + share, + dbton_id ), + spider_db_mbase_utility(spider_db_mbase_utility), table_select(NULL), table_select_pos(0), key_select(NULL), @@ -5474,16 +5664,39 @@ spider_mysql_share::spider_mysql_share( same_db_table_name(TRUE), first_all_link_idx(-1) { - DBUG_ENTER("spider_mysql_share::spider_mysql_share"); + DBUG_ENTER("spider_mbase_share::spider_mbase_share"); DBUG_PRINT("info",("spider this=%p", this)); spider_alloc_calc_mem_init(mem_calc, 71); spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); DBUG_VOID_RETURN; } -spider_mysql_share::~spider_mysql_share() +spider_mysql_share::spider_mysql_share( + st_spider_share *share +) : spider_mbase_share( + share, + spider_db_mysql_utility.dbton_id, + &spider_db_mysql_utility +) { + DBUG_ENTER("spider_mysql_share::spider_mysql_share"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} +spider_mariadb_share::spider_mariadb_share( + st_spider_share *share +) : spider_mbase_share( + share, + spider_db_mariadb_utility.dbton_id, + &spider_db_mariadb_utility +) { + DBUG_ENTER("spider_mariadb_share::spider_mariadb_share"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mbase_share::~spider_mbase_share() { - DBUG_ENTER("spider_mysql_share::~spider_mysql_share"); + DBUG_ENTER("spider_mbase_share::~spider_mbase_share"); DBUG_PRINT("info",("spider this=%p", this)); if (table_select) delete [] table_select; @@ -5504,13 +5717,27 @@ spider_mysql_share::~spider_mysql_share() DBUG_VOID_RETURN; } -int spider_mysql_share::init() +spider_mysql_share::~spider_mysql_share() +{ + DBUG_ENTER("spider_mysql_share::~spider_mysql_share"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mariadb_share::~spider_mariadb_share() +{ + DBUG_ENTER("spider_mariadb_share::~spider_mariadb_share"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_mbase_share::init() { int error_num; uint roop_count; TABLE_SHARE *table_share = spider_share->table_share; uint keys = table_share ? table_share->keys : 0; - DBUG_ENTER("spider_mysql_share::init"); + DBUG_ENTER("spider_mbase_share::init"); DBUG_PRINT("info",("spider this=%p", this)); if (!(key_select_pos = (int *) spider_bulk_alloc_mem(spider_current_trx, 112, @@ -5571,33 +5798,33 @@ int spider_mysql_share::init() DBUG_RETURN(error_num); } -uint spider_mysql_share::get_column_name_length( +uint spider_mbase_share::get_column_name_length( uint field_index ) { - DBUG_ENTER("spider_mysql_share::get_column_name_length"); + DBUG_ENTER("spider_mbase_share::get_column_name_length"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(column_name_str[field_index].length()); } -int spider_mysql_share::append_column_name( +int spider_mbase_share::append_column_name( spider_string *str, uint field_index ) { int error_num; - DBUG_ENTER("spider_mysql_share::append_column_name"); + DBUG_ENTER("spider_mbase_share::append_column_name"); DBUG_PRINT("info",("spider this=%p", this)); - error_num = spider_db_mysql_utility.append_name(str, + error_num = spider_db_mbase_utility->append_name(str, column_name_str[field_index].ptr(), column_name_str[field_index].length()); DBUG_RETURN(error_num); } -int spider_mysql_share::append_column_name_with_alias( +int spider_mbase_share::append_column_name_with_alias( spider_string *str, uint field_index, const char *alias, uint alias_length ) { - DBUG_ENTER("spider_mysql_share::append_column_name_with_alias"); + DBUG_ENTER("spider_mbase_share::append_column_name_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve( alias_length + @@ -5609,7 +5836,7 @@ int spider_mysql_share::append_column_name_with_alias( DBUG_RETURN(0); } -int spider_mysql_share::append_table_name( +int spider_mbase_share::append_table_name( spider_string *str, int all_link_idx ) { @@ -5617,20 +5844,20 @@ int spider_mysql_share::append_table_name( uint db_nm_len = db_names_str[all_link_idx].length(); const char *table_nm = table_names_str[all_link_idx].ptr(); uint table_nm_len = table_names_str[all_link_idx].length(); - DBUG_ENTER("spider_mysql_share::append_table_name"); + DBUG_ENTER("spider_mbase_share::append_table_name"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + spider_db_mbase_utility->append_name(str, db_nm, db_nm_len); str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); - spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + spider_db_mbase_utility->append_name(str, table_nm, table_nm_len); DBUG_RETURN(0); } -int spider_mysql_share::append_table_name_with_adjusting( +int spider_mbase_share::append_table_name_with_adjusting( spider_string *str, int all_link_idx ) { @@ -5640,11 +5867,11 @@ int spider_mysql_share::append_table_name_with_adjusting( const char *table_nm = table_names_str[all_link_idx].ptr(); uint table_nm_len = table_names_str[all_link_idx].length(); uint table_nm_max_len = table_nm_max_length; - DBUG_ENTER("spider_mysql_share::append_table_name_with_adjusting"); + DBUG_ENTER("spider_mbase_share::append_table_name_with_adjusting"); DBUG_PRINT("info",("spider this=%p", this)); - spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + spider_db_mbase_utility->append_name(str, db_nm, db_nm_len); str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); - spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + spider_db_mbase_utility->append_name(str, table_nm, table_nm_len); uint length = db_nm_max_len - db_nm_len + table_nm_max_len - table_nm_len; @@ -5653,7 +5880,7 @@ int spider_mysql_share::append_table_name_with_adjusting( DBUG_RETURN(0); } -int spider_mysql_share::append_from_with_adjusted_table_name( +int spider_mbase_share::append_from_with_adjusted_table_name( spider_string *str, int *table_name_pos ) { @@ -5663,7 +5890,7 @@ int spider_mysql_share::append_from_with_adjusted_table_name( const char *table_nm = table_names_str[0].ptr(); uint table_nm_len = table_names_str[0].length(); uint table_nm_max_len = table_nm_max_length; - DBUG_ENTER("spider_mysql_share::append_from_with_adjusted_table_name"); + DBUG_ENTER("spider_mbase_share::append_from_with_adjusted_table_name"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_FROM_LEN + db_nm_max_length + SPIDER_SQL_DOT_LEN + table_nm_max_length + @@ -5673,9 +5900,9 @@ int spider_mysql_share::append_from_with_adjusted_table_name( } str->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN); *table_name_pos = str->length(); - spider_db_mysql_utility.append_name(str, db_nm, db_nm_len); + spider_db_mbase_utility->append_name(str, db_nm, db_nm_len); str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); - spider_db_mysql_utility.append_name(str, table_nm, table_nm_len); + spider_db_mbase_utility->append_name(str, table_nm, table_nm_len); uint length = db_nm_max_len - db_nm_len + table_nm_max_len - table_nm_len; @@ -5684,14 +5911,13 @@ int spider_mysql_share::append_from_with_adjusted_table_name( DBUG_RETURN(0); } -int spider_mysql_share::create_table_names_str() +int spider_mbase_share::create_table_names_str() { int error_num, roop_count; uint table_nm_len, db_nm_len; spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; char *first_tbl_nm, *first_db_nm; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_share::create_table_names_str"); + DBUG_ENTER("spider_mbase_share::create_table_names_str"); table_names_str = NULL; db_names_str = NULL; db_table_str = NULL; @@ -5822,9 +6048,9 @@ error: DBUG_RETURN(error_num); } -void spider_mysql_share::free_table_names_str() +void spider_mbase_share::free_table_names_str() { - DBUG_ENTER("spider_mysql_share::free_table_names_str"); + DBUG_ENTER("spider_mbase_share::free_table_names_str"); if (db_table_str) { delete [] db_table_str; @@ -5843,14 +6069,13 @@ void spider_mysql_share::free_table_names_str() DBUG_VOID_RETURN; } -int spider_mysql_share::create_column_name_str() +int spider_mbase_share::create_column_name_str() { spider_string *str; int error_num; Field **field; TABLE_SHARE *table_share = spider_share->table_share; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_share::create_column_name_str"); + DBUG_ENTER("spider_mbase_share::create_column_name_str"); if ( table_share->fields && !(column_name_str = new spider_string[table_share->fields]) @@ -5876,9 +6101,9 @@ error: DBUG_RETURN(error_num); } -void spider_mysql_share::free_column_name_str() +void spider_mbase_share::free_column_name_str() { - DBUG_ENTER("spider_mysql_share::free_column_name_str"); + DBUG_ENTER("spider_mbase_share::free_column_name_str"); if (column_name_str) { delete [] column_name_str; @@ -5887,12 +6112,12 @@ void spider_mysql_share::free_column_name_str() DBUG_VOID_RETURN; } -int spider_mysql_share::convert_key_hint_str() +int spider_mbase_share::convert_key_hint_str() { spider_string *tmp_key_hint; int roop_count; TABLE_SHARE *table_share = spider_share->table_share; - DBUG_ENTER("spider_mysql_share::convert_key_hint_str"); + DBUG_ENTER("spider_mbase_share::convert_key_hint_str"); if (spider_share->access_charset->cset != system_charset_info->cset) { /* need conversion */ @@ -5915,11 +6140,10 @@ int spider_mysql_share::convert_key_hint_str() DBUG_RETURN(0); } -int spider_mysql_share::append_show_table_status() +int spider_mbase_share::append_show_table_status() { int roop_count; spider_string *str; - uint dbton_id = spider_dbton_mysql.dbton_id; DBUG_ENTER("spider_mysql_append_show_table_status"); if (!(show_table_status = new spider_string[2 * spider_share->all_link_count])) @@ -5987,7 +6211,7 @@ error: DBUG_RETURN(HA_ERR_OUT_OF_MEM); } -void spider_mysql_share::free_show_table_status() +void spider_mbase_share::free_show_table_status() { DBUG_ENTER("spider_mysql_free_show_table_status"); if (show_table_status) @@ -5998,12 +6222,11 @@ void spider_mysql_share::free_show_table_status() DBUG_VOID_RETURN; } -int spider_mysql_share::append_show_records() +int spider_mbase_share::append_show_records() { int roop_count; spider_string *str; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_share::append_show_records"); + DBUG_ENTER("spider_mbase_share::append_show_records"); if (!(show_records = new spider_string[spider_share->all_link_count])) goto error; @@ -6038,9 +6261,9 @@ error: DBUG_RETURN(HA_ERR_OUT_OF_MEM); } -void spider_mysql_share::free_show_records() +void spider_mbase_share::free_show_records() { - DBUG_ENTER("spider_mysql_share::free_show_records"); + DBUG_ENTER("spider_mbase_share::free_show_records"); if (show_records) { delete [] show_records; @@ -6049,12 +6272,11 @@ void spider_mysql_share::free_show_records() DBUG_VOID_RETURN; } -int spider_mysql_share::append_show_index() +int spider_mbase_share::append_show_index() { int roop_count; spider_string *str; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_share::append_show_index"); + DBUG_ENTER("spider_mbase_share::append_show_index"); if (!(show_index = new spider_string[2 * spider_share->all_link_count])) goto error; @@ -6113,9 +6335,9 @@ error: DBUG_RETURN(HA_ERR_OUT_OF_MEM); } -void spider_mysql_share::free_show_index() +void spider_mbase_share::free_show_index() { - DBUG_ENTER("spider_mysql_share::free_show_index"); + DBUG_ENTER("spider_mbase_share::free_show_index"); if (show_index) { delete [] show_index; @@ -6124,13 +6346,13 @@ void spider_mysql_share::free_show_index() DBUG_VOID_RETURN; } -int spider_mysql_share::append_table_select() +int spider_mbase_share::append_table_select() { Field **field; uint field_length; spider_string *str = table_select; TABLE_SHARE *table_share = spider_share->table_share; - DBUG_ENTER("spider_mysql_share::append_table_select"); + DBUG_ENTER("spider_mbase_share::append_table_select"); if (!*table_share->field) DBUG_RETURN(0); @@ -6148,7 +6370,7 @@ int spider_mysql_share::append_table_select() DBUG_RETURN(append_from_with_adjusted_table_name(str, &table_select_pos)); } -int spider_mysql_share::append_key_select( +int spider_mbase_share::append_key_select( uint idx ) { KEY_PART_INFO *key_part; @@ -6158,7 +6380,7 @@ int spider_mysql_share::append_key_select( spider_string *str = &key_select[idx]; TABLE_SHARE *table_share = spider_share->table_share; const KEY *key_info = &table_share->key_info[idx]; - DBUG_ENTER("spider_mysql_share::append_key_select"); + DBUG_ENTER("spider_mbase_share::append_key_select"); if (!spider_user_defined_key_parts(key_info)) DBUG_RETURN(0); @@ -6178,14 +6400,14 @@ int spider_mysql_share::append_key_select( DBUG_RETURN(append_from_with_adjusted_table_name(str, &key_select_pos[idx])); } -bool spider_mysql_share::need_change_db_table_name() +bool spider_mbase_share::need_change_db_table_name() { - DBUG_ENTER("spider_mysql_share::need_change_db_table_name"); + DBUG_ENTER("spider_mbase_share::need_change_db_table_name"); DBUG_RETURN(!same_db_table_name); } #ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_mysql_share::discover_table_structure( +int spider_mbase_share::discover_table_structure( SPIDER_TRX *trx, SPIDER_SHARE *spider_share, spider_string *str @@ -6193,9 +6415,8 @@ int spider_mysql_share::discover_table_structure( int roop_count, error_num = HA_ERR_WRONG_COMMAND; char sql_buf[MAX_FIELD_WIDTH]; spider_string sql_str(sql_buf, sizeof(sql_buf), system_charset_info); - uint dbton_id = spider_dbton_mysql.dbton_id; uint strlen = str->length(); - DBUG_ENTER("spider_mysql_share::discover_table_structure"); + DBUG_ENTER("spider_mbase_share::discover_table_structure"); DBUG_PRINT("info",("spider this=%p", this)); sql_str.init_calc_mem(228); for (roop_count = 0; roop_count < (int) spider_share->all_link_count; @@ -6454,13 +6675,15 @@ int spider_mysql_share::discover_table_structure( } #endif -spider_mysql_handler::spider_mysql_handler( +spider_mbase_handler::spider_mbase_handler( ha_spider *spider, - spider_mysql_share *db_share + spider_mbase_share *db_share, + spider_db_mbase_util *spider_db_mbase_utility ) : spider_db_handler( spider, db_share ), + spider_db_mbase_utility(spider_db_mbase_utility), where_pos(0), order_pos(0), limit_pos(0), @@ -6484,16 +6707,42 @@ spider_mysql_handler::spider_mysql_handler( mysql_share(db_share), link_for_hash(NULL) { - DBUG_ENTER("spider_mysql_handler::spider_mysql_handler"); + DBUG_ENTER("spider_mbase_handler::spider_mbase_handler"); DBUG_PRINT("info",("spider this=%p", this)); spider_alloc_calc_mem_init(mem_calc, 183); spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); DBUG_VOID_RETURN; } -spider_mysql_handler::~spider_mysql_handler() +spider_mysql_handler::spider_mysql_handler( + ha_spider *spider, + spider_mbase_share *db_share +) : spider_mbase_handler( + spider, + db_share, + &spider_db_mysql_utility +) { + DBUG_ENTER("spider_mysql_handler::spider_mysql_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mariadb_handler::spider_mariadb_handler( + ha_spider *spider, + spider_mbase_share *db_share +) : spider_mbase_handler( + spider, + db_share, + &spider_db_mariadb_utility +) { + DBUG_ENTER("spider_mariadb_handler::spider_mariadb_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mbase_handler::~spider_mbase_handler() { - DBUG_ENTER("spider_mysql_handler::~spider_mysql_handler"); + DBUG_ENTER("spider_mbase_handler::~spider_mbase_handler"); DBUG_PRINT("info",("spider this=%p", this)); while (union_table_name_pos_first) { @@ -6509,7 +6758,21 @@ spider_mysql_handler::~spider_mysql_handler() DBUG_VOID_RETURN; } -int spider_mysql_handler::init() +spider_mysql_handler::~spider_mysql_handler() +{ + DBUG_ENTER("spider_mysql_handler::~spider_mysql_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mariadb_handler::~spider_mariadb_handler() +{ + DBUG_ENTER("spider_mariadb_handler::~spider_mariadb_handler"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_mbase_handler::init() { uint roop_count; THD *thd = spider->trx->thd; @@ -6517,7 +6780,7 @@ int spider_mysql_handler::init() int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); TABLE *table = spider->get_table(); - DBUG_ENTER("spider_mysql_handler::init"); + DBUG_ENTER("spider_mbase_handler::init"); DBUG_PRINT("info",("spider this=%p", this)); sql.init_calc_mem(59); sql_part.init_calc_mem(60); @@ -6572,7 +6835,7 @@ int spider_mysql_handler::init() } -int spider_mysql_handler::append_index_hint( +int spider_mbase_handler::append_index_hint( spider_string *str, int link_idx, ulong sql_type @@ -6583,7 +6846,7 @@ int spider_mysql_handler::append_index_hint( Index_hint *hint; // THD *thd = current_thd; int error_num = 0; - DBUG_ENTER("spider_mysql_handler::append_index_hint"); + DBUG_ENTER("spider_mbase_handler::append_index_hint"); DBUG_PRINT("info",("spider this=%p", this)); while(index_hints && (hint = iter++)) @@ -6626,13 +6889,13 @@ int spider_mysql_handler::append_index_hint( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_table_name_with_adjusting( +int spider_mbase_handler::append_table_name_with_adjusting( spider_string *str, int link_idx, ulong sql_type ) { int error_num = 0; - DBUG_ENTER("spider_mysql_handler::append_table_name_with_adjusting"); + DBUG_ENTER("spider_mbase_handler::append_table_name_with_adjusting"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type == SPIDER_SQL_TYPE_HANDLER) { @@ -6644,7 +6907,7 @@ int spider_mysql_handler::append_table_name_with_adjusting( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_column_types( +int spider_mbase_handler::append_key_column_types( const key_range *start_key, spider_string *str ) { @@ -6658,7 +6921,7 @@ int spider_mysql_handler::append_key_column_types( Field *field; char tmp_buf[MAX_FIELD_WIDTH]; spider_string tmp_str(tmp_buf, sizeof(tmp_buf), system_charset_info); - DBUG_ENTER("spider_mysql_handler::append_key_column_types"); + DBUG_ENTER("spider_mbase_handler::append_key_column_types"); DBUG_PRINT("info",("spider this=%p", this)); tmp_str.init_calc_mem(115); @@ -6712,7 +6975,7 @@ int spider_mysql_handler::append_key_column_types( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_join_columns_for_bka( +int spider_mbase_handler::append_key_join_columns_for_bka( const key_range *start_key, spider_string *str, const char **table_aliases, @@ -6727,7 +6990,7 @@ int spider_mysql_handler::append_key_join_columns_for_bka( Field *field; char tmp_buf[MAX_FIELD_WIDTH]; bool start_where = ((int) str->length() == where_pos); - DBUG_ENTER("spider_mysql_handler::append_key_join_columns_for_bka"); + DBUG_ENTER("spider_mbase_handler::append_key_join_columns_for_bka"); DBUG_PRINT("info",("spider this=%p", this)); start_key_part_map = start_key->keypart_map & full_key_part_map; DBUG_PRINT("info", ("spider spider_user_defined_key_parts=%u", @@ -6776,11 +7039,11 @@ int spider_mysql_handler::append_key_join_columns_for_bka( DBUG_RETURN(0); } -int spider_mysql_handler::append_tmp_table_and_sql_for_bka( +int spider_mbase_handler::append_tmp_table_and_sql_for_bka( const key_range *start_key ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_tmp_table_and_sql_for_bka"); + DBUG_ENTER("spider_mbase_handler::append_tmp_table_and_sql_for_bka"); DBUG_PRINT("info",("spider this=%p", this)); char tmp_table_name[MAX_FIELD_WIDTH * 2], tgt_table_name[MAX_FIELD_WIDTH * 2]; @@ -6838,7 +7101,7 @@ int spider_mysql_handler::append_tmp_table_and_sql_for_bka( if ( (error_num = append_select_columns_with_alias(&sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN)) || - (error_num = spider_db_mysql_utility.append_from_with_alias(&sql, + (error_num = spider_db_mbase_utility->append_from_with_alias(&sql, table_names, table_name_lengths, table_aliases, table_alias_lengths, 2, &table_name_pos, FALSE)) @@ -6878,9 +7141,9 @@ int spider_mysql_handler::append_tmp_table_and_sql_for_bka( DBUG_RETURN(0); } -int spider_mysql_handler::reuse_tmp_table_and_sql_for_bka() +int spider_mbase_handler::reuse_tmp_table_and_sql_for_bka() { - DBUG_ENTER("spider_mysql_handler::reuse_tmp_table_and_sql_for_bka"); + DBUG_ENTER("spider_mbase_handler::reuse_tmp_table_and_sql_for_bka"); DBUG_PRINT("info",("spider this=%p", this)); tmp_sql.length(tmp_sql_pos4); sql.length(limit_pos); @@ -6888,13 +7151,13 @@ int spider_mysql_handler::reuse_tmp_table_and_sql_for_bka() DBUG_RETURN(0); } -void spider_mysql_handler::create_tmp_bka_table_name( +void spider_mbase_handler::create_tmp_bka_table_name( char *tmp_table_name, int *tmp_table_name_length, int link_idx ) { uint adjust_length, length; - DBUG_ENTER("spider_mysql_handler::create_tmp_bka_table_name"); + DBUG_ENTER("spider_mbase_handler::create_tmp_bka_table_name"); if (spider_param_bka_table_name_type(current_thd, mysql_share->spider_share-> bka_table_name_types[spider->conn_link_idx[link_idx]]) == 1) @@ -6936,7 +7199,7 @@ void spider_mysql_handler::create_tmp_bka_table_name( DBUG_VOID_RETURN; } -int spider_mysql_handler::append_create_tmp_bka_table( +int spider_mbase_handler::append_create_tmp_bka_table( const key_range *start_key, spider_string *str, char *tmp_table_name, @@ -6951,7 +7214,7 @@ int spider_mysql_handler::append_create_tmp_bka_table( uint bka_engine_length = strlen(bka_engine), cset_length = strlen(table_charset->csname), coll_length = strlen(table_charset->name); - DBUG_ENTER("spider_mysql_handler::append_create_tmp_bka_table"); + DBUG_ENTER("spider_mbase_handler::append_create_tmp_bka_table"); if (str->reserve(SPIDER_SQL_CREATE_TMP_LEN + tmp_table_name_length + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + SPIDER_SQL_ID_TYPE_LEN + SPIDER_SQL_COMMA_LEN)) @@ -6979,7 +7242,7 @@ int spider_mysql_handler::append_create_tmp_bka_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_drop_tmp_bka_table( +int spider_mbase_handler::append_drop_tmp_bka_table( spider_string *str, char *tmp_table_name, int tmp_table_name_length, @@ -6987,7 +7250,7 @@ int spider_mysql_handler::append_drop_tmp_bka_table( int *drop_table_end_pos, bool with_semicolon ) { - DBUG_ENTER("spider_mysql_handler::append_drop_tmp_bka_table"); + DBUG_ENTER("spider_mbase_handler::append_drop_tmp_bka_table"); if (str->reserve(SPIDER_SQL_DROP_TMP_LEN + tmp_table_name_length + (with_semicolon ? SPIDER_SQL_SEMICOLON_LEN : 0))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -7000,7 +7263,7 @@ int spider_mysql_handler::append_drop_tmp_bka_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_insert_tmp_bka_table( +int spider_mbase_handler::append_insert_tmp_bka_table( const key_range *start_key, spider_string *str, char *tmp_table_name, @@ -7008,7 +7271,7 @@ int spider_mysql_handler::append_insert_tmp_bka_table( int *db_name_pos ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_insert_tmp_bka_table"); + DBUG_ENTER("spider_mbase_handler::append_insert_tmp_bka_table"); if (str->reserve(SPIDER_SQL_INSERT_LEN + SPIDER_SQL_INTO_LEN + tmp_table_name_length + SPIDER_SQL_OPEN_PAREN_LEN + SPIDER_SQL_ID_LEN + SPIDER_SQL_COMMA_LEN)) @@ -7031,11 +7294,11 @@ int spider_mysql_handler::append_insert_tmp_bka_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_union_table_and_sql_for_bka( +int spider_mbase_handler::append_union_table_and_sql_for_bka( const key_range *start_key ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_union_table_and_sql_for_bka"); + DBUG_ENTER("spider_mbase_handler::append_union_table_and_sql_for_bka"); DBUG_PRINT("info",("spider this=%p", this)); char tgt_table_name[MAX_FIELD_WIDTH * 2]; spider_string tgt_table_name_str(tgt_table_name, MAX_FIELD_WIDTH * 2, @@ -7082,7 +7345,7 @@ int spider_mysql_handler::append_union_table_and_sql_for_bka( tmp_sql_pos1 = sql.length(); if ( - (error_num = spider_db_mysql_utility.append_from_with_alias(&tmp_sql, + (error_num = spider_db_mbase_utility->append_from_with_alias(&tmp_sql, table_names, table_name_lengths, table_aliases, table_alias_lengths, 2, &table_name_pos, FALSE)) @@ -7124,15 +7387,15 @@ int spider_mysql_handler::append_union_table_and_sql_for_bka( DBUG_RETURN(0); } -int spider_mysql_handler::reuse_union_table_and_sql_for_bka() +int spider_mbase_handler::reuse_union_table_and_sql_for_bka() { - DBUG_ENTER("spider_mysql_handler::reuse_union_table_and_sql_for_bka"); + DBUG_ENTER("spider_mbase_handler::reuse_union_table_and_sql_for_bka"); DBUG_PRINT("info",("spider this=%p", this)); sql.length(tmp_sql_pos1); DBUG_RETURN(0); } -int spider_mysql_handler::append_insert_for_recovery( +int spider_mbase_handler::append_insert_for_recovery( ulong sql_type, int link_idx ) { @@ -7142,7 +7405,7 @@ int spider_mysql_handler::append_insert_for_recovery( uint field_name_length = 0; bool add_value = FALSE; spider_string *insert_sql; - DBUG_ENTER("spider_mysql_handler::append_insert_for_recovery"); + DBUG_ENTER("spider_mbase_handler::append_insert_for_recovery"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type == SPIDER_SQL_TYPE_INSERT_SQL) { @@ -7190,7 +7453,7 @@ int spider_mysql_handler::append_insert_for_recovery( insert_sql->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); } else { if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, insert_sql, *field, NULL, share->access_charset) || insert_sql->reserve(SPIDER_SQL_COMMA_LEN) @@ -7211,13 +7474,13 @@ int spider_mysql_handler::append_insert_for_recovery( DBUG_RETURN(0); } -int spider_mysql_handler::append_update( +int spider_mbase_handler::append_update( const TABLE *table, my_ptrdiff_t ptr_diff ) { int error_num; spider_string *str = &update_sql; - DBUG_ENTER("spider_mysql_handler::append_update"); + DBUG_ENTER("spider_mbase_handler::append_update"); DBUG_PRINT("info",("spider this=%p", this)); if (str->length() > 0) { @@ -7236,7 +7499,7 @@ int spider_mysql_handler::append_update( DBUG_RETURN(0); } -int spider_mysql_handler::append_update( +int spider_mbase_handler::append_update( const TABLE *table, my_ptrdiff_t ptr_diff, int link_idx @@ -7244,7 +7507,7 @@ int spider_mysql_handler::append_update( int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.update_sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::append_update"); + DBUG_ENTER("spider_mbase_handler::append_update"); DBUG_PRINT("info",("spider this=%p", this)); if (str->length() > 0) { @@ -7277,13 +7540,13 @@ int spider_mysql_handler::append_update( DBUG_RETURN(0); } -int spider_mysql_handler::append_delete( +int spider_mbase_handler::append_delete( const TABLE *table, my_ptrdiff_t ptr_diff ) { int error_num; spider_string *str = &update_sql; - DBUG_ENTER("spider_mysql_handler::append_delete"); + DBUG_ENTER("spider_mbase_handler::append_delete"); DBUG_PRINT("info",("spider this=%p", this)); if (str->length() > 0) { @@ -7303,14 +7566,14 @@ int spider_mysql_handler::append_delete( DBUG_RETURN(0); } -int spider_mysql_handler::append_delete( +int spider_mbase_handler::append_delete( const TABLE *table, my_ptrdiff_t ptr_diff, int link_idx ) { int error_num; spider_string *str = &spider->result_list.update_sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::append_delete"); + DBUG_ENTER("spider_mbase_handler::append_delete"); DBUG_PRINT("info",("spider this=%p", this)); if (str->length() > 0) { @@ -7330,21 +7593,21 @@ int spider_mysql_handler::append_delete( DBUG_RETURN(0); } -int spider_mysql_handler::append_insert_part() +int spider_mbase_handler::append_insert_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_insert_part"); + DBUG_ENTER("spider_mbase_handler::append_insert_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_insert(&insert_sql, 0); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_insert( +int spider_mbase_handler::append_insert( spider_string *str, int link_idx ) { SPIDER_SHARE *share = spider->share; - DBUG_ENTER("spider_mysql_handler::append_insert"); + DBUG_ENTER("spider_mbase_handler::append_insert"); if ( ( spider->write_can_replace || @@ -7408,20 +7671,20 @@ int spider_mysql_handler::append_insert( DBUG_RETURN(0); } -int spider_mysql_handler::append_update_part() +int spider_mbase_handler::append_update_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_update_part"); + DBUG_ENTER("spider_mbase_handler::append_update_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_update(&update_sql, 0); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_update( +int spider_mbase_handler::append_update( spider_string *str, int link_idx ) { - DBUG_ENTER("spider_mysql_handler::append_update"); + DBUG_ENTER("spider_mbase_handler::append_update"); if (str->reserve(SPIDER_SQL_UPDATE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_UPDATE_STR, SPIDER_SQL_UPDATE_LEN); @@ -7448,19 +7711,19 @@ int spider_mysql_handler::append_update( DBUG_RETURN(0); } -int spider_mysql_handler::append_delete_part() +int spider_mbase_handler::append_delete_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_delete_part"); + DBUG_ENTER("spider_mbase_handler::append_delete_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_delete(&update_sql); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_delete( +int spider_mbase_handler::append_delete( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_delete"); + DBUG_ENTER("spider_mbase_handler::append_delete"); if (str->reserve(SPIDER_SQL_DELETE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_DELETE_STR, SPIDER_SQL_DELETE_LEN); @@ -7489,22 +7752,22 @@ int spider_mysql_handler::append_delete( #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_mysql_handler::append_increment_update_set_part() +int spider_mbase_handler::append_increment_update_set_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_increment_update_set_part"); + DBUG_ENTER("spider_mbase_handler::append_increment_update_set_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_increment_update_set(&update_sql); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_increment_update_set( +int spider_mbase_handler::append_increment_update_set( spider_string *str ) { uint field_name_length; uint roop_count; Field *field; - DBUG_ENTER("spider_mysql_handler::append_increment_update_set"); + DBUG_ENTER("spider_mbase_handler::append_increment_update_set"); if (str->reserve(SPIDER_SQL_SET_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); @@ -7548,24 +7811,24 @@ int spider_mysql_handler::append_increment_update_set( #endif #endif -int spider_mysql_handler::append_update_set_part() +int spider_mbase_handler::append_update_set_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_update_set_part"); + DBUG_ENTER("spider_mbase_handler::append_update_set_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_update_set(&update_sql); where_pos = update_sql.length(); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_update_set( +int spider_mbase_handler::append_update_set( spider_string *str ) { uint field_name_length; SPIDER_SHARE *share = spider->share; TABLE *table = spider->get_table(); Field **fields; - DBUG_ENTER("spider_mysql_handler::append_update_set"); + DBUG_ENTER("spider_mbase_handler::append_update_set"); if (str->reserve(SPIDER_SQL_SET_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); @@ -7595,7 +7858,7 @@ int spider_mysql_handler::append_update_set( table->read_set); #endif if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, str, *fields, NULL, share->access_charset) || str->reserve(SPIDER_SQL_COMMA_LEN) @@ -7617,17 +7880,17 @@ int spider_mysql_handler::append_update_set( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_mysql_handler::append_direct_update_set_part() +int spider_mbase_handler::append_direct_update_set_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::append_direct_update_set_part"); + DBUG_ENTER("spider_mbase_handler::append_direct_update_set_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_direct_update_set(&update_sql); where_pos = update_sql.length(); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_direct_update_set( +int spider_mbase_handler::append_direct_update_set( spider_string *str ) { #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) @@ -7637,7 +7900,7 @@ int spider_mysql_handler::append_direct_update_set( TABLE *table = spider->get_table(); #endif #endif - DBUG_ENTER("spider_mysql_handler::append_direct_update_set"); + DBUG_ENTER("spider_mbase_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && spider->direct_update_fields @@ -7646,7 +7909,7 @@ int spider_mysql_handler::append_direct_update_set( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); DBUG_RETURN(spider_db_append_update_columns(spider, str, NULL, 0, - spider_dbton_mysql.dbton_id, FALSE, NULL)); + dbton_id, FALSE, NULL)); } if ( @@ -7687,7 +7950,7 @@ int spider_mysql_handler::append_direct_update_set( table->read_set); #endif if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, str, top_table_field, NULL, share->access_charset) || str->reserve(SPIDER_SQL_COMMA_LEN) @@ -7711,57 +7974,57 @@ int spider_mysql_handler::append_direct_update_set( DBUG_RETURN(0); } -int spider_mysql_handler::append_dup_update_pushdown_part( +int spider_mbase_handler::append_dup_update_pushdown_part( const char *alias, uint alias_length ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_dup_update_pushdown_part"); + DBUG_ENTER("spider_mbase_handler::append_dup_update_pushdown_part"); DBUG_PRINT("info",("spider this=%p", this)); dup_update_sql.length(0); error_num = append_update_columns(&dup_update_sql, alias, alias_length); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_update_columns_part( +int spider_mbase_handler::append_update_columns_part( const char *alias, uint alias_length ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_update_columns_part"); + DBUG_ENTER("spider_mbase_handler::append_update_columns_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_update_columns(&update_sql, alias, alias_length); DBUG_RETURN(error_num); } -int spider_mysql_handler::check_update_columns_part() +int spider_mbase_handler::check_update_columns_part() { int error_num; - DBUG_ENTER("spider_mysql_handler::check_update_columns_part"); + DBUG_ENTER("spider_mbase_handler::check_update_columns_part"); DBUG_PRINT("info",("spider this=%p", this)); error_num = append_update_columns(NULL, NULL, 0); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_update_columns( +int spider_mbase_handler::append_update_columns( spider_string *str, const char *alias, uint alias_length ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_update_columns"); + DBUG_ENTER("spider_mbase_handler::append_update_columns"); error_num = spider_db_append_update_columns(spider, str, - alias, alias_length, spider_dbton_mysql.dbton_id, FALSE, NULL); + alias, alias_length, dbton_id, FALSE, NULL); DBUG_RETURN(error_num); } #endif -int spider_mysql_handler::append_select_part( +int spider_mbase_handler::append_select_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_select_part"); + DBUG_ENTER("spider_mbase_handler::append_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -7778,12 +8041,12 @@ int spider_mysql_handler::append_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_select( +int spider_mbase_handler::append_select( spider_string *str, ulong sql_type ) { SPIDER_RESULT_LIST *result_list = &spider->result_list; - DBUG_ENTER("spider_mysql_handler::append_select"); + DBUG_ENTER("spider_mbase_handler::append_select"); if (sql_type == SPIDER_SQL_TYPE_HANDLER) { if (str->reserve(SPIDER_SQL_HANDLER_LEN)) @@ -7854,12 +8117,12 @@ int spider_mysql_handler::append_select( DBUG_RETURN(0); } -int spider_mysql_handler::append_table_select_part( +int spider_mbase_handler::append_table_select_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_table_select_part"); + DBUG_ENTER("spider_mbase_handler::append_table_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -7873,23 +8136,23 @@ int spider_mysql_handler::append_table_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_table_select( +int spider_mbase_handler::append_table_select( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_table_select"); + DBUG_ENTER("spider_mbase_handler::append_table_select"); table_name_pos = str->length() + mysql_share->table_select_pos; if (str->append(*(mysql_share->table_select))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(0); } -int spider_mysql_handler::append_key_select_part( +int spider_mbase_handler::append_key_select_part( ulong sql_type, uint idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_select_part"); + DBUG_ENTER("spider_mbase_handler::append_key_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -7903,23 +8166,23 @@ int spider_mysql_handler::append_key_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_select( +int spider_mbase_handler::append_key_select( spider_string *str, uint idx ) { - DBUG_ENTER("spider_mysql_handler::append_key_select"); + DBUG_ENTER("spider_mbase_handler::append_key_select"); table_name_pos = str->length() + mysql_share->key_select_pos[idx]; if (str->append(mysql_share->key_select[idx])) DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(0); } -int spider_mysql_handler::append_minimum_select_part( +int spider_mbase_handler::append_minimum_select_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_minimum_select_part"); + DBUG_ENTER("spider_mbase_handler::append_minimum_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -7933,7 +8196,7 @@ int spider_mysql_handler::append_minimum_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_minimum_select( +int spider_mbase_handler::append_minimum_select( spider_string *str, ulong sql_type ) { @@ -7941,7 +8204,7 @@ int spider_mysql_handler::append_minimum_select( Field **field; int field_length; bool appended = FALSE; - DBUG_ENTER("spider_mysql_handler::append_minimum_select"); + DBUG_ENTER("spider_mbase_handler::append_minimum_select"); minimum_select_bitmap_create(); for (field = table->field; *field; field++) { @@ -7970,7 +8233,7 @@ int spider_mysql_handler::append_minimum_select( DBUG_RETURN(append_from(str, sql_type, first_link_idx)); } -int spider_mysql_handler::append_table_select_with_alias( +int spider_mbase_handler::append_table_select_with_alias( spider_string *str, const char *alias, uint alias_length @@ -7978,7 +8241,7 @@ int spider_mysql_handler::append_table_select_with_alias( TABLE *table = spider->get_table(); Field **field; int field_length; - DBUG_ENTER("spider_mysql_handler::append_table_select_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_table_select_with_alias"); for (field = table->field; *field; field++) { field_length = @@ -7994,7 +8257,7 @@ int spider_mysql_handler::append_table_select_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_select_with_alias( +int spider_mbase_handler::append_key_select_with_alias( spider_string *str, const KEY *key_info, const char *alias, @@ -8004,7 +8267,7 @@ int spider_mysql_handler::append_key_select_with_alias( Field *field; uint part_num; int field_length; - DBUG_ENTER("spider_mysql_handler::append_key_select_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_key_select_with_alias"); for (key_part = key_info->key_part, part_num = 0; part_num < spider_user_defined_key_parts(key_info); key_part++, part_num++) { @@ -8021,7 +8284,7 @@ int spider_mysql_handler::append_key_select_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_minimum_select_with_alias( +int spider_mbase_handler::append_minimum_select_with_alias( spider_string *str, const char *alias, uint alias_length @@ -8030,7 +8293,7 @@ int spider_mysql_handler::append_minimum_select_with_alias( Field **field; int field_length; bool appended = FALSE; - DBUG_ENTER("spider_mysql_handler::append_minimum_select_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_minimum_select_with_alias"); minimum_select_bitmap_create(); for (field = table->field; *field; field++) { @@ -8060,14 +8323,14 @@ int spider_mysql_handler::append_minimum_select_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_select_columns_with_alias( +int spider_mbase_handler::append_select_columns_with_alias( spider_string *str, const char *alias, uint alias_length ) { int error_num; SPIDER_RESULT_LIST *result_list = &spider->result_list; - DBUG_ENTER("spider_mysql_handler::append_select_columns_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_select_columns_with_alias"); #ifdef HANDLER_HAS_DIRECT_AGGREGATE if ( result_list->direct_aggregate && @@ -8089,12 +8352,12 @@ int spider_mysql_handler::append_select_columns_with_alias( DBUG_RETURN(append_minimum_select_with_alias(str, alias, alias_length)); } -int spider_mysql_handler::append_hint_after_table_part( +int spider_mbase_handler::append_hint_after_table_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_hint_after_table_part"); + DBUG_ENTER("spider_mbase_handler::append_hint_after_table_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8118,11 +8381,11 @@ int spider_mysql_handler::append_hint_after_table_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_hint_after_table( +int spider_mbase_handler::append_hint_after_table( spider_string *str ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_hint_after_table"); + DBUG_ENTER("spider_mbase_handler::append_hint_after_table"); DBUG_PRINT("info",("spider this=%p", this)); if ( mysql_share->key_hint && @@ -8133,10 +8396,10 @@ int spider_mysql_handler::append_hint_after_table( DBUG_RETURN(0); } -void spider_mysql_handler::set_where_pos( +void spider_mbase_handler::set_where_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::set_where_pos"); + DBUG_ENTER("spider_mbase_handler::set_where_pos"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8158,10 +8421,10 @@ void spider_mysql_handler::set_where_pos( DBUG_VOID_RETURN; } -void spider_mysql_handler::set_where_to_pos( +void spider_mbase_handler::set_where_to_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::set_where_to_pos"); + DBUG_ENTER("spider_mbase_handler::set_where_to_pos"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8183,23 +8446,23 @@ void spider_mysql_handler::set_where_to_pos( DBUG_VOID_RETURN; } -int spider_mysql_handler::check_item_type( +int spider_mbase_handler::check_item_type( Item *item ) { int error_num; - DBUG_ENTER("spider_mysql_handler::check_item_type"); + DBUG_ENTER("spider_mbase_handler::check_item_type"); DBUG_PRINT("info",("spider this=%p", this)); error_num = spider_db_print_item_type(item, NULL, spider, NULL, NULL, 0, - spider_dbton_mysql.dbton_id, FALSE, NULL); + dbton_id, FALSE, NULL); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_values_connector_part( +int spider_mbase_handler::append_values_connector_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_values_connector_part"); + DBUG_ENTER("spider_mbase_handler::append_values_connector_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8216,10 +8479,10 @@ int spider_mysql_handler::append_values_connector_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_values_connector( +int spider_mbase_handler::append_values_connector( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_values_connector"); + DBUG_ENTER("spider_mbase_handler::append_values_connector"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_COMMA_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) @@ -8230,12 +8493,12 @@ int spider_mysql_handler::append_values_connector( DBUG_RETURN(0); } -int spider_mysql_handler::append_values_terminator_part( +int spider_mbase_handler::append_values_terminator_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_values_terminator_part"); + DBUG_ENTER("spider_mbase_handler::append_values_terminator_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8252,22 +8515,22 @@ int spider_mysql_handler::append_values_terminator_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_values_terminator( +int spider_mbase_handler::append_values_terminator( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_values_terminator"); + DBUG_ENTER("spider_mbase_handler::append_values_terminator"); DBUG_PRINT("info",("spider this=%p", this)); str->length(str->length() - SPIDER_SQL_COMMA_LEN - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(0); } -int spider_mysql_handler::append_union_table_connector_part( +int spider_mbase_handler::append_union_table_connector_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_union_table_connector_part"); + DBUG_ENTER("spider_mbase_handler::append_union_table_connector_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8284,10 +8547,10 @@ int spider_mysql_handler::append_union_table_connector_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_union_table_connector( +int spider_mbase_handler::append_union_table_connector( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_union_table_connector"); + DBUG_ENTER("spider_mbase_handler::append_union_table_connector"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve((SPIDER_SQL_SPACE_LEN * 2) + SPIDER_SQL_UNION_ALL_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -8297,12 +8560,12 @@ int spider_mysql_handler::append_union_table_connector( DBUG_RETURN(0); } -int spider_mysql_handler::append_union_table_terminator_part( +int spider_mbase_handler::append_union_table_terminator_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_union_table_terminator_part"); + DBUG_ENTER("spider_mbase_handler::append_union_table_terminator_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8316,10 +8579,10 @@ int spider_mysql_handler::append_union_table_terminator_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_union_table_terminator( +int spider_mbase_handler::append_union_table_terminator( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_union_table_terminator"); + DBUG_ENTER("spider_mbase_handler::append_union_table_terminator"); DBUG_PRINT("info",("spider this=%p", this)); str->length(str->length() - ((SPIDER_SQL_SPACE_LEN * 2) + SPIDER_SQL_UNION_ALL_LEN)); @@ -8334,13 +8597,13 @@ int spider_mysql_handler::append_union_table_terminator( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_column_values_part( +int spider_mbase_handler::append_key_column_values_part( const key_range *start_key, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_column_values_part"); + DBUG_ENTER("spider_mbase_handler::append_key_column_values_part"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8356,7 +8619,7 @@ int spider_mysql_handler::append_key_column_values_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_column_values( +int spider_mbase_handler::append_key_column_values( spider_string *str, const key_range *start_key ) { @@ -8372,7 +8635,7 @@ int spider_mysql_handler::append_key_column_values( key_part_map start_key_part_map; KEY_PART_INFO *key_part; Field *field; - DBUG_ENTER("spider_mysql_handler::append_key_column_values"); + DBUG_ENTER("spider_mbase_handler::append_key_column_values"); start_key_part_map = start_key->keypart_map & full_key_part_map; DBUG_PRINT("info", ("spider spider_user_defined_key_parts=%u", spider_user_defined_key_parts(key_info))); @@ -8398,7 +8661,7 @@ int spider_mysql_handler::append_key_column_values( if (error_num > 0) DBUG_RETURN(error_num); } else { - if (spider_db_mysql_utility.append_column_value(spider, str, field, ptr, + if (spider_db_mbase_utility->append_column_value(spider, str, field, ptr, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -8411,13 +8674,13 @@ int spider_mysql_handler::append_key_column_values( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_column_values_with_name_part( +int spider_mbase_handler::append_key_column_values_with_name_part( const key_range *start_key, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_column_values_with_name_part"); + DBUG_ENTER("spider_mbase_handler::append_key_column_values_with_name_part"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8433,7 +8696,7 @@ int spider_mysql_handler::append_key_column_values_with_name_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_column_values_with_name( +int spider_mbase_handler::append_key_column_values_with_name( spider_string *str, const key_range *start_key ) { @@ -8451,7 +8714,7 @@ int spider_mysql_handler::append_key_column_values_with_name( KEY_PART_INFO *key_part; Field *field; char tmp_buf[MAX_FIELD_WIDTH]; - DBUG_ENTER("spider_mysql_handler::append_key_column_values_with_name"); + DBUG_ENTER("spider_mbase_handler::append_key_column_values_with_name"); start_key_part_map = start_key->keypart_map & full_key_part_map; DBUG_PRINT("info", ("spider spider_user_defined_key_parts=%u", spider_user_defined_key_parts(key_info))); @@ -8479,7 +8742,7 @@ int spider_mysql_handler::append_key_column_values_with_name( if (error_num > 0) DBUG_RETURN(error_num); } else { - if (spider_db_mysql_utility.append_column_value(spider, str, field, ptr, + if (spider_db_mbase_utility->append_column_value(spider, str, field, ptr, share->access_charset)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -8496,7 +8759,7 @@ int spider_mysql_handler::append_key_column_values_with_name( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_where_part( +int spider_mbase_handler::append_key_where_part( const key_range *start_key, const key_range *end_key, ulong sql_type @@ -8504,7 +8767,7 @@ int spider_mysql_handler::append_key_where_part( int error_num; spider_string *str, *str_part = NULL, *str_part2 = NULL; bool set_order; - DBUG_ENTER("spider_mysql_handler::append_key_where_part"); + DBUG_ENTER("spider_mbase_handler::append_key_where_part"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8539,7 +8802,7 @@ int spider_mysql_handler::append_key_where_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_where( +int spider_mbase_handler::append_key_where( spider_string *str, spider_string *str_part, spider_string *str_part2, @@ -8549,14 +8812,14 @@ int spider_mysql_handler::append_key_where( bool set_order ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_key_where"); + DBUG_ENTER("spider_mbase_handler::append_key_where"); error_num = spider_db_append_key_where_internal(str, str_part, str_part2, start_key, end_key, spider, set_order, sql_type, - spider_dbton_mysql.dbton_id); + dbton_id); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_is_null_part( +int spider_mbase_handler::append_is_null_part( ulong sql_type, KEY_PART_INFO *key_part, const key_range *key, @@ -8566,7 +8829,7 @@ int spider_mysql_handler::append_is_null_part( ) { int error_num; spider_string *str, *str_part = NULL, *str_part2 = NULL; - DBUG_ENTER("spider_mysql_handler::append_is_null_part"); + DBUG_ENTER("spider_mbase_handler::append_is_null_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8593,7 +8856,7 @@ int spider_mysql_handler::append_is_null_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_is_null( +int spider_mbase_handler::append_is_null( ulong sql_type, spider_string *str, spider_string *str_part, @@ -8604,7 +8867,7 @@ int spider_mysql_handler::append_is_null( bool key_eq, bool tgt_final ) { - DBUG_ENTER("spider_mysql_handler::append_is_null"); + DBUG_ENTER("spider_mbase_handler::append_is_null"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider key_eq=%s", key_eq ? "TRUE" : "FALSE")); if (key_part->null_bit) @@ -8677,14 +8940,14 @@ int spider_mysql_handler::append_is_null( DBUG_RETURN(0); } -int spider_mysql_handler::append_where_terminator_part( +int spider_mbase_handler::append_where_terminator_part( ulong sql_type, bool set_order, int key_count ) { int error_num; spider_string *str, *str_part = NULL, *str_part2 = NULL; - DBUG_ENTER("spider_mysql_handler::append_where_terminator_part"); + DBUG_ENTER("spider_mbase_handler::append_where_terminator_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -8711,7 +8974,7 @@ int spider_mysql_handler::append_where_terminator_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_where_terminator( +int spider_mbase_handler::append_where_terminator( ulong sql_type, spider_string *str, spider_string *str_part, @@ -8720,7 +8983,7 @@ int spider_mysql_handler::append_where_terminator( int key_count ) { SPIDER_RESULT_LIST *result_list = &spider->result_list; - DBUG_ENTER("spider_mysql_handler::append_where_terminator"); + DBUG_ENTER("spider_mbase_handler::append_where_terminator"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type != SPIDER_SQL_TYPE_HANDLER) { @@ -8750,12 +9013,12 @@ int spider_mysql_handler::append_where_terminator( DBUG_RETURN(0); } -int spider_mysql_handler::append_match_where_part( +int spider_mbase_handler::append_match_where_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_match_where_part"); + DBUG_ENTER("spider_mbase_handler::append_match_where_part"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -8769,13 +9032,13 @@ int spider_mysql_handler::append_match_where_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_match_where( +int spider_mbase_handler::append_match_where( spider_string *str ) { int error_num; bool first = TRUE; st_spider_ft_info *ft_info = spider->ft_first; - DBUG_ENTER("spider_mysql_handler::append_match_where"); + DBUG_ENTER("spider_mbase_handler::append_match_where"); if (spider->ft_current) { while (TRUE) @@ -8806,7 +9069,7 @@ int spider_mysql_handler::append_match_where( DBUG_RETURN(0); } -int spider_mysql_handler::append_update_where( +int spider_mbase_handler::append_update_where( spider_string *str, const TABLE *table, my_ptrdiff_t ptr_diff @@ -8816,7 +9079,7 @@ int spider_mysql_handler::append_update_where( THD *thd = spider->trx->thd; SPIDER_SHARE *share = spider->share; bool no_pk = (table->s->primary_key == MAX_KEY); - DBUG_ENTER("spider_mysql_handler::append_update_where"); + DBUG_ENTER("spider_mbase_handler::append_update_where"); DBUG_PRINT("info", ("spider table->s->primary_key=%s", table->s->primary_key != MAX_KEY ? "TRUE" : "FALSE")); uint str_len_bakup = str->length(); @@ -8853,7 +9116,7 @@ int spider_mysql_handler::append_update_where( str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); (*field)->move_field_offset(ptr_diff); if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, str, *field, NULL, share->access_charset) || str->reserve(SPIDER_SQL_AND_LEN) @@ -8893,7 +9156,7 @@ int spider_mysql_handler::append_update_where( str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); (*field)->move_field_offset(ptr_diff); if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, str, *field, NULL, share->access_charset) || str->reserve(SPIDER_SQL_AND_LEN) @@ -8917,7 +9180,7 @@ int spider_mysql_handler::append_update_where( DBUG_RETURN(0); } -int spider_mysql_handler::append_condition_part( +int spider_mbase_handler::append_condition_part( const char *alias, uint alias_length, ulong sql_type, @@ -8926,7 +9189,7 @@ int spider_mysql_handler::append_condition_part( int error_num; spider_string *str; bool start_where = FALSE; - DBUG_ENTER("spider_mysql_handler::append_condition_part"); + DBUG_ENTER("spider_mbase_handler::append_condition_part"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -9000,7 +9263,7 @@ int spider_mysql_handler::append_condition_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_condition( +int spider_mbase_handler::append_condition( spider_string *str, const char *alias, uint alias_length, @@ -9009,7 +9272,7 @@ int spider_mysql_handler::append_condition( ) { int error_num, restart_pos = 0, start_where_pos; SPIDER_CONDITION *tmp_cond = spider->condition; - DBUG_ENTER("spider_mysql_handler::append_condition"); + DBUG_ENTER("spider_mbase_handler::append_condition"); if (str && start_where) { start_where_pos = str->length(); @@ -9041,7 +9304,7 @@ int spider_mysql_handler::append_condition( } if ((error_num = spider_db_print_item_type( (Item *) tmp_cond->cond, NULL, spider, str, alias, alias_length, - spider_dbton_mysql.dbton_id, FALSE, NULL))) + dbton_id, FALSE, NULL))) { if (str && error_num == ER_SPIDER_COND_SKIP_NUM) { @@ -9056,7 +9319,7 @@ int spider_mysql_handler::append_condition( DBUG_RETURN(0); } -int spider_mysql_handler::append_match_against_part( +int spider_mbase_handler::append_match_against_part( ulong sql_type, st_spider_ft_info *ft_info, const char *alias, @@ -9064,7 +9327,7 @@ int spider_mysql_handler::append_match_against_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_match_against_part"); + DBUG_ENTER("spider_mbase_handler::append_match_against_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9078,7 +9341,7 @@ int spider_mysql_handler::append_match_against_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_match_against( +int spider_mbase_handler::append_match_against( spider_string *str, st_spider_ft_info *ft_info, const char *alias, @@ -9092,7 +9355,7 @@ int spider_mysql_handler::append_match_against( int key_count; KEY_PART_INFO *key_part; Field *field; - DBUG_ENTER("spider_mysql_handler::append_match_against"); + DBUG_ENTER("spider_mbase_handler::append_match_against"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_MATCH_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -9141,7 +9404,7 @@ int spider_mysql_handler::append_match_against( tmp_str.append(ft_init_key->ptr(), ft_init_key->length(), ft_init_key->charset()) || str->reserve(tmp_str.length() * 2) || - spider_db_mysql_utility.append_escaped_util(str, tmp_str.get_str()) + spider_db_mbase_utility->append_escaped_util(str, tmp_str.get_str()) ) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->mem_calc(); @@ -9164,14 +9427,14 @@ int spider_mysql_handler::append_match_against( DBUG_RETURN(0); } -int spider_mysql_handler::append_match_select_part( +int spider_mbase_handler::append_match_select_part( ulong sql_type, const char *alias, uint alias_length ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_match_select_part"); + DBUG_ENTER("spider_mbase_handler::append_match_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9185,13 +9448,13 @@ int spider_mysql_handler::append_match_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_match_select( +int spider_mbase_handler::append_match_select( spider_string *str, const char *alias, uint alias_length ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_match_select"); + DBUG_ENTER("spider_mbase_handler::append_match_select"); DBUG_PRINT("info",("spider this=%p", this)); if (spider->ft_current) { @@ -9213,14 +9476,14 @@ int spider_mysql_handler::append_match_select( } #ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_mysql_handler::append_sum_select_part( +int spider_mbase_handler::append_sum_select_part( ulong sql_type, const char *alias, uint alias_length ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_sum_select_part"); + DBUG_ENTER("spider_mbase_handler::append_sum_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9234,21 +9497,21 @@ int spider_mysql_handler::append_sum_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_sum_select( +int spider_mbase_handler::append_sum_select( spider_string *str, const char *alias, uint alias_length ) { int error_num; st_select_lex *select_lex; - DBUG_ENTER("spider_mysql_handler::append_sum_select"); + DBUG_ENTER("spider_mbase_handler::append_sum_select"); DBUG_PRINT("info",("spider this=%p", this)); select_lex = spider_get_select_lex(spider); JOIN *join = select_lex->join; Item_sum **item_sum_ptr; for (item_sum_ptr = join->sum_funcs; *item_sum_ptr; ++item_sum_ptr) { - if ((error_num = spider_db_mysql_utility.open_item_sum_func(*item_sum_ptr, + if ((error_num = spider_db_mbase_utility->open_item_sum_func(*item_sum_ptr, spider, str, alias, alias_length, FALSE, NULL))) { DBUG_RETURN(error_num); @@ -9261,10 +9524,10 @@ int spider_mysql_handler::append_sum_select( } #endif -void spider_mysql_handler::set_order_pos( +void spider_mbase_handler::set_order_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::set_order_pos"); + DBUG_ENTER("spider_mbase_handler::set_order_pos"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -9287,10 +9550,10 @@ void spider_mysql_handler::set_order_pos( DBUG_VOID_RETURN; } -void spider_mysql_handler::set_order_to_pos( +void spider_mbase_handler::set_order_to_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::set_order_to_pos"); + DBUG_ENTER("spider_mbase_handler::set_order_to_pos"); switch (sql_type) { case SPIDER_SQL_TYPE_SELECT_SQL: @@ -9314,14 +9577,14 @@ void spider_mysql_handler::set_order_to_pos( } #ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_mysql_handler::append_group_by_part( +int spider_mbase_handler::append_group_by_part( const char *alias, uint alias_length, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_group_by_part"); + DBUG_ENTER("spider_mbase_handler::append_group_by_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9345,14 +9608,14 @@ int spider_mysql_handler::append_group_by_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_group_by( +int spider_mbase_handler::append_group_by( spider_string *str, const char *alias, uint alias_length ) { int error_num; st_select_lex *select_lex; - DBUG_ENTER("spider_mysql_handler::append_group_by"); + DBUG_ENTER("spider_mbase_handler::append_group_by"); DBUG_PRINT("info",("spider this=%p", this)); select_lex = spider_get_select_lex(spider); ORDER *group = (ORDER *) select_lex->group_list.first; @@ -9364,7 +9627,7 @@ int spider_mysql_handler::append_group_by( for (; group; group = group->next) { if ((error_num = spider_db_print_item_type((*group->item), NULL, spider, - str, alias, alias_length, spider_dbton_mysql.dbton_id, FALSE, NULL))) + str, alias, alias_length, dbton_id, FALSE, NULL))) { DBUG_RETURN(error_num); } @@ -9378,14 +9641,14 @@ int spider_mysql_handler::append_group_by( } #endif -int spider_mysql_handler::append_key_order_for_merge_with_alias_part( +int spider_mbase_handler::append_key_order_for_merge_with_alias_part( const char *alias, uint alias_length, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_order_for_merge_with_alias_part"); + DBUG_ENTER("spider_mbase_handler::append_key_order_for_merge_with_alias_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9410,7 +9673,7 @@ int spider_mysql_handler::append_key_order_for_merge_with_alias_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_order_for_merge_with_alias( +int spider_mbase_handler::append_key_order_for_merge_with_alias( spider_string *str, const char *alias, uint alias_length @@ -9420,7 +9683,7 @@ int spider_mysql_handler::append_key_order_for_merge_with_alias( int length; Field *field; uint key_name_length; - DBUG_ENTER("spider_mysql_handler::append_key_order_for_merge_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_key_order_for_merge_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) @@ -9494,14 +9757,14 @@ int spider_mysql_handler::append_key_order_for_merge_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias_part( +int spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias_part( const char *alias, uint alias_length, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias_part"); + DBUG_ENTER("spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9526,7 +9789,7 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias_par DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( +int spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias( spider_string *str, const char *alias, uint alias_length @@ -9536,7 +9799,7 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( st_select_lex *select_lex; longlong select_limit; longlong offset_limit; - DBUG_ENTER("spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) @@ -9557,7 +9820,7 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( { if ((error_num = spider_db_print_item_type((*order->item), NULL, spider, str, alias, - alias_length, spider_dbton_mysql.dbton_id, FALSE, NULL))) + alias_length, dbton_id, FALSE, NULL))) { DBUG_PRINT("info",("spider error=%d", error_num)); DBUG_RETURN(error_num); @@ -9580,14 +9843,14 @@ int spider_mysql_handler::append_key_order_for_direct_order_limit_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_order_with_alias_part( +int spider_mbase_handler::append_key_order_with_alias_part( const char *alias, uint alias_length, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_key_order_with_alias_part"); + DBUG_ENTER("spider_mbase_handler::append_key_order_with_alias_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9612,12 +9875,12 @@ int spider_mysql_handler::append_key_order_with_alias_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_key_order_for_handler( +int spider_mbase_handler::append_key_order_for_handler( spider_string *str, const char *alias, uint alias_length ) { - DBUG_ENTER("spider_mysql_handler::append_key_order_for_handler"); + DBUG_ENTER("spider_mbase_handler::append_key_order_for_handler"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider ha_next_pos=%d", ha_next_pos)); DBUG_PRINT("info",("spider ha_where_pos=%d", ha_where_pos)); @@ -9627,7 +9890,7 @@ int spider_mysql_handler::append_key_order_for_handler( DBUG_RETURN(0); } -int spider_mysql_handler::append_key_order_with_alias( +int spider_mbase_handler::append_key_order_with_alias( spider_string *str, const char *alias, uint alias_length @@ -9638,7 +9901,7 @@ int spider_mysql_handler::append_key_order_with_alias( KEY_PART_INFO *key_part; Field *field; uint key_name_length; - DBUG_ENTER("spider_mysql_handler::append_key_order_with_alias"); + DBUG_ENTER("spider_mbase_handler::append_key_order_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); #ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) @@ -9793,14 +10056,14 @@ int spider_mysql_handler::append_key_order_with_alias( DBUG_RETURN(0); } -int spider_mysql_handler::append_limit_part( +int spider_mbase_handler::append_limit_part( longlong offset, longlong limit, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_limit_part"); + DBUG_ENTER("spider_mbase_handler::append_limit_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9830,14 +10093,14 @@ int spider_mysql_handler::append_limit_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::reappend_limit_part( +int spider_mbase_handler::reappend_limit_part( longlong offset, longlong limit, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::reappend_limit_part"); + DBUG_ENTER("spider_mbase_handler::reappend_limit_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9867,14 +10130,14 @@ int spider_mysql_handler::reappend_limit_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_limit( +int spider_mbase_handler::append_limit( spider_string *str, longlong offset, longlong limit ) { char buf[SPIDER_LONGLONG_LEN + 1]; uint32 length; - DBUG_ENTER("spider_mysql_handler::append_limit"); + DBUG_ENTER("spider_mbase_handler::append_limit"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info", ("spider offset=%lld", offset)); DBUG_PRINT("info", ("spider limit=%lld", limit)); @@ -9898,12 +10161,12 @@ int spider_mysql_handler::append_limit( DBUG_RETURN(0); } -int spider_mysql_handler::append_select_lock_part( +int spider_mbase_handler::append_select_lock_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_select_lock_part"); + DBUG_ENTER("spider_mbase_handler::append_select_lock_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9917,11 +10180,11 @@ int spider_mysql_handler::append_select_lock_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_select_lock( +int spider_mbase_handler::append_select_lock( spider_string *str ) { int lock_mode = spider_conn_lock_mode(spider); - DBUG_ENTER("spider_mysql_handler::append_select_lock"); + DBUG_ENTER("spider_mbase_handler::append_select_lock"); DBUG_PRINT("info",("spider this=%p", this)); if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) { @@ -9937,12 +10200,12 @@ int spider_mysql_handler::append_select_lock( DBUG_RETURN(0); } -int spider_mysql_handler::append_union_all_start_part( +int spider_mbase_handler::append_union_all_start_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_union_all_start_part"); + DBUG_ENTER("spider_mbase_handler::append_union_all_start_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9956,10 +10219,10 @@ int spider_mysql_handler::append_union_all_start_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_union_all_start( +int spider_mbase_handler::append_union_all_start( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_union_all_start"); + DBUG_ENTER("spider_mbase_handler::append_union_all_start"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -9967,12 +10230,12 @@ int spider_mysql_handler::append_union_all_start( DBUG_RETURN(0); } -int spider_mysql_handler::append_union_all_part( +int spider_mbase_handler::append_union_all_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_union_all_part"); + DBUG_ENTER("spider_mbase_handler::append_union_all_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -9986,10 +10249,10 @@ int spider_mysql_handler::append_union_all_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_union_all( +int spider_mbase_handler::append_union_all( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_union_all"); + DBUG_ENTER("spider_mbase_handler::append_union_all"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_UNION_ALL_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -9997,12 +10260,12 @@ int spider_mysql_handler::append_union_all( DBUG_RETURN(0); } -int spider_mysql_handler::append_union_all_end_part( +int spider_mbase_handler::append_union_all_end_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_union_all_end_part"); + DBUG_ENTER("spider_mbase_handler::append_union_all_end_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10016,24 +10279,24 @@ int spider_mysql_handler::append_union_all_end_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_union_all_end( +int spider_mbase_handler::append_union_all_end( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_union_all_end"); + DBUG_ENTER("spider_mbase_handler::append_union_all_end"); DBUG_PRINT("info",("spider this=%p", this)); str->length(str->length() - SPIDER_SQL_UNION_ALL_LEN + SPIDER_SQL_CLOSE_PAREN_LEN); DBUG_RETURN(0); } -int spider_mysql_handler::append_multi_range_cnt_part( +int spider_mbase_handler::append_multi_range_cnt_part( ulong sql_type, uint multi_range_cnt, bool with_comma ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt_part"); + DBUG_ENTER("spider_mbase_handler::append_multi_range_cnt_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10050,14 +10313,14 @@ int spider_mysql_handler::append_multi_range_cnt_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_multi_range_cnt( +int spider_mbase_handler::append_multi_range_cnt( spider_string *str, uint multi_range_cnt, bool with_comma ) { int range_cnt_length; char range_cnt_str[SPIDER_SQL_INT_LEN]; - DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt"); + DBUG_ENTER("spider_mbase_handler::append_multi_range_cnt"); DBUG_PRINT("info",("spider this=%p", this)); range_cnt_length = my_sprintf(range_cnt_str, (range_cnt_str, "%u", multi_range_cnt)); @@ -10075,13 +10338,13 @@ int spider_mysql_handler::append_multi_range_cnt( DBUG_RETURN(0); } -int spider_mysql_handler::append_multi_range_cnt_with_name_part( +int spider_mbase_handler::append_multi_range_cnt_with_name_part( ulong sql_type, uint multi_range_cnt ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt_with_name_part"); + DBUG_ENTER("spider_mbase_handler::append_multi_range_cnt_with_name_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10098,13 +10361,13 @@ int spider_mysql_handler::append_multi_range_cnt_with_name_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_multi_range_cnt_with_name( +int spider_mbase_handler::append_multi_range_cnt_with_name( spider_string *str, uint multi_range_cnt ) { int range_cnt_length; char range_cnt_str[SPIDER_SQL_INT_LEN]; - DBUG_ENTER("spider_mysql_handler::append_multi_range_cnt_with_name"); + DBUG_ENTER("spider_mbase_handler::append_multi_range_cnt_with_name"); DBUG_PRINT("info",("spider this=%p", this)); range_cnt_length = my_sprintf(range_cnt_str, (range_cnt_str, "%u", multi_range_cnt)); @@ -10118,7 +10381,7 @@ int spider_mysql_handler::append_multi_range_cnt_with_name( DBUG_RETURN(0); } -int spider_mysql_handler::append_open_handler_part( +int spider_mbase_handler::append_open_handler_part( ulong sql_type, uint handler_id, SPIDER_CONN *conn, @@ -10126,7 +10389,7 @@ int spider_mysql_handler::append_open_handler_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_open_handler_part"); + DBUG_ENTER("spider_mbase_handler::append_open_handler_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10141,14 +10404,14 @@ int spider_mysql_handler::append_open_handler_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_open_handler( +int spider_mbase_handler::append_open_handler( spider_string *str, uint handler_id, SPIDER_CONN *conn, int link_idx ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_open_handler"); + DBUG_ENTER("spider_mbase_handler::append_open_handler"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider link_idx=%d", link_idx)); DBUG_PRINT("info",("spider m_handler_cid=%s", @@ -10172,13 +10435,13 @@ int spider_mysql_handler::append_open_handler( DBUG_RETURN(0); } -int spider_mysql_handler::append_close_handler_part( +int spider_mbase_handler::append_close_handler_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_close_handler_part"); + DBUG_ENTER("spider_mbase_handler::append_close_handler_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10193,11 +10456,11 @@ int spider_mysql_handler::append_close_handler_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_close_handler( +int spider_mbase_handler::append_close_handler( spider_string *str, int link_idx ) { - DBUG_ENTER("spider_mysql_handler::append_close_handler"); + DBUG_ENTER("spider_mbase_handler::append_close_handler"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_HANDLER_LEN + SPIDER_SQL_CLOSE_LEN + SPIDER_SQL_HANDLER_CID_LEN)) @@ -10209,12 +10472,12 @@ int spider_mysql_handler::append_close_handler( DBUG_RETURN(0); } -int spider_mysql_handler::append_insert_terminator_part( +int spider_mbase_handler::append_insert_terminator_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_insert_terminator_part"); + DBUG_ENTER("spider_mbase_handler::append_insert_terminator_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10228,10 +10491,10 @@ int spider_mysql_handler::append_insert_terminator_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_insert_terminator( +int spider_mbase_handler::append_insert_terminator( spider_string *str ) { - DBUG_ENTER("spider_mysql_handler::append_insert_terminator"); + DBUG_ENTER("spider_mbase_handler::append_insert_terminator"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider dup_update_sql.length=%u", dup_update_sql.length())); if ( @@ -10256,12 +10519,12 @@ int spider_mysql_handler::append_insert_terminator( DBUG_RETURN(0); } -int spider_mysql_handler::append_insert_values_part( +int spider_mbase_handler::append_insert_values_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_insert_values_part"); + DBUG_ENTER("spider_mbase_handler::append_insert_values_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10275,14 +10538,14 @@ int spider_mysql_handler::append_insert_values_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_insert_values( +int spider_mbase_handler::append_insert_values( spider_string *str ) { SPIDER_SHARE *share = spider->share; TABLE *table = spider->get_table(); Field **field; bool add_value = FALSE; - DBUG_ENTER("spider_mysql_handler::append_insert_values"); + DBUG_ENTER("spider_mbase_handler::append_insert_values"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) { @@ -10329,7 +10592,7 @@ int spider_mysql_handler::append_insert_values( str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); } else { if ( - spider_db_mysql_utility. + spider_db_mbase_utility-> append_column_value(spider, str, *field, NULL, share->access_charset) || str->reserve(SPIDER_SQL_COMMA_LEN) @@ -10359,12 +10622,12 @@ int spider_mysql_handler::append_insert_values( DBUG_RETURN(0); } -int spider_mysql_handler::append_into_part( +int spider_mbase_handler::append_into_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_into_part"); + DBUG_ENTER("spider_mbase_handler::append_into_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10378,13 +10641,13 @@ int spider_mysql_handler::append_into_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_into( +int spider_mbase_handler::append_into( spider_string *str ) { const TABLE *table = spider->get_table(); Field **field; uint field_name_length = 0; - DBUG_ENTER("spider_mysql_handler::append_into"); + DBUG_ENTER("spider_mbase_handler::append_into"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_INTO_LEN + mysql_share->db_nm_max_length + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + @@ -10420,10 +10683,10 @@ int spider_mysql_handler::append_into( DBUG_RETURN(0); } -void spider_mysql_handler::set_insert_to_pos( +void spider_mbase_handler::set_insert_to_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::set_insert_to_pos"); + DBUG_ENTER("spider_mbase_handler::set_insert_to_pos"); switch (sql_type) { case SPIDER_SQL_TYPE_INSERT_SQL: @@ -10436,13 +10699,13 @@ void spider_mysql_handler::set_insert_to_pos( DBUG_VOID_RETURN; } -int spider_mysql_handler::append_from_part( +int spider_mbase_handler::append_from_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_from_part"); + DBUG_ENTER("spider_mbase_handler::append_from_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10462,12 +10725,12 @@ int spider_mysql_handler::append_from_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_from( +int spider_mbase_handler::append_from( spider_string *str, ulong sql_type, int link_idx ) { - DBUG_ENTER("spider_mysql_handler::append_from"); + DBUG_ENTER("spider_mbase_handler::append_from"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider link_idx=%d", link_idx)); int error_num = 0; @@ -10501,14 +10764,14 @@ int spider_mysql_handler::append_from( DBUG_RETURN(0); } -int spider_mysql_handler::append_flush_tables_part( +int spider_mbase_handler::append_flush_tables_part( ulong sql_type, int link_idx, bool lock ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_flush_tables_part"); + DBUG_ENTER("spider_mbase_handler::append_flush_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10522,12 +10785,12 @@ int spider_mysql_handler::append_flush_tables_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_flush_tables( +int spider_mbase_handler::append_flush_tables( spider_string *str, int link_idx, bool lock ) { - DBUG_ENTER("spider_mysql_handler::append_flush_tables"); + DBUG_ENTER("spider_mbase_handler::append_flush_tables"); DBUG_PRINT("info",("spider this=%p", this)); if (lock) { @@ -10545,13 +10808,13 @@ int spider_mysql_handler::append_flush_tables( DBUG_RETURN(0); } -int spider_mysql_handler::append_optimize_table_part( +int spider_mbase_handler::append_optimize_table_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_optimize_table_part"); + DBUG_ENTER("spider_mbase_handler::append_optimize_table_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10565,7 +10828,7 @@ int spider_mysql_handler::append_optimize_table_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_optimize_table( +int spider_mbase_handler::append_optimize_table( spider_string *str, int link_idx ) { @@ -10573,7 +10836,7 @@ int spider_mysql_handler::append_optimize_table( int conn_link_idx = spider->conn_link_idx[link_idx]; int local_length = spider_param_internal_optimize_local(spider->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; - DBUG_ENTER("spider_mysql_handler::append_optimize_table"); + DBUG_ENTER("spider_mbase_handler::append_optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_OPTIMIZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + local_length + @@ -10590,13 +10853,13 @@ int spider_mysql_handler::append_optimize_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_analyze_table_part( +int spider_mbase_handler::append_analyze_table_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_analyze_table_part"); + DBUG_ENTER("spider_mbase_handler::append_analyze_table_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10610,7 +10873,7 @@ int spider_mysql_handler::append_analyze_table_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_analyze_table( +int spider_mbase_handler::append_analyze_table( spider_string *str, int link_idx ) { @@ -10618,7 +10881,7 @@ int spider_mysql_handler::append_analyze_table( int conn_link_idx = spider->conn_link_idx[link_idx]; int local_length = spider_param_internal_optimize_local(spider->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; - DBUG_ENTER("spider_mysql_handler::append_analyze_table"); + DBUG_ENTER("spider_mbase_handler::append_analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_ANALYZE_LEN + SPIDER_SQL_SQL_TABLE_LEN + local_length + @@ -10635,14 +10898,14 @@ int spider_mysql_handler::append_analyze_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_repair_table_part( +int spider_mbase_handler::append_repair_table_part( ulong sql_type, int link_idx, HA_CHECK_OPT* check_opt ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_repair_table_part"); + DBUG_ENTER("spider_mbase_handler::append_repair_table_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10656,7 +10919,7 @@ int spider_mysql_handler::append_repair_table_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_repair_table( +int spider_mbase_handler::append_repair_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt @@ -10665,7 +10928,7 @@ int spider_mysql_handler::append_repair_table( int conn_link_idx = spider->conn_link_idx[link_idx]; int local_length = spider_param_internal_optimize_local(spider->trx->thd, share->internal_optimize_local) * SPIDER_SQL_SQL_LOCAL_LEN; - DBUG_ENTER("spider_mysql_handler::append_repair_table"); + DBUG_ENTER("spider_mbase_handler::append_repair_table"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_REPAIR_LEN + SPIDER_SQL_SQL_TABLE_LEN + local_length + @@ -10700,14 +10963,14 @@ int spider_mysql_handler::append_repair_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_check_table_part( +int spider_mbase_handler::append_check_table_part( ulong sql_type, int link_idx, HA_CHECK_OPT* check_opt ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_check_table_part"); + DBUG_ENTER("spider_mbase_handler::append_check_table_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10721,13 +10984,13 @@ int spider_mysql_handler::append_check_table_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_check_table( +int spider_mbase_handler::append_check_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt ) { int conn_link_idx = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::append_check_table"); + DBUG_ENTER("spider_mbase_handler::append_check_table"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_CHECK_TABLE_LEN + mysql_share->db_names_str[conn_link_idx].length() + @@ -10765,13 +11028,13 @@ int spider_mysql_handler::append_check_table( DBUG_RETURN(0); } -int spider_mysql_handler::append_enable_keys_part( +int spider_mbase_handler::append_enable_keys_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_enable_keys_part"); + DBUG_ENTER("spider_mbase_handler::append_enable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10785,12 +11048,12 @@ int spider_mysql_handler::append_enable_keys_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_enable_keys( +int spider_mbase_handler::append_enable_keys( spider_string *str, int link_idx ) { int conn_link_idx = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::append_enable_keys"); + DBUG_ENTER("spider_mbase_handler::append_enable_keys"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + mysql_share->db_names_str[conn_link_idx].length() + @@ -10806,13 +11069,13 @@ int spider_mysql_handler::append_enable_keys( DBUG_RETURN(0); } -int spider_mysql_handler::append_disable_keys_part( +int spider_mbase_handler::append_disable_keys_part( ulong sql_type, int link_idx ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_disable_keys_part"); + DBUG_ENTER("spider_mbase_handler::append_disable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10826,12 +11089,12 @@ int spider_mysql_handler::append_disable_keys_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_disable_keys( +int spider_mbase_handler::append_disable_keys( spider_string *str, int link_idx ) { int conn_link_idx = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::append_disable_keys"); + DBUG_ENTER("spider_mbase_handler::append_disable_keys"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_SQL_ALTER_TABLE_LEN + mysql_share->db_names_str[conn_link_idx].length() + @@ -10847,12 +11110,12 @@ int spider_mysql_handler::append_disable_keys( DBUG_RETURN(0); } -int spider_mysql_handler::append_delete_all_rows_part( +int spider_mbase_handler::append_delete_all_rows_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_delete_all_rows_part"); + DBUG_ENTER("spider_mbase_handler::append_delete_all_rows_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10866,12 +11129,12 @@ int spider_mysql_handler::append_delete_all_rows_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_delete_all_rows( +int spider_mbase_handler::append_delete_all_rows( spider_string *str, ulong sql_type ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_delete_all_rows"); + DBUG_ENTER("spider_mbase_handler::append_delete_all_rows"); DBUG_PRINT("info",("spider this=%p", this)); if (spider->sql_command == SQLCOM_TRUNCATE) { @@ -10887,12 +11150,12 @@ int spider_mysql_handler::append_delete_all_rows( DBUG_RETURN(0); } -int spider_mysql_handler::append_truncate( +int spider_mbase_handler::append_truncate( spider_string *str, ulong sql_type, int link_idx ) { - DBUG_ENTER("spider_mysql_handler::append_truncate"); + DBUG_ENTER("spider_mbase_handler::append_truncate"); if (str->reserve(SPIDER_SQL_TRUNCATE_TABLE_LEN + mysql_share->db_nm_max_length + SPIDER_SQL_DOT_LEN + mysql_share->table_nm_max_length + @@ -10904,7 +11167,7 @@ int spider_mysql_handler::append_truncate( DBUG_RETURN(0); } -int spider_mysql_handler::append_explain_select_part( +int spider_mbase_handler::append_explain_select_part( key_range *start_key, key_range *end_key, ulong sql_type, @@ -10912,7 +11175,7 @@ int spider_mysql_handler::append_explain_select_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_explain_select_part"); + DBUG_ENTER("spider_mbase_handler::append_explain_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -10927,7 +11190,7 @@ int spider_mysql_handler::append_explain_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_explain_select( +int spider_mbase_handler::append_explain_select( spider_string *str, key_range *start_key, key_range *end_key, @@ -10935,7 +11198,7 @@ int spider_mysql_handler::append_explain_select( int link_idx ) { int error_num; - DBUG_ENTER("spider_mysql_handler::append_explain_select"); + DBUG_ENTER("spider_mbase_handler::append_explain_select"); DBUG_PRINT("info",("spider this=%p", this)); if (str->reserve(SPIDER_SQL_EXPLAIN_SELECT_LEN)) { @@ -10964,7 +11227,7 @@ int spider_mysql_handler::append_explain_select( * solely of the specified column. * FALSE - otherwise. ********************************************************************/ -bool spider_mysql_handler::is_sole_projection_field( +bool spider_mbase_handler::is_sole_projection_field( uint16 field_index ) { // Determine whether the projection list consists solely of the field of interest @@ -10973,7 +11236,7 @@ bool spider_mysql_handler::is_sole_projection_field( uint16 projection_field_count = 0; uint16 projection_field_index; Field** field; - DBUG_ENTER( "spider_mysql_handler::is_sole_projection_field" ); + DBUG_ENTER( "spider_mbase_handler::is_sole_projection_field" ); for ( field = table->field; *field ; field++ ) { @@ -11012,10 +11275,10 @@ bool spider_mysql_handler::is_sole_projection_field( DBUG_RETURN( FALSE ); } -bool spider_mysql_handler::is_bulk_insert_exec_period( +bool spider_mbase_handler::is_bulk_insert_exec_period( bool bulk_end ) { - DBUG_ENTER("spider_mysql_handler::is_bulk_insert_exec_period"); + DBUG_ENTER("spider_mbase_handler::is_bulk_insert_exec_period"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider insert_sql.length=%u", insert_sql.length())); DBUG_PRINT("info",("spider insert_pos=%d", insert_pos)); @@ -11029,19 +11292,19 @@ bool spider_mysql_handler::is_bulk_insert_exec_period( DBUG_RETURN(FALSE); } -bool spider_mysql_handler::sql_is_filled_up( +bool spider_mbase_handler::sql_is_filled_up( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::sql_is_filled_up"); + DBUG_ENTER("spider_mbase_handler::sql_is_filled_up"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(filled_up); } -bool spider_mysql_handler::sql_is_empty( +bool spider_mbase_handler::sql_is_empty( ulong sql_type ) { bool is_empty; - DBUG_ENTER("spider_mysql_handler::sql_is_empty"); + DBUG_ENTER("spider_mbase_handler::sql_is_empty"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -11069,34 +11332,34 @@ bool spider_mysql_handler::sql_is_empty( DBUG_RETURN(is_empty); } -bool spider_mysql_handler::support_multi_split_read() +bool spider_mbase_handler::support_multi_split_read() { - DBUG_ENTER("spider_mysql_handler::support_multi_split_read"); + DBUG_ENTER("spider_mbase_handler::support_multi_split_read"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -bool spider_mysql_handler::support_bulk_update() +bool spider_mbase_handler::support_bulk_update() { - DBUG_ENTER("spider_mysql_handler::support_bulk_update"); + DBUG_ENTER("spider_mbase_handler::support_bulk_update"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -int spider_mysql_handler::bulk_tmp_table_insert() +int spider_mbase_handler::bulk_tmp_table_insert() { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_insert"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_insert"); DBUG_PRINT("info",("spider this=%p", this)); error_num = store_sql_to_bulk_tmp_table(&update_sql, upd_tmp_tbl); DBUG_RETURN(error_num); } -int spider_mysql_handler::bulk_tmp_table_insert( +int spider_mbase_handler::bulk_tmp_table_insert( int link_idx ) { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_insert"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_insert"); DBUG_PRINT("info",("spider this=%p", this)); error_num = store_sql_to_bulk_tmp_table( &spider->result_list.update_sqls[link_idx], @@ -11104,10 +11367,10 @@ int spider_mysql_handler::bulk_tmp_table_insert( DBUG_RETURN(error_num); } -int spider_mysql_handler::bulk_tmp_table_end_bulk_insert() +int spider_mbase_handler::bulk_tmp_table_end_bulk_insert() { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_end_bulk_insert"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_end_bulk_insert"); DBUG_PRINT("info",("spider this=%p", this)); if ((error_num = upd_tmp_tbl->file->ha_end_bulk_insert())) { @@ -11116,10 +11379,10 @@ int spider_mysql_handler::bulk_tmp_table_end_bulk_insert() DBUG_RETURN(0); } -int spider_mysql_handler::bulk_tmp_table_rnd_init() +int spider_mbase_handler::bulk_tmp_table_rnd_init() { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_init"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_rnd_init"); DBUG_PRINT("info",("spider this=%p", this)); upd_tmp_tbl->file->extra(HA_EXTRA_CACHE); if ((error_num = upd_tmp_tbl->file->ha_rnd_init(TRUE))) @@ -11130,10 +11393,10 @@ int spider_mysql_handler::bulk_tmp_table_rnd_init() DBUG_RETURN(0); } -int spider_mysql_handler::bulk_tmp_table_rnd_next() +int spider_mbase_handler::bulk_tmp_table_rnd_next() { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_next"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_rnd_next"); DBUG_PRINT("info",("spider this=%p", this)); #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 error_num = upd_tmp_tbl->file->ha_rnd_next(upd_tmp_tbl->record[0]); @@ -11147,10 +11410,10 @@ int spider_mysql_handler::bulk_tmp_table_rnd_next() DBUG_RETURN(error_num); } -int spider_mysql_handler::bulk_tmp_table_rnd_end() +int spider_mbase_handler::bulk_tmp_table_rnd_end() { int error_num; - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_rnd_end"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_rnd_end"); DBUG_PRINT("info",("spider this=%p", this)); reading_from_bulk_tmp_table = FALSE; if ((error_num = upd_tmp_tbl->file->ha_rnd_end())) @@ -11160,28 +11423,28 @@ int spider_mysql_handler::bulk_tmp_table_rnd_end() DBUG_RETURN(0); } -bool spider_mysql_handler::need_copy_for_update( +bool spider_mbase_handler::need_copy_for_update( int link_idx ) { int all_link_idx = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::need_copy_for_update"); + DBUG_ENTER("spider_mbase_handler::need_copy_for_update"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(!mysql_share->same_db_table_name || spider->share->link_statuses[all_link_idx] == SPIDER_LINK_STATUS_RECOVERY); } -bool spider_mysql_handler::bulk_tmp_table_created() +bool spider_mbase_handler::bulk_tmp_table_created() { - DBUG_ENTER("spider_mysql_handler::bulk_tmp_table_created"); + DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_created"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(upd_tmp_tbl); } -int spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start() +int spider_mbase_handler::mk_bulk_tmp_table_and_bulk_start() { THD *thd = spider->trx->thd; TABLE *table = spider->get_table(); - DBUG_ENTER("spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start"); + DBUG_ENTER("spider_mbase_handler::mk_bulk_tmp_table_and_bulk_start"); DBUG_PRINT("info",("spider this=%p", this)); if (!upd_tmp_tbl) { @@ -11202,9 +11465,9 @@ int spider_mysql_handler::mk_bulk_tmp_table_and_bulk_start() DBUG_RETURN(0); } -void spider_mysql_handler::rm_bulk_tmp_table() +void spider_mbase_handler::rm_bulk_tmp_table() { - DBUG_ENTER("spider_mysql_handler::rm_bulk_tmp_table"); + DBUG_ENTER("spider_mbase_handler::rm_bulk_tmp_table"); DBUG_PRINT("info",("spider this=%p", this)); if (upd_tmp_tbl) { @@ -11214,12 +11477,12 @@ void spider_mysql_handler::rm_bulk_tmp_table() DBUG_VOID_RETURN; } -int spider_mysql_handler::store_sql_to_bulk_tmp_table( +int spider_mbase_handler::store_sql_to_bulk_tmp_table( spider_string *str, TABLE *tmp_table ) { int error_num; - DBUG_ENTER("spider_mysql_handler::store_sql_to_bulk_tmp_table"); + DBUG_ENTER("spider_mbase_handler::store_sql_to_bulk_tmp_table"); DBUG_PRINT("info",("spider this=%p", this)); tmp_table->field[0]->set_notnull(); tmp_table->field[0]->store(str->ptr(), str->length(), str->charset()); @@ -11228,24 +11491,24 @@ int spider_mysql_handler::store_sql_to_bulk_tmp_table( DBUG_RETURN(0); } -int spider_mysql_handler::restore_sql_from_bulk_tmp_table( +int spider_mbase_handler::restore_sql_from_bulk_tmp_table( spider_string *str, TABLE *tmp_table ) { - DBUG_ENTER("spider_mysql_handler::restore_sql_from_bulk_tmp_table"); + DBUG_ENTER("spider_mbase_handler::restore_sql_from_bulk_tmp_table"); DBUG_PRINT("info",("spider this=%p", this)); tmp_table->field[0]->val_str(str->get_str()); str->mem_calc(); DBUG_RETURN(0); } -int spider_mysql_handler::insert_lock_tables_list( +int spider_mbase_handler::insert_lock_tables_list( SPIDER_CONN *conn, int link_idx ) { - spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + spider_db_mbase *db_conn = (spider_db_mbase *) conn->db_conn; SPIDER_LINK_FOR_HASH *tmp_link_for_hash2 = &link_for_hash[link_idx]; - DBUG_ENTER("spider_mysql_handler::insert_lock_tables_list"); + DBUG_ENTER("spider_mbase_handler::insert_lock_tables_list"); DBUG_PRINT("info",("spider this=%p", this)); uint old_elements = db_conn->lock_table_hash.array.max_element; @@ -11271,7 +11534,7 @@ int spider_mysql_handler::insert_lock_tables_list( DBUG_RETURN(0); } -int spider_mysql_handler::append_lock_tables_list( +int spider_mbase_handler::append_lock_tables_list( SPIDER_CONN *conn, int link_idx, int *appended @@ -11279,8 +11542,8 @@ int spider_mysql_handler::append_lock_tables_list( int error_num; SPIDER_LINK_FOR_HASH *tmp_link_for_hash, *tmp_link_for_hash2; int conn_link_idx = spider->conn_link_idx[link_idx]; - spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; - DBUG_ENTER("spider_mysql_handler::append_lock_tables_list"); + spider_db_mbase *db_conn = (spider_db_mbase *) conn->db_conn; + DBUG_ENTER("spider_mbase_handler::append_lock_tables_list"); DBUG_PRINT("info",("spider this=%p", this)); tmp_link_for_hash2 = &link_for_hash[link_idx]; tmp_link_for_hash2->db_table_str = @@ -11342,14 +11605,14 @@ int spider_mysql_handler::append_lock_tables_list( DBUG_RETURN(0); } -int spider_mysql_handler::realloc_sql( +int spider_mbase_handler::realloc_sql( ulong *realloced ) { THD *thd = spider->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); - DBUG_ENTER("spider_mysql_handler::realloc_sql"); + DBUG_ENTER("spider_mbase_handler::realloc_sql"); DBUG_PRINT("info",("spider this=%p", this)); if ((int) sql.alloced_length() > init_sql_alloc_size * 2) { @@ -11396,10 +11659,10 @@ int spider_mysql_handler::realloc_sql( DBUG_RETURN(0); } -int spider_mysql_handler::reset_sql( +int spider_mbase_handler::reset_sql( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_sql"); + DBUG_ENTER("spider_mbase_handler::reset_sql"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) { @@ -11426,73 +11689,73 @@ int spider_mysql_handler::reset_sql( } #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_mysql_handler::reset_keys( +int spider_mbase_handler::reset_keys( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_keys"); + DBUG_ENTER("spider_mbase_handler::reset_keys"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_mysql_handler::reset_upds( +int spider_mbase_handler::reset_upds( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_upds"); + DBUG_ENTER("spider_mbase_handler::reset_upds"); DBUG_PRINT("info",("spider this=%p", this)); hs_upds.clear(); DBUG_RETURN(0); } -int spider_mysql_handler::reset_strs( +int spider_mbase_handler::reset_strs( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_strs"); + DBUG_ENTER("spider_mbase_handler::reset_strs"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_mysql_handler::reset_strs_pos( +int spider_mbase_handler::reset_strs_pos( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_strs_pos"); + DBUG_ENTER("spider_mbase_handler::reset_strs_pos"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_ASSERT(0); DBUG_RETURN(0); } -int spider_mysql_handler::push_back_upds( +int spider_mbase_handler::push_back_upds( SPIDER_HS_STRING_REF &info ) { int error_num; - DBUG_ENTER("spider_mysql_handler::push_back_upds"); + DBUG_ENTER("spider_mbase_handler::push_back_upds"); DBUG_PRINT("info",("spider this=%p", this)); error_num = hs_upds.push_back(info); DBUG_RETURN(error_num); } #endif -bool spider_mysql_handler::need_lock_before_set_sql_for_exec( +bool spider_mbase_handler::need_lock_before_set_sql_for_exec( ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::need_lock_before_set_sql_for_exec"); + DBUG_ENTER("spider_mbase_handler::need_lock_before_set_sql_for_exec"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(FALSE); } #ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_mysql_handler::set_sql_for_exec( +int spider_mbase_handler::set_sql_for_exec( ulong sql_type, int link_idx, SPIDER_LINK_IDX_CHAIN *link_idx_chain ) { int error_num; - DBUG_ENTER("spider_mysql_handler::set_sql_for_exec"); + DBUG_ENTER("spider_mbase_handler::set_sql_for_exec"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type & SPIDER_SQL_TYPE_SELECT_SQL) { - if ((error_num = spider_db_mysql_utility.reappend_tables( + if ((error_num = spider_db_mbase_utility->reappend_tables( spider->fields, link_idx_chain, &sql))) DBUG_RETURN(error_num); exec_sql = &sql; @@ -11501,7 +11764,7 @@ int spider_mysql_handler::set_sql_for_exec( } #endif -int spider_mysql_handler::set_sql_for_exec( +int spider_mbase_handler::set_sql_for_exec( ulong sql_type, int link_idx ) { @@ -11510,7 +11773,7 @@ int spider_mysql_handler::set_sql_for_exec( SPIDER_SHARE *share = spider->share; SPIDER_RESULT_LIST *result_list = &spider->result_list; int all_link_idx = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::set_sql_for_exec"); + DBUG_ENTER("spider_mbase_handler::set_sql_for_exec"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_type & (SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL)) { @@ -11561,7 +11824,7 @@ int spider_mysql_handler::set_sql_for_exec( exec_sql->length(table_name_pos); if (result_list->tmp_table_join && spider->bka_mode != 2) { - if ((error_num = spider_db_mysql_utility.append_from_with_alias( + if ((error_num = spider_db_mbase_utility->append_from_with_alias( exec_sql, table_names, table_name_lengths, table_aliases, table_alias_lengths, 2, &table_name_pos, TRUE)) @@ -11683,12 +11946,12 @@ int spider_mysql_handler::set_sql_for_exec( DBUG_RETURN(0); } -int spider_mysql_handler::set_sql_for_exec( +int spider_mbase_handler::set_sql_for_exec( spider_db_copy_table *tgt_ct, ulong sql_type ) { - spider_mysql_copy_table *mysql_ct = (spider_mysql_copy_table *) tgt_ct; - DBUG_ENTER("spider_mysql_handler::set_sql_for_exec"); + spider_mbase_copy_table *mysql_ct = (spider_mbase_copy_table *) tgt_ct; + DBUG_ENTER("spider_mbase_handler::set_sql_for_exec"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -11702,7 +11965,7 @@ int spider_mysql_handler::set_sql_for_exec( DBUG_RETURN(0); } -int spider_mysql_handler::execute_sql( +int spider_mbase_handler::execute_sql( ulong sql_type, SPIDER_CONN *conn, int quick_mode, @@ -11710,7 +11973,7 @@ int spider_mysql_handler::execute_sql( ) { spider_string *tgt_sql; uint tgt_length; - DBUG_ENTER("spider_mysql_handler::execute_sql"); + DBUG_ENTER("spider_mbase_handler::execute_sql"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -11764,23 +12027,23 @@ int spider_mysql_handler::execute_sql( )); } -int spider_mysql_handler::reset() +int spider_mbase_handler::reset() { - DBUG_ENTER("spider_mysql_handler::reset"); + DBUG_ENTER("spider_mbase_handler::reset"); DBUG_PRINT("info",("spider this=%p", this)); update_sql.length(0); DBUG_RETURN(0); } -int spider_mysql_handler::sts_mode_exchange( +int spider_mbase_handler::sts_mode_exchange( int sts_mode ) { - DBUG_ENTER("spider_mysql_handler::sts_mode_exchange"); + DBUG_ENTER("spider_mbase_handler::sts_mode_exchange"); DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); DBUG_RETURN(sts_mode); } -int spider_mysql_handler::show_table_status( +int spider_mbase_handler::show_table_status( int link_idx, int sts_mode, uint flag @@ -11791,7 +12054,7 @@ int spider_mysql_handler::show_table_status( SPIDER_SHARE *share = spider->share; uint pos = (2 * spider->conn_link_idx[link_idx]); ulonglong auto_increment_value = 0; - DBUG_ENTER("spider_mysql_handler::show_table_status"); + DBUG_ENTER("spider_mbase_handler::show_table_status"); DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); if (sts_mode == 1) @@ -12087,15 +12350,15 @@ int spider_mysql_handler::show_table_status( DBUG_RETURN(0); } -int spider_mysql_handler::crd_mode_exchange( +int spider_mbase_handler::crd_mode_exchange( int crd_mode ) { - DBUG_ENTER("spider_mysql_handler::crd_mode_exchange"); + DBUG_ENTER("spider_mbase_handler::crd_mode_exchange"); DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); DBUG_RETURN(crd_mode); } -int spider_mysql_handler::show_index( +int spider_mbase_handler::show_index( int link_idx, int crd_mode ) { @@ -12107,7 +12370,7 @@ int spider_mysql_handler::show_index( int roop_count; longlong *tmp_cardinality; uint pos = (2 * spider->conn_link_idx[link_idx]); - DBUG_ENTER("spider_mysql_handler::show_index"); + DBUG_ENTER("spider_mbase_handler::show_index"); DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); if (crd_mode == 1) { @@ -12380,7 +12643,7 @@ int spider_mysql_handler::show_index( DBUG_RETURN(0); } -int spider_mysql_handler::show_records( +int spider_mbase_handler::show_records( int link_idx ) { int error_num; @@ -12388,7 +12651,7 @@ int spider_mysql_handler::show_records( SPIDER_DB_RESULT *res; SPIDER_SHARE *share = spider->share; uint pos = spider->conn_link_idx[link_idx]; - DBUG_ENTER("spider_mysql_handler::show_records"); + DBUG_ENTER("spider_mbase_handler::show_records"); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; @@ -12493,17 +12756,17 @@ int spider_mysql_handler::show_records( DBUG_RETURN(0); } -int spider_mysql_handler::show_last_insert_id( +int spider_mbase_handler::show_last_insert_id( int link_idx, ulonglong &last_insert_id ) { SPIDER_CONN *conn = spider->conns[link_idx]; - DBUG_ENTER("spider_mysql_handler::show_last_insert_id"); + DBUG_ENTER("spider_mbase_handler::show_last_insert_id"); last_insert_id = conn->db_conn->last_insert_id(); DBUG_RETURN(0); } -ha_rows spider_mysql_handler::explain_select( +ha_rows spider_mbase_handler::explain_select( key_range *start_key, key_range *end_key, int link_idx @@ -12515,7 +12778,7 @@ ha_rows spider_mysql_handler::explain_select( SPIDER_DB_RESULT *res; ha_rows rows; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - DBUG_ENTER("spider_mysql_handler::explain_select"); + DBUG_ENTER("spider_mbase_handler::explain_select"); if ((error_num = dbton_hdl->append_explain_select_part( start_key, end_key, SPIDER_SQL_TYPE_OTHER_SQL, link_idx))) { @@ -12639,13 +12902,13 @@ ha_rows spider_mysql_handler::explain_select( DBUG_RETURN(rows); } -int spider_mysql_handler::lock_tables( +int spider_mbase_handler::lock_tables( int link_idx ) { int error_num; SPIDER_CONN *conn = spider->conns[link_idx]; spider_string *str = &sql; - DBUG_ENTER("spider_mysql_handler::lock_tables"); + DBUG_ENTER("spider_mbase_handler::lock_tables"); str->length(0); if ((error_num = conn->db_conn->append_lock_tables(str))) { @@ -12692,12 +12955,12 @@ int spider_mysql_handler::lock_tables( DBUG_RETURN(0); } -int spider_mysql_handler::unlock_tables( +int spider_mbase_handler::unlock_tables( int link_idx ) { int error_num; SPIDER_CONN *conn = spider->conns[link_idx]; - DBUG_ENTER("spider_mysql_handler::unlock_tables"); + DBUG_ENTER("spider_mbase_handler::unlock_tables"); if (conn->table_locked) { spider_string *str = &sql; @@ -12728,14 +12991,14 @@ int spider_mysql_handler::unlock_tables( DBUG_RETURN(0); } -int spider_mysql_handler::disable_keys( +int spider_mbase_handler::disable_keys( SPIDER_CONN *conn, int link_idx ) { int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::disable_keys"); + DBUG_ENTER("spider_mbase_handler::disable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -12777,14 +13040,14 @@ int spider_mysql_handler::disable_keys( DBUG_RETURN(0); } -int spider_mysql_handler::enable_keys( +int spider_mbase_handler::enable_keys( SPIDER_CONN *conn, int link_idx ) { int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::enable_keys"); + DBUG_ENTER("spider_mbase_handler::enable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -12826,7 +13089,7 @@ int spider_mysql_handler::enable_keys( DBUG_RETURN(0); } -int spider_mysql_handler::check_table( +int spider_mbase_handler::check_table( SPIDER_CONN *conn, int link_idx, HA_CHECK_OPT* check_opt @@ -12834,7 +13097,7 @@ int spider_mysql_handler::check_table( int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::check_table"); + DBUG_ENTER("spider_mbase_handler::check_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -12876,7 +13139,7 @@ int spider_mysql_handler::check_table( DBUG_RETURN(0); } -int spider_mysql_handler::repair_table( +int spider_mbase_handler::repair_table( SPIDER_CONN *conn, int link_idx, HA_CHECK_OPT* check_opt @@ -12884,7 +13147,7 @@ int spider_mysql_handler::repair_table( int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::repair_table"); + DBUG_ENTER("spider_mbase_handler::repair_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -12926,14 +13189,14 @@ int spider_mysql_handler::repair_table( DBUG_RETURN(0); } -int spider_mysql_handler::analyze_table( +int spider_mbase_handler::analyze_table( SPIDER_CONN *conn, int link_idx ) { int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::analyze_table"); + DBUG_ENTER("spider_mbase_handler::analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -12975,14 +13238,14 @@ int spider_mysql_handler::analyze_table( DBUG_RETURN(0); } -int spider_mysql_handler::optimize_table( +int spider_mbase_handler::optimize_table( SPIDER_CONN *conn, int link_idx ) { int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::optimize_table"); + DBUG_ENTER("spider_mbase_handler::optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -13024,7 +13287,7 @@ int spider_mysql_handler::optimize_table( DBUG_RETURN(0); } -int spider_mysql_handler::flush_tables( +int spider_mbase_handler::flush_tables( SPIDER_CONN *conn, int link_idx, bool lock @@ -13032,7 +13295,7 @@ int spider_mysql_handler::flush_tables( int error_num; SPIDER_SHARE *share = spider->share; spider_string *str = &spider->result_list.sqls[link_idx]; - DBUG_ENTER("spider_mysql_handler::flush_tables"); + DBUG_ENTER("spider_mbase_handler::flush_tables"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, @@ -13057,13 +13320,13 @@ int spider_mysql_handler::flush_tables( DBUG_RETURN(0); } -int spider_mysql_handler::flush_logs( +int spider_mbase_handler::flush_logs( SPIDER_CONN *conn, int link_idx ) { int error_num; SPIDER_SHARE *share = spider->share; - DBUG_ENTER("spider_mysql_handler::flush_logs"); + DBUG_ENTER("spider_mbase_handler::flush_logs"); DBUG_PRINT("info",("spider this=%p", this)); spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd, share); @@ -13082,16 +13345,16 @@ int spider_mysql_handler::flush_logs( DBUG_RETURN(0); } -int spider_mysql_handler::insert_opened_handler( +int spider_mbase_handler::insert_opened_handler( SPIDER_CONN *conn, int link_idx ) { - spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + spider_db_mbase *db_conn = (spider_db_mbase *) conn->db_conn; SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; DBUG_ASSERT(tmp_link_for_hash->spider == spider); DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); uint old_elements = db_conn->handler_open_array.max_element; - DBUG_ENTER("spider_mysql_handler::insert_opened_handler"); + DBUG_ENTER("spider_mbase_handler::insert_opened_handler"); DBUG_PRINT("info",("spider this=%p", this)); if (insert_dynamic(&db_conn->handler_open_array, (uchar*) &tmp_link_for_hash)) @@ -13108,14 +13371,14 @@ int spider_mysql_handler::insert_opened_handler( DBUG_RETURN(0); } -int spider_mysql_handler::delete_opened_handler( +int spider_mbase_handler::delete_opened_handler( SPIDER_CONN *conn, int link_idx ) { - spider_db_mysql *db_conn = (spider_db_mysql *) conn->db_conn; + spider_db_mbase *db_conn = (spider_db_mbase *) conn->db_conn; uint roop_count, elements = db_conn->handler_open_array.elements; SPIDER_LINK_FOR_HASH *tmp_link_for_hash; - DBUG_ENTER("spider_mysql_handler::delete_opened_handler"); + DBUG_ENTER("spider_mbase_handler::delete_opened_handler"); DBUG_PRINT("info",("spider this=%p", this)); for (roop_count = 0; roop_count < elements; roop_count++) { @@ -13131,27 +13394,27 @@ int spider_mysql_handler::delete_opened_handler( DBUG_RETURN(0); } -int spider_mysql_handler::sync_from_clone_source( +int spider_mbase_handler::sync_from_clone_source( spider_db_handler *dbton_hdl ) { - DBUG_ENTER("spider_mysql_handler::sync_from_clone_source"); + DBUG_ENTER("spider_mbase_handler::sync_from_clone_source"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(0); } -bool spider_mysql_handler::support_use_handler( +bool spider_mbase_handler::support_use_handler( int use_handler ) { - DBUG_ENTER("spider_mysql_handler::support_use_handler"); + DBUG_ENTER("spider_mbase_handler::support_use_handler"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -void spider_mysql_handler::minimum_select_bitmap_create() +void spider_mbase_handler::minimum_select_bitmap_create() { TABLE *table = spider->get_table(); Field **field_p; - DBUG_ENTER("spider_mysql_handler::minimum_select_bitmap_create"); + DBUG_ENTER("spider_mbase_handler::minimum_select_bitmap_create"); DBUG_PRINT("info",("spider this=%p", this)); memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set)); if ( @@ -13218,10 +13481,10 @@ void spider_mysql_handler::minimum_select_bitmap_create() DBUG_VOID_RETURN; } -bool spider_mysql_handler::minimum_select_bit_is_set( +bool spider_mbase_handler::minimum_select_bit_is_set( uint field_index ) { - DBUG_ENTER("spider_mysql_handler::minimum_select_bit_is_set"); + DBUG_ENTER("spider_mbase_handler::minimum_select_bit_is_set"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider field_index=%u", field_index)); DBUG_PRINT("info",("spider minimum_select_bitmap=%s", @@ -13230,12 +13493,12 @@ bool spider_mysql_handler::minimum_select_bit_is_set( DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index)); } -void spider_mysql_handler::copy_minimum_select_bitmap( +void spider_mbase_handler::copy_minimum_select_bitmap( uchar *bitmap ) { int roop_count; TABLE *table = spider->get_table(); - DBUG_ENTER("spider_mysql_handler::copy_minimum_select_bitmap"); + DBUG_ENTER("spider_mbase_handler::copy_minimum_select_bitmap"); for (roop_count = 0; roop_count < (int) ((table->s->fields + 7) / 8); roop_count++) @@ -13249,9 +13512,9 @@ void spider_mysql_handler::copy_minimum_select_bitmap( DBUG_VOID_RETURN; } -int spider_mysql_handler::init_union_table_name_pos() +int spider_mbase_handler::init_union_table_name_pos() { - DBUG_ENTER("spider_mysql_handler::init_union_table_name_pos"); + DBUG_ENTER("spider_mbase_handler::init_union_table_name_pos"); DBUG_PRINT("info",("spider this=%p", this)); if (!union_table_name_pos_first) { @@ -13268,9 +13531,9 @@ int spider_mysql_handler::init_union_table_name_pos() DBUG_RETURN(0); } -int spider_mysql_handler::set_union_table_name_pos() +int spider_mbase_handler::set_union_table_name_pos() { - DBUG_ENTER("spider_mysql_handler::set_union_table_name_pos"); + DBUG_ENTER("spider_mbase_handler::set_union_table_name_pos"); DBUG_PRINT("info",("spider this=%p", this)); if (union_table_name_pos_current->tgt_num >= SPIDER_INT_HLD_TGT_SIZE) { @@ -13293,12 +13556,12 @@ int spider_mysql_handler::set_union_table_name_pos() DBUG_RETURN(0); } -int spider_mysql_handler::reset_union_table_name( +int spider_mbase_handler::reset_union_table_name( spider_string *str, int link_idx, ulong sql_type ) { - DBUG_ENTER("spider_mysql_handler::reset_union_table_name"); + DBUG_ENTER("spider_mbase_handler::reset_union_table_name"); DBUG_PRINT("info",("spider this=%p", this)); if (!union_table_name_pos_current) DBUG_RETURN(0); @@ -13321,7 +13584,7 @@ int spider_mysql_handler::reset_union_table_name( } #ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_mysql_handler::append_from_and_tables_part( +int spider_mbase_handler::append_from_and_tables_part( spider_fields *fields, ulong sql_type ) { @@ -13329,7 +13592,7 @@ int spider_mysql_handler::append_from_and_tables_part( spider_string *str; SPIDER_TABLE_HOLDER *table_holder; TABLE_LIST *table_list; - DBUG_ENTER("spider_mysql_handler::append_from_and_tables_part"); + DBUG_ENTER("spider_mbase_handler::append_from_and_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13342,19 +13605,19 @@ int spider_mysql_handler::append_from_and_tables_part( fields->set_pos_to_first_table_holder(); table_holder = fields->get_next_table_holder(); table_list = table_holder->table->pos_in_table_list; - error_num = spider_db_mysql_utility.append_from_and_tables( + error_num = spider_db_mbase_utility->append_from_and_tables( table_holder->spider, fields, str, table_list, fields->get_table_count()); DBUG_RETURN(error_num); } -int spider_mysql_handler::reappend_tables_part( +int spider_mbase_handler::reappend_tables_part( spider_fields *fields, ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::reappend_tables_part"); + DBUG_ENTER("spider_mbase_handler::reappend_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13364,17 +13627,17 @@ int spider_mysql_handler::reappend_tables_part( default: DBUG_RETURN(0); } - error_num = spider_db_mysql_utility.reappend_tables(fields, + error_num = spider_db_mbase_utility->reappend_tables(fields, link_idx_chain, str); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_where_part( +int spider_mbase_handler::append_where_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_where_part"); + DBUG_ENTER("spider_mbase_handler::append_where_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13384,16 +13647,16 @@ int spider_mysql_handler::append_where_part( default: DBUG_RETURN(0); } - error_num = spider_db_mysql_utility.append_where(str); + error_num = spider_db_mbase_utility->append_where(str); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_having_part( +int spider_mbase_handler::append_having_part( ulong sql_type ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_having_part"); + DBUG_ENTER("spider_mbase_handler::append_having_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13403,11 +13666,11 @@ int spider_mysql_handler::append_having_part( default: DBUG_RETURN(0); } - error_num = spider_db_mysql_utility.append_having(str); + error_num = spider_db_mbase_utility->append_having(str); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_item_type_part( +int spider_mbase_handler::append_item_type_part( Item *item, const char *alias, uint alias_length, @@ -13417,7 +13680,7 @@ int spider_mysql_handler::append_item_type_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_item_type_part"); + DBUG_ENTER("spider_mbase_handler::append_item_type_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13428,11 +13691,11 @@ int spider_mysql_handler::append_item_type_part( DBUG_RETURN(0); } error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, spider_dbton_mysql.dbton_id, use_fields, fields); + alias, alias_length, dbton_id, use_fields, fields); DBUG_RETURN(error_num); } -int spider_mysql_handler::append_list_item_select_part( +int spider_mbase_handler::append_list_item_select_part( List *select, const char *alias, uint alias_length, @@ -13442,7 +13705,7 @@ int spider_mysql_handler::append_list_item_select_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_list_item_select_part"); + DBUG_ENTER("spider_mbase_handler::append_list_item_select_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13457,7 +13720,7 @@ int spider_mysql_handler::append_list_item_select_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_list_item_select( +int spider_mbase_handler::append_list_item_select( List *select, spider_string *str, const char *alias, @@ -13466,12 +13729,12 @@ int spider_mysql_handler::append_list_item_select( spider_fields *fields ) { int error_num; - uint dbton_id = spider_dbton_mysql.dbton_id, length; + uint32 length; List_iterator_fast it(*select); Item *item; Field *field; const char *item_name; - DBUG_ENTER("spider_mysql_handler::append_list_item_select"); + DBUG_ENTER("spider_mbase_handler::append_list_item_select"); DBUG_PRINT("info",("spider this=%p", this)); while ((item = it++)) { @@ -13495,7 +13758,7 @@ int spider_mysql_handler::append_list_item_select( )) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - if ((error_num = spider_db_mysql_utility.append_name(str, + if ((error_num = spider_db_mbase_utility->append_name(str, item_name, length))) { DBUG_RETURN(error_num); @@ -13506,7 +13769,7 @@ int spider_mysql_handler::append_list_item_select( DBUG_RETURN(0); } -int spider_mysql_handler::append_group_by_part( +int spider_mbase_handler::append_group_by_part( ORDER *order, const char *alias, uint alias_length, @@ -13516,7 +13779,7 @@ int spider_mysql_handler::append_group_by_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_group_by_part"); + DBUG_ENTER("spider_mbase_handler::append_group_by_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13531,7 +13794,7 @@ int spider_mysql_handler::append_group_by_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_group_by( +int spider_mbase_handler::append_group_by( ORDER *order, spider_string *str, const char *alias, @@ -13540,8 +13803,7 @@ int spider_mysql_handler::append_group_by( spider_fields *fields ) { int error_num; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_handler::append_group_by"); + DBUG_ENTER("spider_mbase_handler::append_group_by"); DBUG_PRINT("info",("spider this=%p", this)); if (order) { @@ -13564,7 +13826,7 @@ int spider_mysql_handler::append_group_by( DBUG_RETURN(0); } -int spider_mysql_handler::append_order_by_part( +int spider_mbase_handler::append_order_by_part( ORDER *order, const char *alias, uint alias_length, @@ -13574,7 +13836,7 @@ int spider_mysql_handler::append_order_by_part( ) { int error_num; spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_order_by_part"); + DBUG_ENTER("spider_mbase_handler::append_order_by_part"); DBUG_PRINT("info",("spider this=%p", this)); switch (sql_type) { @@ -13589,7 +13851,7 @@ int spider_mysql_handler::append_order_by_part( DBUG_RETURN(error_num); } -int spider_mysql_handler::append_order_by( +int spider_mbase_handler::append_order_by( ORDER *order, spider_string *str, const char *alias, @@ -13598,8 +13860,7 @@ int spider_mysql_handler::append_order_by( spider_fields *fields ) { int error_num; - uint dbton_id = spider_dbton_mysql.dbton_id; - DBUG_ENTER("spider_mysql_handler::append_order_by"); + DBUG_ENTER("spider_mbase_handler::append_order_by"); DBUG_PRINT("info",("spider this=%p", this)); if (order) { @@ -13631,18 +13892,45 @@ int spider_mysql_handler::append_order_by( } #endif -spider_mysql_copy_table::spider_mysql_copy_table( - spider_mysql_share *db_share +spider_mbase_copy_table::spider_mbase_copy_table( + spider_mbase_share *db_share ) : spider_db_copy_table( db_share ), mysql_share(db_share) { + DBUG_ENTER("spider_mbase_copy_table::spider_mbase_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mysql_copy_table::spider_mysql_copy_table( + spider_mbase_share *db_share +) : spider_mbase_copy_table( + db_share +) { DBUG_ENTER("spider_mysql_copy_table::spider_mysql_copy_table"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_VOID_RETURN; } +spider_mariadb_copy_table::spider_mariadb_copy_table( + spider_mbase_share *db_share +) : spider_mbase_copy_table( + db_share +) { + DBUG_ENTER("spider_mariadb_copy_table::spider_mariadb_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +spider_mbase_copy_table::~spider_mbase_copy_table() +{ + DBUG_ENTER("spider_mbase_copy_table::~spider_mbase_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + spider_mysql_copy_table::~spider_mysql_copy_table() { DBUG_ENTER("spider_mysql_copy_table::~spider_mysql_copy_table"); @@ -13650,26 +13938,33 @@ spider_mysql_copy_table::~spider_mysql_copy_table() DBUG_VOID_RETURN; } -int spider_mysql_copy_table::init() +spider_mariadb_copy_table::~spider_mariadb_copy_table() { - DBUG_ENTER("spider_mysql_copy_table::init"); + DBUG_ENTER("spider_mariadb_copy_table::~spider_mariadb_copy_table"); + DBUG_PRINT("info",("spider this=%p", this)); + DBUG_VOID_RETURN; +} + +int spider_mbase_copy_table::init() +{ + DBUG_ENTER("spider_mbase_copy_table::init"); DBUG_PRINT("info",("spider this=%p", this)); sql.init_calc_mem(78); DBUG_RETURN(0); } -void spider_mysql_copy_table::set_sql_charset( +void spider_mbase_copy_table::set_sql_charset( CHARSET_INFO *cs ) { - DBUG_ENTER("spider_mysql_copy_table::set_sql_charset"); + DBUG_ENTER("spider_mbase_copy_table::set_sql_charset"); DBUG_PRINT("info",("spider this=%p", this)); sql.set_charset(cs); DBUG_VOID_RETURN; } -int spider_mysql_copy_table::append_select_str() +int spider_mbase_copy_table::append_select_str() { - DBUG_ENTER("spider_mysql_copy_table::append_select_str"); + DBUG_ENTER("spider_mbase_copy_table::append_select_str"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_SELECT_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13677,10 +13972,10 @@ int spider_mysql_copy_table::append_select_str() DBUG_RETURN(0); } -int spider_mysql_copy_table::append_insert_str( +int spider_mbase_copy_table::append_insert_str( int insert_flg ) { - DBUG_ENTER("spider_mysql_copy_table::append_insert_str"); + DBUG_ENTER("spider_mbase_copy_table::append_insert_str"); DBUG_PRINT("info",("spider this=%p", this)); if (insert_flg & SPIDER_DB_INSERT_REPLACE) { @@ -13719,12 +14014,12 @@ int spider_mysql_copy_table::append_insert_str( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_table_columns( +int spider_mbase_copy_table::append_table_columns( TABLE_SHARE *table_share ) { int error_num; Field **field; - DBUG_ENTER("spider_mysql_copy_table::append_table_columns"); + DBUG_ENTER("spider_mbase_copy_table::append_table_columns"); DBUG_PRINT("info",("spider this=%p", this)); for (field = table_share->field; *field; field++) { @@ -13732,7 +14027,7 @@ int spider_mysql_copy_table::append_table_columns( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - (*field)->field_name, spider_dbton_mysql.dbton_id))) + (*field)->field_name, dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13743,9 +14038,9 @@ int spider_mysql_copy_table::append_table_columns( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_from_str() +int spider_mbase_copy_table::append_from_str() { - DBUG_ENTER("spider_mysql_copy_table::append_from_str"); + DBUG_ENTER("spider_mbase_copy_table::append_from_str"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_FROM_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13753,40 +14048,40 @@ int spider_mysql_copy_table::append_from_str() DBUG_RETURN(0); } -int spider_mysql_copy_table::append_table_name( +int spider_mbase_copy_table::append_table_name( int link_idx ) { int error_num; - DBUG_ENTER("spider_mysql_copy_table::append_table_name"); + DBUG_ENTER("spider_mbase_copy_table::append_table_name"); DBUG_PRINT("info",("spider this=%p", this)); error_num = mysql_share->append_table_name(&sql, link_idx); DBUG_RETURN(error_num); } -void spider_mysql_copy_table::set_sql_pos() +void spider_mbase_copy_table::set_sql_pos() { - DBUG_ENTER("spider_mysql_copy_table::set_sql_pos"); + DBUG_ENTER("spider_mbase_copy_table::set_sql_pos"); DBUG_PRINT("info",("spider this=%p", this)); pos = sql.length(); DBUG_VOID_RETURN; } -void spider_mysql_copy_table::set_sql_to_pos() +void spider_mbase_copy_table::set_sql_to_pos() { - DBUG_ENTER("spider_mysql_copy_table::set_sql_to_pos"); + DBUG_ENTER("spider_mbase_copy_table::set_sql_to_pos"); DBUG_PRINT("info",("spider this=%p", this)); sql.length(pos); DBUG_VOID_RETURN; } -int spider_mysql_copy_table::append_copy_where( +int spider_mbase_copy_table::append_copy_where( spider_db_copy_table *source_ct, KEY *key_info, ulong *last_row_pos, ulong *last_lengths ) { int error_num, roop_count, roop_count2; - DBUG_ENTER("spider_mysql_copy_table::append_copy_where"); + DBUG_ENTER("spider_mbase_copy_table::append_copy_where"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_WHERE_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) { @@ -13832,7 +14127,7 @@ int spider_mysql_copy_table::append_copy_where( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_key_order_str( +int spider_mbase_copy_table::append_key_order_str( KEY *key_info, int start_pos, bool desc_flg @@ -13840,7 +14135,7 @@ int spider_mysql_copy_table::append_key_order_str( int length, error_num; KEY_PART_INFO *key_part; Field *field; - DBUG_ENTER("spider_mysql_copy_table::append_key_order_str"); + DBUG_ENTER("spider_mbase_copy_table::append_key_order_str"); DBUG_PRINT("info",("spider this=%p", this)); if ((int) spider_user_defined_key_parts(key_info) > start_pos) { @@ -13861,7 +14156,7 @@ int spider_mysql_copy_table::append_key_order_str( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - field->field_name, spider_dbton_mysql.dbton_id))) + field->field_name, dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13891,7 +14186,7 @@ int spider_mysql_copy_table::append_key_order_str( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - field->field_name, spider_dbton_mysql.dbton_id))) + field->field_name, dbton_id))) DBUG_RETURN(error_num); if (key_part->key_part_flag & HA_REVERSE_SORT) { @@ -13914,13 +14209,13 @@ int spider_mysql_copy_table::append_key_order_str( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_limit( +int spider_mbase_copy_table::append_limit( longlong offset, longlong limit ) { char buf[SPIDER_LONGLONG_LEN + 1]; uint32 length; - DBUG_ENTER("spider_mysql_copy_table::append_limit"); + DBUG_ENTER("spider_mbase_copy_table::append_limit"); DBUG_PRINT("info",("spider this=%p", this)); if (offset || limit < 9223372036854775807LL) { @@ -13942,9 +14237,9 @@ int spider_mysql_copy_table::append_limit( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_into_str() +int spider_mbase_copy_table::append_into_str() { - DBUG_ENTER("spider_mysql_copy_table::append_into_str"); + DBUG_ENTER("spider_mbase_copy_table::append_into_str"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_INTO_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13952,9 +14247,9 @@ int spider_mysql_copy_table::append_into_str() DBUG_RETURN(0); } -int spider_mysql_copy_table::append_open_paren_str() +int spider_mbase_copy_table::append_open_paren_str() { - DBUG_ENTER("spider_mysql_copy_table::append_open_paren_str"); + DBUG_ENTER("spider_mbase_copy_table::append_open_paren_str"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_OPEN_PAREN_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -13962,9 +14257,9 @@ int spider_mysql_copy_table::append_open_paren_str() DBUG_RETURN(0); } -int spider_mysql_copy_table::append_values_str() +int spider_mbase_copy_table::append_values_str() { - DBUG_ENTER("spider_mysql_copy_table::append_values_str"); + DBUG_ENTER("spider_mbase_copy_table::append_values_str"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN)) @@ -13975,10 +14270,10 @@ int spider_mysql_copy_table::append_values_str() DBUG_RETURN(0); } -int spider_mysql_copy_table::append_select_lock_str( +int spider_mbase_copy_table::append_select_lock_str( int lock_mode ) { - DBUG_ENTER("spider_mysql_copy_table::append_select_lock_str"); + DBUG_ENTER("spider_mbase_copy_table::append_select_lock_str"); DBUG_PRINT("info",("spider this=%p", this)); if (lock_mode == SPIDER_LOCK_MODE_EXCLUSIVE) { @@ -13994,20 +14289,20 @@ int spider_mysql_copy_table::append_select_lock_str( DBUG_RETURN(0); } -int spider_mysql_copy_table::exec_query( +int spider_mbase_copy_table::exec_query( SPIDER_CONN *conn, int quick_mode, int *need_mon ) { int error_num; - DBUG_ENTER("spider_mysql_copy_table::exec_query"); + DBUG_ENTER("spider_mbase_copy_table::exec_query"); DBUG_PRINT("info",("spider this=%p", this)); error_num = spider_db_query(conn, sql.ptr(), sql.length(), quick_mode, need_mon); DBUG_RETURN(error_num); } -int spider_mysql_copy_table::copy_key_row( +int spider_mbase_copy_table::copy_key_row( spider_db_copy_table *source_ct, Field *field, ulong *row_pos, @@ -14016,14 +14311,14 @@ int spider_mysql_copy_table::copy_key_row( const int joint_length ) { int error_num; - spider_string *source_str = &((spider_mysql_copy_table *) source_ct)->sql; - DBUG_ENTER("spider_mysql_copy_table::copy_key_row"); + spider_string *source_str = &((spider_mbase_copy_table *) source_ct)->sql; + DBUG_ENTER("spider_mbase_copy_table::copy_key_row"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); if ((error_num = spider_db_append_name_with_quote_str(&sql, - field->field_name, spider_dbton_mysql.dbton_id))) + field->field_name, dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length + SPIDER_SQL_AND_LEN)) @@ -14035,12 +14330,12 @@ int spider_mysql_copy_table::copy_key_row( DBUG_RETURN(0); } -int spider_mysql_copy_table::copy_row( +int spider_mbase_copy_table::copy_row( Field *field, SPIDER_DB_ROW *row ) { int error_num; - DBUG_ENTER("spider_mysql_copy_table::copy_row"); + DBUG_ENTER("spider_mbase_copy_table::copy_row"); DBUG_PRINT("info",("spider this=%p", this)); if (row->is_null()) { @@ -14053,7 +14348,7 @@ int spider_mysql_copy_table::copy_row( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); if ((error_num = row->append_escaped_to_str(&sql, - spider_dbton_mysql.dbton_id))) + dbton_id))) DBUG_RETURN(error_num); if (sql.reserve(SPIDER_SQL_VALUE_QUOTE_LEN + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -14068,7 +14363,7 @@ int spider_mysql_copy_table::copy_row( DBUG_RETURN(0); } -int spider_mysql_copy_table::copy_rows( +int spider_mbase_copy_table::copy_rows( TABLE *table, SPIDER_DB_ROW *row, ulong **last_row_pos, @@ -14077,7 +14372,7 @@ int spider_mysql_copy_table::copy_rows( int error_num; Field **field; ulong *lengths2, *row_pos2; - DBUG_ENTER("spider_mysql_copy_table::copy_rows"); + DBUG_ENTER("spider_mbase_copy_table::copy_rows"); DBUG_PRINT("info",("spider this=%p", this)); row_pos2 = *last_row_pos; lengths2 = *last_lengths; @@ -14108,13 +14403,13 @@ int spider_mysql_copy_table::copy_rows( DBUG_RETURN(0); } -int spider_mysql_copy_table::copy_rows( +int spider_mbase_copy_table::copy_rows( TABLE *table, SPIDER_DB_ROW *row ) { int error_num; Field **field; - DBUG_ENTER("spider_mysql_copy_table::copy_rows"); + DBUG_ENTER("spider_mbase_copy_table::copy_rows"); DBUG_PRINT("info",("spider this=%p", this)); for ( field = table->field; @@ -14138,22 +14433,22 @@ int spider_mysql_copy_table::copy_rows( DBUG_RETURN(0); } -int spider_mysql_copy_table::append_insert_terminator() +int spider_mbase_copy_table::append_insert_terminator() { - DBUG_ENTER("spider_mysql_copy_table::append_insert_terminator"); + DBUG_ENTER("spider_mbase_copy_table::append_insert_terminator"); DBUG_PRINT("info",("spider this=%p", this)); sql.length(sql.length() - SPIDER_SQL_COMMA_LEN - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN(0); } -int spider_mysql_copy_table::copy_insert_values( +int spider_mbase_copy_table::copy_insert_values( spider_db_copy_table *source_ct ) { - spider_mysql_copy_table *tmp_ct = (spider_mysql_copy_table *) source_ct; + spider_mbase_copy_table *tmp_ct = (spider_mbase_copy_table *) source_ct; spider_string *source_str = &tmp_ct->sql; int values_length = source_str->length() - tmp_ct->pos; const char *values_ptr = source_str->ptr() + tmp_ct->pos; - DBUG_ENTER("spider_mysql_copy_table::copy_insert_values"); + DBUG_ENTER("spider_mbase_copy_table::copy_insert_values"); DBUG_PRINT("info",("spider this=%p", this)); if (sql.reserve(values_length)) { diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 9a709f46c51..3448cea06cc 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -13,11 +13,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class spider_db_mysql_util: public spider_db_util +class spider_db_mbase_util: public spider_db_util { public: - spider_db_mysql_util(); - ~spider_db_mysql_util(); + spider_db_mbase_util(); + virtual ~spider_db_mbase_util(); int append_name( spider_string *str, const char *name, @@ -174,7 +174,21 @@ public: #endif }; -class spider_db_mysql_row: public spider_db_row +class spider_db_mysql_util: public spider_db_mbase_util +{ +public: + spider_db_mysql_util(); + ~spider_db_mysql_util(); +}; + +class spider_db_mariadb_util: public spider_db_mbase_util +{ +public: + spider_db_mariadb_util(); + ~spider_db_mariadb_util(); +}; + +class spider_db_mbase_row: public spider_db_row { public: MYSQL_ROW row; @@ -184,8 +198,10 @@ public: uint field_count; uint record_size; bool cloned; - spider_db_mysql_row(); - ~spider_db_mysql_row(); + spider_db_mbase_row( + uint dbton_id + ); + virtual ~spider_db_mbase_row(); int store_to_field( Field *field, CHARSET_INFO *access_charset @@ -214,15 +230,31 @@ public: uint get_byte_size(); }; -class spider_db_mysql_result: public spider_db_result +class spider_db_mysql_row: public spider_db_mbase_row +{ +public: + spider_db_mysql_row(); + ~spider_db_mysql_row(); +}; + +class spider_db_mariadb_row: public spider_db_mbase_row +{ +public: + spider_db_mariadb_row(); + ~spider_db_mariadb_row(); +}; + +class spider_db_mbase_result: public spider_db_result { public: MYSQL_RES *db_result; - spider_db_mysql_row row; + spider_db_mbase_row row; MYSQL_ROW_OFFSET first_row; int store_error_num; - spider_db_mysql_result(SPIDER_DB_CONN *in_db_conn); - ~spider_db_mysql_result(); + spider_db_mbase_result( + SPIDER_DB_CONN *in_db_conn + ); + virtual ~spider_db_mbase_result(); bool has_result(); void free_result(); SPIDER_DB_ROW *current_row(); @@ -289,9 +321,29 @@ public: #endif }; -class spider_db_mysql: public spider_db_conn +class spider_db_mysql_result: public spider_db_mbase_result { - int stored_error; +public: + spider_db_mysql_result( + SPIDER_DB_CONN *in_db_conn + ); + ~spider_db_mysql_result(); +}; + +class spider_db_mariadb_result: public spider_db_mbase_result +{ +public: + spider_db_mariadb_result( + SPIDER_DB_CONN *in_db_conn + ); + ~spider_db_mariadb_result(); +}; + +class spider_db_mbase: public spider_db_conn +{ +protected: + int stored_error; + spider_db_mbase_util *spider_db_mbase_utility; public: MYSQL *db_conn; HASH lock_table_hash; @@ -306,10 +358,11 @@ public: const char *handler_open_array_func_name; const char *handler_open_array_file_name; ulong handler_open_array_line_no; - spider_db_mysql( - SPIDER_CONN *conn + spider_db_mbase( + SPIDER_CONN *conn, + spider_db_mbase_util *spider_db_mbase_utility ); - ~spider_db_mysql(); + virtual ~spider_db_mbase(); int init(); bool is_connected(); void bg_connect(); @@ -524,8 +577,28 @@ public: ); }; -class spider_mysql_share: public spider_db_share +class spider_db_mysql: public spider_db_mbase { +public: + spider_db_mysql( + SPIDER_CONN *conn + ); + ~spider_db_mysql(); +}; + +class spider_db_mariadb: public spider_db_mbase +{ +public: + spider_db_mariadb( + SPIDER_CONN *conn + ); + ~spider_db_mariadb(); +}; + +class spider_mbase_share: public spider_db_share +{ +protected: + spider_db_mbase_util *spider_db_mbase_utility; public: spider_string *table_select; int table_select_pos; @@ -547,10 +620,12 @@ public: bool same_db_table_name; int first_all_link_idx; - spider_mysql_share( - st_spider_share *share + spider_mbase_share( + st_spider_share *share, + uint dbton_id, + spider_db_mbase_util *spider_db_mbase_utility ); - ~spider_mysql_share(); + virtual ~spider_mbase_share(); int init(); uint get_column_name_length( uint field_index @@ -585,7 +660,7 @@ public: spider_string *str ); #endif -private: +protected: int create_table_names_str(); void free_table_names_str(); int create_column_name_str(); @@ -603,8 +678,28 @@ private: ); }; -class spider_mysql_handler: public spider_db_handler +class spider_mysql_share: public spider_mbase_share { +public: + spider_mysql_share( + st_spider_share *share + ); + ~spider_mysql_share(); +}; + +class spider_mariadb_share: public spider_mbase_share +{ +public: + spider_mariadb_share( + st_spider_share *share + ); + ~spider_mariadb_share(); +}; + +class spider_mbase_handler: public spider_db_handler +{ +protected: + spider_db_mbase_util *spider_db_mbase_utility; spider_string sql; spider_string sql_part; spider_string sql_part2; @@ -614,7 +709,7 @@ class spider_mysql_handler: public spider_db_handler int limit_pos; public: int table_name_pos; -private: +protected: int ha_read_pos; int ha_next_pos; int ha_where_pos; @@ -647,14 +742,15 @@ private: SPIDER_INT_HLD *union_table_name_pos_first; SPIDER_INT_HLD *union_table_name_pos_current; public: - spider_mysql_share *mysql_share; + spider_mbase_share *mysql_share; SPIDER_LINK_FOR_HASH *link_for_hash; uchar *minimum_select_bitmap; - spider_mysql_handler( + spider_mbase_handler( ha_spider *spider, - spider_mysql_share *share + spider_mbase_share *share, + spider_db_mbase_util *spider_db_mbase_utility ); - ~spider_mysql_handler(); + virtual ~spider_mbase_handler(); int init(); int append_index_hint( spider_string *str, @@ -1498,16 +1594,36 @@ public: #endif }; -class spider_mysql_copy_table: public spider_db_copy_table +class spider_mysql_handler: public spider_mbase_handler { public: - spider_mysql_share *mysql_share; + spider_mysql_handler( + ha_spider *spider, + spider_mbase_share *share + ); + ~spider_mysql_handler(); +}; + +class spider_mariadb_handler: public spider_mbase_handler +{ +public: + spider_mariadb_handler( + ha_spider *spider, + spider_mbase_share *share + ); + ~spider_mariadb_handler(); +}; + +class spider_mbase_copy_table: public spider_db_copy_table +{ +public: + spider_mbase_share *mysql_share; spider_string sql; uint pos; - spider_mysql_copy_table( - spider_mysql_share *db_share + spider_mbase_copy_table( + spider_mbase_share *db_share ); - ~spider_mysql_copy_table(); + virtual ~spider_mbase_copy_table(); int init(); void set_sql_charset( CHARSET_INFO *cs @@ -1578,3 +1694,21 @@ public: spider_db_copy_table *source_ct ); }; + +class spider_mysql_copy_table: public spider_mbase_copy_table +{ +public: + spider_mysql_copy_table( + spider_mbase_share *db_share + ); + ~spider_mysql_copy_table(); +}; + +class spider_mariadb_copy_table: public spider_mbase_copy_table +{ +public: + spider_mariadb_copy_table( + spider_mbase_share *db_share + ); + ~spider_mariadb_copy_table(); +}; diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 82a1e9a0fbc..eae749f6867 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -512,7 +512,7 @@ SPIDER_DB_ROW *spider_db_oracle_row::clone() spider_db_oracle_row *clone_row; DBUG_ENTER("spider_db_oracle_row::clone"); DBUG_PRINT("info",("spider this=%p", this)); - if (!(clone_row = new spider_db_oracle_row())) + if (!(clone_row = new spider_db_oracle_row(dbton_id))) { DBUG_RETURN(NULL); } @@ -772,9 +772,9 @@ int spider_db_oracle_row::fetch() } spider_db_oracle_result::spider_db_oracle_result(SPIDER_DB_CONN *in_db_conn) : - spider_db_result(in_db_conn, spider_dbton_oracle.dbton_id), + spider_db_result(in_db_conn), db_conn(NULL), stmtp(NULL), field_count(0), access_charset(NULL), - fetched(FALSE) + fetched(FALSE), row(in_db_conn->dbton_id) { DBUG_ENTER("spider_db_oracle_result::spider_db_oracle_result"); DBUG_PRINT("info",("spider this=%p", this)); @@ -4365,7 +4365,8 @@ int spider_db_oracle_util::append_having( spider_oracle_share::spider_oracle_share( st_spider_share *share ) : spider_db_share( - share + share, + spider_dbton_oracle.dbton_id ), table_select(NULL), table_select_pos(0), diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index fe5265184b6..0e706219432 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -128,6 +128,7 @@ extern long spider_conn_mutex_id; handlerton *spider_hton_ptr; SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; extern SPIDER_DBTON spider_dbton_mysql; +extern SPIDER_DBTON spider_dbton_mariadb; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) extern SPIDER_DBTON spider_dbton_handlersocket; #endif @@ -7362,15 +7363,22 @@ int spider_db_init( #endif spider_dbton_mysql.dbton_id = dbton_id; + spider_dbton_mysql.db_util->dbton_id = dbton_id; spider_dbton[dbton_id] = spider_dbton_mysql; ++dbton_id; + spider_dbton_mariadb.dbton_id = dbton_id; + spider_dbton_mariadb.db_util->dbton_id = dbton_id; + spider_dbton[dbton_id] = spider_dbton_mariadb; + ++dbton_id; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) spider_dbton_handlersocket.dbton_id = dbton_id; + spider_dbton_handlersocket.db_util->dbton_id = dbton_id; spider_dbton[dbton_id] = spider_dbton_handlersocket; ++dbton_id; #endif #ifdef HAVE_ORACLE_OCI spider_dbton_oracle.dbton_id = dbton_id; + spider_dbton_oracle.db_util->dbton_id = dbton_id; spider_dbton[dbton_id] = spider_dbton_oracle; ++dbton_id; #endif From 20e19f69750466ac2c9bbf82ef5ba396fc842a08 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 31 Jan 2019 22:08:45 +0100 Subject: [PATCH 17/22] MDEV-17479 Assertion `mysql_socket.fd != -1' failed in inline_mysql_socket_send on server shutdown Do not try to write ER_SHUTDOWN error message to socket, when it is forcefully closed by the shutdown. This will avoid the race condition (attempt to write to closed socket, if connection shuts down by itself). --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 77736607e22..9240622cadf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1791,7 +1791,7 @@ static void close_connections(void) */ THD* save_thd= current_thd; set_current_thd(tmp); - close_connection(tmp,ER_SERVER_SHUTDOWN); + close_connection(tmp); set_current_thd(save_thd); } #endif From f669cecbe30da820b93ebff0d3ed27d578627e47 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 31 Jan 2019 02:20:51 +0530 Subject: [PATCH 18/22] MDEV-18415 mariabackup.mdev-14447 test case fails with Table 'test.t' doesn't exist in engine - Added retry logic if validation of first page fails with checksum mismatch. --- extra/mariabackup/xtrabackup.cc | 15 +++++++++++---- .../suite/mariabackup/mdev-14447.result | 1 + mysql-test/suite/mariabackup/mdev-14447.test | 14 ++++++++++++-- storage/innobase/buf/buf0buf.cc | 10 ++++++++++ storage/innobase/include/fsp0file.h | 19 +++++++++++++++++++ 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 87f8822c38b..6ba5d950104 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3092,7 +3092,16 @@ xb_load_single_table_tablespace( die("Can't open datafile %s", name); } - err = file->validate_first_page(&flush_lsn); + for (int i = 0; i < 10; i++) { + err = file->validate_first_page(&flush_lsn); + if (err != DB_CORRUPTION) { + break; + } + + my_sleep(1000); + } + + bool is_empty_file = file->exists() && file->is_empty_file(); if (err == DB_SUCCESS && file->space_id() != SRV_TMP_SPACE_ID) { os_offset_t node_size = os_file_get_size(file->handle()); @@ -3124,9 +3133,7 @@ xb_load_single_table_tablespace( delete file; - if (err != DB_SUCCESS && err != DB_CORRUPTION && xtrabackup_backup) { - /* allow corrupted first page for xtrabackup, it could be just - zero-filled page, which we restore from redo log later */ + if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) { die("Failed to not validate first page of the file %s, error %d",name, (int)err); } } diff --git a/mysql-test/suite/mariabackup/mdev-14447.result b/mysql-test/suite/mariabackup/mdev-14447.result index 3bca7eb5701..6600c13ed74 100644 --- a/mysql-test/suite/mariabackup/mdev-14447.result +++ b/mysql-test/suite/mariabackup/mdev-14447.result @@ -7,6 +7,7 @@ COMMIT; SELECT count(*) FROM t; count(*) 100000 +FOUND 1 /Checksum mismatch in datafile/ in backup.log # Prepare full backup, apply incremental one # Restore and check results # shutdown server diff --git a/mysql-test/suite/mariabackup/mdev-14447.test b/mysql-test/suite/mariabackup/mdev-14447.test index 689b578f2ab..96d12368547 100644 --- a/mysql-test/suite/mariabackup/mdev-14447.test +++ b/mysql-test/suite/mariabackup/mdev-14447.test @@ -1,3 +1,4 @@ +--source include/have_debug.inc call mtr.add_suppression("InnoDB: New log files created"); let $basedir=$MYSQLTEST_VARDIR/tmp/backup; @@ -9,16 +10,26 @@ echo # Create full backup , modify table, then create incremental/differential b --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; --enable_result_log + BEGIN; INSERT INTO t select uuid(), uuid(), uuid(), uuid() from seq_1_to_100000; COMMIT; SELECT count(*) FROM t; -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; + +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,page_intermittent_checksum_mismatch 2> $backuplog; + +--let SEARCH_RANGE = 10000000 +--let SEARCH_PATTERN=Checksum mismatch in datafile +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; --disable_result_log echo # Prepare full backup, apply incremental one; exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir; + exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ; echo # Restore and check results; @@ -36,7 +47,6 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir= echo # restart server; --source include/start_mysqld.inc - --enable_result_log SELECT count(*) FROM t; DROP TABLE t; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 8dc2fd20dbe..e97a36efa56 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1103,6 +1103,16 @@ buf_page_is_corrupted( if (srv_checksum_algorithm == SRV_CHECKSUM_ALGORITHM_CRC32) { + + DBUG_EXECUTE_IF( + "page_intermittent_checksum_mismatch", { + static int page_counter; + if (page_counter++ == 2) { + checksum_field2++; + } + }); + + crc32 = buf_page_check_crc32(read_buf, checksum_field2); crc32_inited = true; diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index 9bc7b4bf9c9..0cb6ccaf86c 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -314,6 +314,25 @@ public: return(m_last_os_error); } + /** Check whether the file is empty. + @return true if file is empty */ + bool is_empty_file() const + { +#ifdef _WIN32 + os_offset_t offset = + (os_offset_t) m_file_info.nFileSizeLow + | ((os_offset_t) m_file_info.nFileSizeHigh << 32); + + return (offset == 0); +#else + return (m_file_info.st_size == 0); +#endif + } + + /** Check if the file exist. + @return true if file exists. */ + bool exists() const { return m_exists; } + /** Test if the filepath provided looks the same as this filepath by string comparison. If they are two different paths to the same file, same_as() will be used to show that after the files are opened. From a2641b26111116adabe1e1c06b768d8c3e06e129 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 29 Jan 2019 13:15:59 +0100 Subject: [PATCH 19/22] MDEV-18380 : adjust max_statement_time in mariabackup --- extra/mariabackup/backup_mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 8936b577a9e..a691cb664f1 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -152,7 +152,7 @@ xb_mysql_connect() return(NULL); } - xb_mysql_query(connection, "SET SESSION wait_timeout=2147483", + xb_mysql_query(connection, "SET SESSION wait_timeout=2147483, max_statement_time=0", false, true); return(connection); From 7c7161a1bd150e61f530933f096a8035932071af Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 28 Jan 2019 14:38:39 +0530 Subject: [PATCH 20/22] MDEV-18194 Incremental prepare tries to access page which is out of tablespace bounds Problem: ======= Mariabackup incremental prepare creates new tablespace when it encounter new tablespace. It sets the intial size as FIL_IBD_FILE_INITIAL_SIZE (4). But while applying redo log, it tries to access 5th page and then it leads to out of tablespace error. Fix: === While parsing the redo log record, track FSP_SIZE in recv_spaces for the respective space id. Assign the recv_size for the tablespace when it is loaded. Extend the tablespace depends on recv_size while applying the redo log record. --- .../incremental_ddl_before_backup.result | 32 ++++++++++++ .../incremental_ddl_before_backup.test | 50 +++++++++++++++++++ storage/innobase/fil/fil0fil.cc | 2 +- storage/innobase/log/log0recv.cc | 30 +++++++++-- 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/mariabackup/incremental_ddl_before_backup.result create mode 100644 mysql-test/suite/mariabackup/incremental_ddl_before_backup.test diff --git a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result new file mode 100644 index 00000000000..a6273a20ff5 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.result @@ -0,0 +1,32 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t1(i INT) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; +# Create full backup , modify table, then create incremental/differential backup +create table t4(f1 int not null, f2 int not null)engine=innodb; +insert into t4 values(1, 2), (2, 2), (3, 3), (5, 5), (6, 6), (4, 4), (9, 9); +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +rename table t4 to t7; +select count(*) from t7; +count(*) +7168 +# XTRABACKUP INCREMENTAL +# XTRABACKUP PREPARE +# XTRABACKUP INCREMENTAL PREPARE +# shutdown server +# remove datadir +# xtrabackup move back +# restart server +select count(*) from t7; +count(*) +7168 +drop table t1, t2, t7, t3; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test new file mode 100644 index 00000000000..2136771b97e --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test @@ -0,0 +1,50 @@ +--source include/have_debug.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +let $basedir=$MYSQLTEST_VARDIR/tmp/backup; +let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; + +CREATE TABLE t1(i INT) ENGINE INNODB; +CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; +CREATE TABLE t3(i INT) ENGINE INNODB; + +echo # Create full backup , modify table, then create incremental/differential backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir; +--enable_result_log + +create table t4(f1 int not null, f2 int not null)engine=innodb; +insert into t4 values(1, 2), (2, 2), (3, 3), (5, 5), (6, 6), (4, 4), (9, 9); +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +insert into t4 select * from t4; +rename table t4 to t7; +select count(*) from t7; + +--echo # XTRABACKUP INCREMENTAL +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir; + +--echo # XTRABACKUP PREPARE +exec $XTRABACKUP --apply-log-only --prepare --target-dir=$basedir; + +--echo # XTRABACKUP INCREMENTAL PREPARE +exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir; + +let $targetdir=$basedir; +-- source include/restart_and_restore.inc +--enable_result_log + +select count(*) from t7; +drop table t1, t2, t7, t3; + +# Cleanup +rmdir $basedir; +rmdir $incremental_dir; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 604f43d7639..623aa38be38 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -963,7 +963,7 @@ fil_space_extend_must_retry( we have set the node->being_extended flag. */ mutex_exit(&fil_system->mutex); - ut_ad(size > space->size); + ut_ad(size >= space->size); ulint last_page_no = space->size; const ulint file_start_page_no = last_page_no - node->size; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index f71067fddf2..bcd6254ebd6 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -152,9 +152,13 @@ struct file_name_t { /** Status of the tablespace */ fil_status status; + /** FSP_SIZE of tablespace */ + ulint size; + /** Constructor */ file_name_t(std::string name_, bool deleted) : - name(name_), space(NULL), status(deleted ? DELETED: NORMAL) {} + name(name_), space(NULL), status(deleted ? DELETED: NORMAL), + size(0) {} }; /** Map of dirty tablespaces during recovery */ @@ -326,6 +330,11 @@ fil_name_process( ut_ad(space != NULL); if (f.space == NULL || f.space == space) { + + if (f.size && f.space == NULL) { + fil_space_set_recv_size(space->id, f.size); + } + f.name = fname.name; f.space = space; f.status = file_name_t::NORMAL; @@ -2394,11 +2403,24 @@ recv_parse_log_rec( } if (*page_no == 0 && *type == MLOG_4BYTES + && apply && mach_read_from_2(old_ptr) == FSP_HEADER_OFFSET + FSP_SIZE) { old_ptr += 2; - fil_space_set_recv_size(*space, - mach_parse_compressed(&old_ptr, - end_ptr)); + + ulint size = mach_parse_compressed(&old_ptr, end_ptr); + + recv_spaces_t::iterator it = recv_spaces.find(*space); + + ut_ad(!recv_sys->mlog_checkpoint_lsn + || *space == TRX_SYS_SPACE + || srv_is_undo_tablespace(*space) + || it != recv_spaces.end()); + + if (it != recv_spaces.end() && !it->second.space) { + it->second.size = size; + } + + fil_space_set_recv_size(*space, size); } return(new_ptr - ptr); From 09cea8703f3ec4e4f9e23855a339c9e3d5e84d3b Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 1 Feb 2019 17:10:27 +0400 Subject: [PATCH 21/22] MDEV-17148 DROP DATABASE throw "Directory not empty" after changed lower_case_table_names. No need to lowercase table names on case-sensitive file systems, as the cache won't contain the 'lowercased' table anyway. And it prevents the UPPERCASE.frm from being deleted. --- mysql-test/r/lowercase_table.result | 4 ++++ mysql-test/t/lowercase_table.test | 12 ++++++++++++ sql/sql_db.cc | 8 ++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index ac7d3e6bf7b..823ffa7696f 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -127,3 +127,7 @@ Database (mysql_TE%) mysql_test drop database mysql_TEST; End of 10.0 tests +create database db1; +create table t1 (a int); +drop database db1; +drop table t1; diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index c339105aae4..e0dcb6c36dd 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -118,3 +118,15 @@ show databases like "mysql_TE%"; drop database mysql_TEST; --echo End of 10.0 tests + +# +# MDEV-17148 DROP DATABASE throw "Directory not empty" after changed lower_case_table_names. +# + +let $datadir=`select @@datadir`; +create database db1; +create table t1 (a int); +copy_file $datadir/test/t1.frm $datadir/db1/T1.frm; +drop database db1; +drop table t1; + diff --git a/sql/sql_db.cc b/sql/sql_db.cc index e94303f7e62..0e554e29380 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1107,8 +1107,12 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, table_list->table_name_length= table->length; table_list->open_type= OT_BASE_ONLY; - /* To be able to correctly look up the table in the table cache. */ - if (lower_case_table_names) + /* + On the case-insensitive file systems table is opened + with the lowercased file name. So we should lowercase + as well to look up the cache properly. + */ + if (lower_case_file_system) table_list->table_name_length= my_casedn_str(files_charset_info, table_list->table_name); From e214aa1cd35d282c27c1888bcd6cf943340c67ff Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 2 Feb 2019 10:02:03 +0100 Subject: [PATCH 22/22] MDEV-18281 COM_RESET_CONNECTION changes the connection encoding Store original charset during client authentication, and restore it for COM_RESET_CONNECTION --- client/mysqltest.cc | 9 ++++++++- mysql-test/main/reset_connection.result | 20 ++++++++++++++++++++ mysql-test/main/reset_connection.test | 15 +++++++++++++++ sql/sql_class.cc | 1 + sql/sql_class.h | 3 +++ sql/sql_connect.cc | 1 + sql/sql_parse.cc | 3 +++ 7 files changed, 51 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 47e92eba7f8..0eb8c896ba5 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5966,6 +5966,7 @@ void do_connect(struct st_command *command) int read_timeout= 0; int write_timeout= 0; int connect_timeout= 0; + char *csname=0; struct st_connection* con_slot; static DYNAMIC_STRING ds_connection_name; @@ -6077,6 +6078,11 @@ void do_connect(struct st_command *command) { connect_timeout= atoi(con_options + sizeof("connect_timeout=")-1); } + else if (strncasecmp(con_options, "CHARSET=", + sizeof("CHARSET=") - 1) == 0) + { + csname= strdup(con_options + sizeof("CHARSET=") - 1); + } else die("Illegal option to connect: %.*s", (int) (end - con_options), con_options); @@ -6114,7 +6120,7 @@ void do_connect(struct st_command *command) mysql_options(con_slot->mysql, MYSQL_OPT_COMPRESS, NullS); mysql_options(con_slot->mysql, MYSQL_OPT_LOCAL_INFILE, 0); mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_NAME, - charset_info->csname); + csname?csname: charset_info->csname); if (opt_charsets_dir) mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_DIR, opt_charsets_dir); @@ -6225,6 +6231,7 @@ void do_connect(struct st_command *command) #ifdef HAVE_SMEM dynstr_free(&ds_shm); #endif + free(csname); DBUG_VOID_RETURN; } diff --git a/mysql-test/main/reset_connection.result b/mysql-test/main/reset_connection.result index 925195f704e..54f6ffdbd25 100644 --- a/mysql-test/main/reset_connection.result +++ b/mysql-test/main/reset_connection.result @@ -5,3 +5,23 @@ Com_select 10 SHOW local STATUS LIKE 'com_select'; Variable_name Value Com_select 0 +# Test if charset changes after reset (utf8) +connect utf8_conn,localhost,root,,,,,CHARSET=utf8; +connection utf8_conn; +SELECT IF(@@character_set_client='utf8','OK', 'FAIL') AS RESULT; +RESULT +OK +SELECT IF(@@character_set_client='utf8','OK', 'FAIL') AS RESULT; +RESULT +OK +disconnect utf8_conn; +# Test if charset changes after reset (latin1) +connect latin1_conn,localhost,root,,,,,CHARSET=latin1; +connection latin1_conn; +SELECT IF(@@character_set_client='latin1','OK', 'FAIL') AS RESULT; +RESULT +OK +SELECT IF(@@character_set_client='latin1','OK', 'FAIL') AS RESULT; +RESULT +OK +disconnect latin1_conn; diff --git a/mysql-test/main/reset_connection.test b/mysql-test/main/reset_connection.test index 49f41c32fc3..73c8280703c 100644 --- a/mysql-test/main/reset_connection.test +++ b/mysql-test/main/reset_connection.test @@ -23,3 +23,18 @@ SHOW local STATUS LIKE 'com_select'; SHOW local STATUS LIKE 'com_select'; +--echo # Test if charset changes after reset (utf8) +connect(utf8_conn,localhost,root,,,,,CHARSET=utf8); +connection utf8_conn; +SELECT IF(@@character_set_client='utf8','OK', 'FAIL') AS RESULT; +--reset_connection +SELECT IF(@@character_set_client='utf8','OK', 'FAIL') AS RESULT; +disconnect utf8_conn; + +--echo # Test if charset changes after reset (latin1) +connect(latin1_conn,localhost,root,,,,,CHARSET=latin1); +connection latin1_conn; +SELECT IF(@@character_set_client='latin1','OK', 'FAIL') AS RESULT; +--reset_connection +SELECT IF(@@character_set_client='latin1','OK', 'FAIL') AS RESULT; +disconnect latin1_conn; \ No newline at end of file diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2efdf91f6a9..85c29b6b661 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -847,6 +847,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock) prepare_derived_at_open= FALSE; create_tmp_table_for_derived= FALSE; save_prep_leaf_list= FALSE; + org_charset= 0; /* Restore THR_THD */ set_current_thd(old_THR_THD); inc_thread_count(); diff --git a/sql/sql_class.h b/sql/sql_class.h index 1a7eb943193..b1fc89db7f2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2365,6 +2365,9 @@ public: uint dbug_sentry; // watch out for memory corruption #endif struct st_my_thread_var *mysys_var; + + /* Original charset number from the first client packet, or COM_CHANGE_USER*/ + CHARSET_INFO *org_charset; private: /* Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index b48070b9c8f..6881ca5956e 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -796,6 +796,7 @@ bool thd_init_client_charset(THD *thd, uint cs_number) cs->csname); return true; } + thd->org_charset= cs; thd->update_charset(cs,cs,cs); } return false; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 731dd3cba71..73f17c21abe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1715,6 +1715,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->status_var.com_other++; thd->change_user(); thd->clear_error(); // if errors from rollback + /* Restore original charset from client authentication packet.*/ + if(thd->org_charset) + thd->update_charset(thd->org_charset,thd->org_charset,thd->org_charset); my_ok(thd, 0, 0, 0); break; }