summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku <kentokushiba@gmail.com>2019-01-23 18:43:11 +0900
committerKentoku <kentokushiba@gmail.com>2019-01-23 18:43:11 +0900
commitbbe29adb03e6a04b8d64f7598e61c955f0f0769a (patch)
tree0ff17cd7873fd566318cf8f29fb80b91fca05fd0
parentd4144c8e010b61a440d422d0f1ca5b066532d173 (diff)
downloadmariadb-git-10.3-spider.tar.gz
Merging the latest Spider10.3-spider
-rwxr-xr-xscripts/wsrep_sst_xtrabackup692
-rwxr-xr-xscripts/wsrep_sst_xtrabackup-v21260
-rwxr-xr-xstorage/rocksdb/myrocks_hotbackup686
-rw-r--r--storage/spider/ha_spider.cc193
-rw-r--r--storage/spider/ha_spider.h92
-rw-r--r--storage/spider/hs_client/hs_compat.h2
-rw-r--r--storage/spider/hs_client/hstcpcli.cpp25
-rw-r--r--storage/spider/hs_client/hstcpcli.hpp3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_deinit.inc14
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc29
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_deinit.inc19
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc51
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_deinit.inc19
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc51
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_deinit.inc19
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc51
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_deinit.inc19
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc51
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_deinit.inc15
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc35
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my.cnf2
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_1_1.cnf44
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_2_1.cnf56
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_2_2.cnf38
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_2_3.cnf8
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_3_1.cnf11
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_3_2.cnf9
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_3_3.cnf9
-rw-r--r--storage/spider/mysql-test/spider/bugfix/my_4_1.cnf9
-rw-r--r--storage/spider/mysql-test/spider/bugfix/suite.opt1
-rw-r--r--storage/spider/mysql-test/spider/bugfix/suite.pm12
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.cnf3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test72
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test156
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test156
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test156
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test157
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.cnf4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test95
-rw-r--r--storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_deinit.inc16
-rw-r--r--storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc33
-rw-r--r--storage/spider/mysql-test/spider/include/direct_join_using_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_join_using_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_join_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_join_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_join_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_join_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_deinit.inc9
-rw-r--r--storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc13
-rw-r--r--storage/spider/mysql-test/spider/include/init_spider.inc42
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_0_deinit.inc21
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_0_init.inc55
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_1_deinit.inc21
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_1_init.inc55
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_2_deinit.inc21
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_2_init.inc55
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_3_deinit.inc21
-rw-r--r--storage/spider/mysql-test/spider/include/quick_mode_3_init.inc55
-rw-r--r--storage/spider/mysql-test/spider/include/slave_trx_isolation_deinit.inc17
-rw-r--r--storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc39
-rw-r--r--storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test126
-rw-r--r--storage/spider/mysql-test/spider/t/direct_join_using.test197
-rw-r--r--storage/spider/mysql-test/spider/t/direct_left_join.test197
-rw-r--r--storage/spider/mysql-test/spider/t/direct_left_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/direct_right_join.test197
-rw-r--r--storage/spider/mysql-test/spider/t/direct_right_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test212
-rw-r--r--storage/spider/mysql-test/spider/t/quick_mode_0.test294
-rw-r--r--storage/spider/mysql-test/spider/t/quick_mode_1.test294
-rw-r--r--storage/spider/mysql-test/spider/t/quick_mode_2.test294
-rw-r--r--storage/spider/mysql-test/spider/t/quick_mode_3.test294
-rw-r--r--storage/spider/mysql-test/spider/t/show_system_tables.test26
-rw-r--r--storage/spider/mysql-test/spider/t/slave_trx_isolation.test148
-rw-r--r--storage/spider/scripts/install_spider.sql88
-rw-r--r--storage/spider/spd_conn.cc10
-rw-r--r--storage/spider/spd_conn.h4
-rw-r--r--storage/spider/spd_copy_tables.cc45
-rw-r--r--storage/spider/spd_db_conn.cc508
-rw-r--r--storage/spider/spd_db_conn.h27
-rw-r--r--storage/spider/spd_db_handlersocket.cc125
-rw-r--r--storage/spider/spd_db_handlersocket.h9
-rw-r--r--storage/spider/spd_db_include.h12
-rw-r--r--storage/spider/spd_db_mysql.cc939
-rw-r--r--storage/spider/spd_db_mysql.h45
-rw-r--r--storage/spider/spd_db_oracle.cc301
-rw-r--r--storage/spider/spd_db_oracle.h11
-rw-r--r--storage/spider/spd_direct_sql.cc79
-rw-r--r--storage/spider/spd_environ.h15
-rw-r--r--storage/spider/spd_group_by_handler.cc67
-rw-r--r--storage/spider/spd_i_s.cc4
-rw-r--r--storage/spider/spd_include.h86
-rw-r--r--storage/spider/spd_param.cc81
-rw-r--r--storage/spider/spd_param.h10
-rw-r--r--storage/spider/spd_ping_table.cc2
-rw-r--r--storage/spider/spd_sys_table.cc169
-rw-r--r--storage/spider/spd_sys_table.h33
-rw-r--r--storage/spider/spd_table.cc53
-rw-r--r--storage/spider/spd_trx.cc38
115 files changed, 10350 insertions, 739 deletions
diff --git a/scripts/wsrep_sst_xtrabackup b/scripts/wsrep_sst_xtrabackup
new file mode 100755
index 00000000000..41ed4485de5
--- /dev/null
+++ b/scripts/wsrep_sst_xtrabackup
@@ -0,0 +1,692 @@
+#!/bin/bash -ue
+# Copyright (C) 2013 Percona Inc
+#
+# 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; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
+# MA 02110-1301 USA.
+
+# Optional dependencies and options documented here: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+# Make sure to read that before proceeding!
+
+
+
+
+. $(dirname $0)/wsrep_sst_common
+
+ealgo=""
+ekey=""
+ekeyfile=""
+encrypt=0
+nproc=1
+ecode=0
+XTRABACKUP_PID=""
+tcert=""
+tpem=""
+sockopt=""
+progress=""
+ttime=0
+totime=0
+lsn="${WSREP_SST_OPT_LSN}"
+incremental=0
+ecmd=""
+rlimit=""
+
+sfmt="tar"
+strmcmd=""
+tfmt=""
+tcmd=""
+rebuild=0
+rebuildcmd=""
+payload=0
+pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
+pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
+uextra=0
+
+if pv --help 2>/dev/null | grep -q FORMAT;then
+ pvopts+=$pvformat
+fi
+pcmd="pv $pvopts"
+declare -a RC
+
+INNOBACKUPEX_BIN=innobackupex
+DATA="${WSREP_SST_OPT_DATA}"
+INFO_FILE="xtrabackup_galera_info"
+IST_FILE="xtrabackup_ist"
+MAGIC_FILE="${DATA}/${INFO_FILE}"
+
+# Setting the path for ss and ip
+export PATH="/usr/sbin:/sbin:$PATH"
+
+timeit(){
+ local stage=$1
+ shift
+ local cmd="$@"
+ local x1 x2 took extcode
+
+ if [[ $ttime -eq 1 ]];then
+ x1=$(date +%s)
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ x2=$(date +%s)
+ took=$(( x2-x1 ))
+ wsrep_log_info "NOTE: $stage took $took seconds"
+ totime=$(( totime+took ))
+ else
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ fi
+ return $extcode
+}
+
+get_keys()
+{
+ if [[ $encrypt -eq 2 ]];then
+ return
+ fi
+
+ if [[ $encrypt -eq 0 ]];then
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
+ wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
+ fi
+ return
+ fi
+
+ if [[ $sfmt == 'tar' ]];then
+ wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
+ encrypt=0
+ return
+ fi
+
+ wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
+
+ if [[ -z $ealgo ]];then
+ wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
+ exit 3
+ fi
+
+ if [[ -z $ekey && ! -r $ekeyfile ]];then
+ wsrep_log_error "FATAL: Either key or keyfile must be readable"
+ exit 3
+ fi
+
+ if [[ -z $ekey ]];then
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
+ else
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ ecmd+=" -d"
+ fi
+}
+
+get_transfer()
+{
+ TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
+
+ if [[ $tfmt == 'nc' ]];then
+ wsrep_check_programs nc
+ wsrep_log_info "Using netcat as streamer"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc -l ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc -dl ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -l -p ${TSST_PORT}"
+ fi
+ else
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}"
+ fi
+ fi
+ else
+ tfmt='socat'
+ wsrep_check_programs socat
+ wsrep_log_info "Using socat as streamer"
+
+ if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then
+ wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer"
+ encrypt=0
+ fi
+
+ if [[ $encrypt -eq 2 ]];then
+ wsrep_log_info "Using openssl based encryption with socat"
+ if [[ -z $tpem || -z $tcert ]];then
+ wsrep_log_error "Both PEM and CRT files required"
+ exit 22
+ fi
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with PEM $tpem, CA: $tcert"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=$tpem,cafile=${tcert}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}"
+ fi
+ else
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
+ else
+ tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
+ fi
+ fi
+ fi
+
+}
+
+get_footprint()
+{
+ pushd $WSREP_SST_OPT_DATA 1>/dev/null
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
+ # QuickLZ has around 50% compression ratio
+ # When compression/compaction used, the progress is only an approximate.
+ payload=$(( payload*1/2 ))
+ fi
+ popd 1>/dev/null
+ pcmd+=" -s $payload"
+ adjust_progress
+}
+
+adjust_progress()
+{
+ if [[ -n $progress && $progress != '1' ]];then
+ if [[ -e $progress ]];then
+ pcmd+=" 2>>$progress"
+ else
+ pcmd+=" 2>$progress"
+ fi
+ elif [[ -z $progress && -n $rlimit ]];then
+ # When rlimit is non-zero
+ pcmd="pv -q"
+ fi
+
+ if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ wsrep_log_info "Rate-limiting SST to $rlimit"
+ pcmd+=" -L \$rlimit"
+ fi
+}
+
+read_cnf()
+{
+ sfmt=$(parse_cnf sst streamfmt "tar")
+ tfmt=$(parse_cnf sst transferfmt "socat")
+ tcert=$(parse_cnf sst tca "")
+ tpem=$(parse_cnf sst tcert "")
+ encrypt=$(parse_cnf sst encrypt 0)
+ sockopt=$(parse_cnf sst sockopt "")
+ progress=$(parse_cnf sst progress "")
+ rebuild=$(parse_cnf sst rebuild 0)
+ ttime=$(parse_cnf sst time 0)
+ incremental=$(parse_cnf sst incremental 0)
+ ealgo=$(parse_cnf xtrabackup encrypt "")
+ ekey=$(parse_cnf xtrabackup encrypt-key "")
+ ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
+
+ # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+ if [[ -z $ealgo ]];then
+ ealgo=$(parse_cnf sst encrypt-algo "")
+ ekey=$(parse_cnf sst encrypt-key "")
+ ekeyfile=$(parse_cnf sst encrypt-key-file "")
+ fi
+ rlimit=$(parse_cnf sst rlimit "")
+ uextra=$(parse_cnf sst use_extra 0)
+}
+
+get_stream()
+{
+ if [[ $sfmt == 'xbstream' ]];then
+ wsrep_log_info "Streaming with xbstream"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="xbstream -x"
+ else
+ strmcmd="xbstream -c \${INFO_FILE} \${IST_FILE}"
+ fi
+ else
+ sfmt="tar"
+ wsrep_log_info "Streaming with tar"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="tar xfi - --recursive-unlink -h"
+ else
+ strmcmd="tar cf - \${INFO_FILE} \${IST_FILE}"
+ fi
+
+ fi
+}
+
+get_proc()
+{
+ set +e
+ nproc=$(grep -c processor /proc/cpuinfo)
+ [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
+ set -e
+}
+
+sig_joiner_cleanup()
+{
+ wsrep_log_error "Removing $MAGIC_FILE file due to signal"
+ rm -f "$MAGIC_FILE"
+}
+
+cleanup_joiner()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+ if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_log_info "Removing the sst_in_progress file"
+ wsrep_cleanup_progress_file
+ fi
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+}
+
+check_pid()
+{
+ local pid_file="$1"
+ [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
+}
+
+cleanup_donor()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+
+ if [[ -n $XTRABACKUP_PID ]];then
+ if check_pid $XTRABACKUP_PID
+ then
+ wsrep_log_error "xtrabackup process is still running. Killing... "
+ kill_xtrabackup
+ fi
+
+ rm -f $XTRABACKUP_PID
+ fi
+ rm -f ${DATA}/${IST_FILE}
+
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+}
+
+kill_xtrabackup()
+{
+ local PID=$(cat $XTRABACKUP_PID)
+ [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
+ rm -f "$XTRABACKUP_PID"
+}
+
+# waits ~10 seconds for nc to open the port and then reports ready
+# (regardless of timeout)
+wait_for_listen()
+{
+ local PORT=$1
+ local ADDR=$2
+ local MODULE=$3
+ for i in {1..50}
+ do
+ ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
+ sleep 0.2
+ done
+ if [[ $incremental -eq 1 ]];then
+ echo "ready ${ADDR}/${MODULE}/$lsn"
+ else
+ echo "ready ${ADDR}/${MODULE}"
+ fi
+}
+
+check_extra()
+{
+ local use_socket=1
+ if [[ $uextra -eq 1 ]];then
+ if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
+ local eport=$(parse_cnf --mysqld extra-port)
+ if [[ -n $eport ]];then
+ # Xtrabackup works only locally.
+ # Hence, setting host to 127.0.0.1 unconditionally.
+ wsrep_log_info "SST through extra_port $eport"
+ INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
+ use_socket=0
+ else
+ wsrep_log_error "Extra port $eport null, failing"
+ exit 1
+ fi
+ else
+ wsrep_log_info "Thread pool not set, ignore the option use_extra"
+ fi
+ fi
+ if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
+ INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
+ fi
+}
+
+wsrep_check_programs "innobackupex"
+
+rm -f "${MAGIC_FILE}"
+
+if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
+ wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
+ exit 22
+fi
+
+read_cnf
+get_stream
+get_transfer
+
+INNOEXTRA=""
+INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \$INNOEXTRA --galera-info --stream=\$sfmt \${TMPDIR} 2>\${DATA}/innobackup.backup.log"
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+ trap cleanup_donor EXIT
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+ usrst=0
+ TMPDIR="${TMPDIR:-/tmp}"
+
+ if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ usrst=1
+ fi
+
+ if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
+ INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ elif [[ $usrst -eq 1 ]];then
+ # Empty password, used for testing, debugging etc.
+ INNOEXTRA+=" --password="
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $ekey ]];then
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
+ else
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
+ fi
+ fi
+
+ if [[ -n $lsn ]];then
+ INNOEXTRA+=" --incremental --incremental-lsn=$lsn "
+ fi
+
+ check_extra
+
+ wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT}"
+
+ if [[ -n $progress ]];then
+ get_footprint
+ tcmd="$pcmd | $tcmd"
+ elif [[ -n $rlimit ]];then
+ adjust_progress
+ tcmd="$pcmd | $tcmd"
+ fi
+
+ set +e
+ timeit "Donor-Transfer" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+
+ if [ ${RC[0]} -ne 0 ]; then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
+ "Check ${DATA}/innobackup.backup.log"
+ exit 22
+ elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "$tcmd finished with error: ${RC[1]}"
+ exit 22
+ fi
+
+ # innobackupex implicitly writes PID to fixed location in ${TMPDIR}
+ XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid"
+
+ else # BYPASS FOR IST
+
+ wsrep_log_info "Bypassing the SST for IST"
+ echo "continue" # now server can resume updating data
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space)
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+ echo "1" > "${DATA}/${IST_FILE}"
+ get_keys
+ pushd ${DATA} 1>/dev/null
+ set +e
+ if [[ $encrypt -eq 1 ]];then
+ tcmd=" $ecmd | $tcmd"
+ fi
+ timeit "Donor-IST-Unencrypted-transfer" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+ popd 1>/dev/null
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while streaming data to joiner node: " \
+ "exit codes: ${RC[@]}"
+ exit 1
+ fi
+ done
+ fi
+
+ echo "done ${WSREP_SST_OPT_GTID}"
+ wsrep_log_info "Total time on donor: $totime seconds"
+
+elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
+then
+ [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ touch $SST_PROGRESS_FILE
+
+ if [[ ! -e ${DATA}/ibdata1 ]];then
+ incremental=0
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ wsrep_log_info "Incremental SST enabled"
+ #lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
+ lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
+ wsrep_log_info "Recovered LSN: $lsn"
+ fi
+
+ sencrypted=1
+ nthreads=1
+
+ MODULE="xtrabackup_sst"
+
+ # May need xtrabackup_checkpoints later on
+ rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
+
+ ADDR="${WSREP_SST_OPT_HOST}:${WSREP_SST_OPT_PORT:-4444}"
+
+ wait_for_listen ${WSREP_SST_OPT_PORT:-4444} ${ADDR} ${MODULE} &
+
+ trap sig_joiner_cleanup HUP PIPE INT TERM
+ trap cleanup_joiner EXIT
+
+ if [[ -n $progress ]];then
+ adjust_progress
+ tcmd+=" | $pcmd"
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ BDATA=$DATA
+ DATA=$(mktemp -d)
+ MAGIC_FILE="${DATA}/${INFO_FILE}"
+ fi
+
+ get_keys
+ set +e
+ if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
+ strmcmd=" $ecmd | $strmcmd"
+ fi
+
+ pushd ${DATA} 1>/dev/null
+ timeit "Joiner-Recv-Unencrypted" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ popd 1>/dev/null
+
+ set -e
+
+ if [[ $sfmt == 'xbstream' ]];then
+ # Special handling till lp:1193240 is fixed"
+ if [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "Xbstream failed"
+ wsrep_log_error "Data directory ${DATA} may not be empty: lp:1193240" \
+ "Manual intervention required in that case"
+ exit 32
+ fi
+ fi
+
+ wait %% # join for wait_for_listen thread
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+ if [ ! -r "${MAGIC_FILE}" ]
+ then
+ # this message should cause joiner to abort
+ wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
+ wsrep_log_info "Contents of datadir"
+ wsrep_log_info "$(ls -l ${DATA}/**/*)"
+ exit 32
+ fi
+
+ if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
+ then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ exit 32
+ fi
+
+ if [ ! -r "${DATA}/${IST_FILE}" ]
+ then
+ wsrep_log_info "Proceeding with SST"
+ wsrep_log_info "Removing existing ib_logfile files"
+ if [[ $incremental -ne 1 ]];then
+ rm -f ${DATA}/ib_logfile*
+ else
+ rm -f ${BDATA}/ib_logfile*
+ fi
+
+ get_proc
+
+ # Rebuild indexes for compact backups
+ if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
+ wsrep_log_info "Index compaction detected"
+ rebuild=1
+ fi
+
+ if [[ $rebuild -eq 1 ]];then
+ nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
+ wsrep_log_info "Rebuilding during prepare with $nthreads threads"
+ rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
+ fi
+
+ if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
+
+ wsrep_log_info "Compressed qpress files found"
+
+ if ! command -v qpress >/dev/null;then
+ wsrep_log_error "qpress not found in path: $PATH"
+ exit 22
+ fi
+
+ if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
+ count=$(find ${DATA} -type f -name '*.qp' | wc -l)
+ count=$(( count*2 ))
+ if pv --help | grep -q FORMAT;then
+ pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
+ else
+ pvopts="-f -s $count -l -N Decompression"
+ fi
+ pcmd="pv $pvopts"
+ adjust_progress
+ dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
+ else
+ dcmd="xargs -n 2 qpress -T${nproc}d"
+ fi
+
+ wsrep_log_info "Removing existing ibdata1 file"
+ rm -f ${DATA}/ibdata1
+
+ # Decompress the qpress files
+ wsrep_log_info "Decompression with $nproc threads"
+ timeit "Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ extcode=$?
+
+ if [[ $extcode -eq 0 ]];then
+ wsrep_log_info "Removing qpress files after decompression"
+ find ${DATA} -type f -name '*.qp' -delete
+ if [[ $? -ne 0 ]];then
+ wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ fi
+ else
+ wsrep_log_error "Decompression failed. Exit code: $extcode"
+ exit 22
+ fi
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
+ INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \
+ --ibbackup=xtrabackup_55 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
+ fi
+
+ wsrep_log_info "Preparing the backup at ${DATA}"
+ timeit "Xtrabackup prepare stage" "$INNOAPPLY"
+
+ if [[ $incremental -eq 1 ]];then
+ wsrep_log_info "Cleaning up ${DATA} after incremental SST"
+ [[ -d ${DATA} ]] && rm -rf ${DATA}
+ DATA=$BDATA
+ fi
+
+ if [ $? -ne 0 ];
+ then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with errors. Check ${DATA}/innobackup.prepare.log"
+ exit 22
+ fi
+ else
+ wsrep_log_info "${IST_FILE} received from donor: Running IST"
+ fi
+
+ if [[ ! -r ${MAGIC_FILE} ]];then
+ wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
+ exit 2
+ fi
+
+ cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
+ wsrep_log_info "Total time on joiner: $totime seconds"
+fi
+
+exit 0
diff --git a/scripts/wsrep_sst_xtrabackup-v2 b/scripts/wsrep_sst_xtrabackup-v2
new file mode 100755
index 00000000000..2de384806b2
--- /dev/null
+++ b/scripts/wsrep_sst_xtrabackup-v2
@@ -0,0 +1,1260 @@
+#!/bin/bash -ue
+# Copyright (C) 2013 Percona Inc
+#
+# 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; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
+# MA 02110-1301 USA.
+
+# Documentation: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+# Make sure to read that before proceeding!
+
+
+
+
+. $(dirname $0)/wsrep_sst_common
+
+ealgo=""
+ekey=""
+ekeyfile=""
+encrypt=0
+nproc=1
+ecode=0
+ssyslog=""
+ssystag=""
+XTRABACKUP_PID=""
+tca=""
+tcert=""
+tkey=""
+sockopt=""
+progress=""
+ttime=0
+totime=0
+ecmd=""
+rlimit=""
+# Initially
+stagemsg="${WSREP_SST_OPT_ROLE}"
+cpat=""
+ib_home_dir=""
+ib_log_dir=""
+ib_undo_dir=""
+
+sfmt="tar"
+strmcmd=""
+tfmt=""
+tcmd=""
+rebuild=0
+rebuildcmd=""
+payload=0
+pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
+pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
+STATDIR=""
+uextra=0
+disver=""
+
+tmpopts=""
+itmpdir=""
+xtmpdir=""
+
+scomp=""
+sdecomp=""
+ssl_dhparams=""
+
+ssl_cert=""
+ssl_ca=""
+ssl_key=""
+
+if pv --help 2>/dev/null | grep -q FORMAT;then
+ pvopts+=$pvformat
+fi
+pcmd="pv $pvopts"
+declare -a RC
+
+INNOBACKUPEX_BIN=innobackupex
+DATA="${WSREP_SST_OPT_DATA}"
+INFO_FILE="xtrabackup_galera_info"
+IST_FILE="xtrabackup_ist"
+MAGIC_FILE="${DATA}/${INFO_FILE}"
+
+# Setting the path for ss and ip
+export PATH="/usr/sbin:/sbin:$PATH"
+
+OS=$(uname)
+
+if ! which lsof > /dev/null; then
+ wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
+ exit 2 # ENOENT
+fi
+
+timeit(){
+ local stage=$1
+ shift
+ local cmd="$@"
+ local x1 x2 took extcode
+
+ if [[ $ttime -eq 1 ]];then
+ x1=$(date +%s)
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ x2=$(date +%s)
+ took=$(( x2-x1 ))
+ wsrep_log_info "NOTE: $stage took $took seconds"
+ totime=$(( totime+took ))
+ else
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ fi
+ return $extcode
+}
+
+get_keys()
+{
+ # $encrypt -eq 1 is for internal purposes only
+ if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
+ return
+ fi
+
+ if [[ $encrypt -eq 0 ]];then
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
+ wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
+ fi
+ return
+ fi
+
+ if [[ $sfmt == 'tar' ]];then
+ wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
+ encrypt=-1
+ return
+ fi
+
+ wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
+
+ if [[ -z $ealgo ]];then
+ wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
+ exit 3
+ fi
+
+ if [[ -z $ekey && ! -r $ekeyfile ]];then
+ wsrep_log_error "FATAL: Either key or keyfile must be readable"
+ exit 3
+ fi
+
+ if [[ -z $ekey ]];then
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
+ else
+ wsrep_log_warning "Using the 'encrypt-key' option causes the encryption key"
+ wsrep_log_warning "to be set via the command-line and is considered insecure."
+ wsrep_log_warning "It is recommended to use the 'encrypt-key-file' option instead."
+
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ ecmd+=" -d"
+ fi
+
+ stagemsg+="-XB-Encrypted"
+}
+
+#
+# If the ssl_dhparams variable is already set, uses that as a source
+# of dh parameters for OpenSSL. Otherwise, looks for dhparams.pem in the
+# datadir, and creates it there if it can't find the file.
+# No input parameters
+#
+check_for_dhparams()
+{
+ if [[ -z "$ssl_dhparams" ]]; then
+ if ! [[ -r "$DATA/dhparams.pem" ]]; then
+ wsrep_check_programs openssl
+ wsrep_log_info "Could not find dhparams file, creating $DATA/dhparams.pem"
+
+ if ! openssl dhparam -out "$DATA/dhparams.pem" 2048 >/dev/null 2>&1
+ then
+ wsrep_log_error "******** FATAL ERROR ********************************* "
+ wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. "
+ wsrep_log_error "****************************************************** "
+ exit 22
+ fi
+ fi
+ ssl_dhparams="$DATA/dhparams.pem"
+ fi
+}
+
+#
+# verifies that the certificate matches the private key
+# doing this will save us having to wait for a timeout that would
+# otherwise occur.
+#
+# 1st param: path to the cert
+# 2nd param: path to the private key
+#
+verify_cert_matches_key()
+{
+ local cert_path=$1
+ local key_path=$2
+
+ wsrep_check_programs openssl diff
+
+ # generate the public key from the cert and the key
+ # they should match (otherwise we can't create an SSL connection)
+ if ! diff <(openssl x509 -in "$cert_path" -pubkey -noout) <(openssl rsa -in "$key_path" -pubout 2>/dev/null) >/dev/null 2>&1
+ then
+ wsrep_log_error "******** FATAL ERROR ************************* "
+ wsrep_log_error "* The certifcate and private key do not match. "
+ wsrep_log_error "* Please check your certificate and key files. "
+ wsrep_log_error "********************************************** "
+ exit 22
+ fi
+}
+
+# Checks to see if the file exists
+# If the file does not exist (or cannot be read), issues an error
+# and exits
+#
+# 1st param: file name to be checked (for read access)
+# 2nd param: 1st error message (header)
+# 3rd param: 2nd error message (footer, optional)
+#
+verify_file_exists()
+{
+ local file_path=$1
+ local error_message1=$2
+ local error_message2=$3
+
+ if ! [[ -r "$file_path" ]]; then
+ wsrep_log_error "******** FATAL ERROR ************************* "
+ wsrep_log_error "* $error_message1 "
+ wsrep_log_error "* Could not find/access : $file_path "
+
+ if ! [[ -z "$error_message2" ]]; then
+ wsrep_log_error "* $error_message2 "
+ fi
+
+ wsrep_log_error "********************************************** "
+ exit 22
+ fi
+}
+
+get_transfer()
+{
+ TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
+
+ if [[ $tfmt == 'nc' ]];then
+ wsrep_check_programs nc
+
+ if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
+ wsrep_log_error "******** FATAL ERROR *********************** "
+ wsrep_log_error "* Using SSL encryption (encrypt= 2, 3, or 4) "
+ wsrep_log_error "* is not supported when using nc(netcat). "
+ wsrep_log_error "******************************************** "
+ exit 22
+ fi
+
+ wsrep_log_info "Using netcat as streamer"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if nc -h 2>&1 | grep -q ncat; then
+ # Ncat
+ tcmd="nc $sockopt -l ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc $sockopt -dl ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc $sockopt -l -p ${TSST_PORT}"
+ fi
+ else
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -q0 ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ fi
+ fi
+ else
+ tfmt='socat'
+ wsrep_log_info "Using socat as streamer"
+ wsrep_check_programs socat
+
+ donor_extra=""
+ joiner_extra=""
+ if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
+ if ! socat -V | grep -q WITH_OPENSSL; then
+ wsrep_log_error "******** FATAL ERROR ****************** "
+ wsrep_log_error "* socat is not openssl enabled. "
+ wsrep_log_error "* Unable to encrypt SST communications. "
+ wsrep_log_error "*************************************** "
+ exit 2
+ fi
+
+ # Determine the socat version
+ SOCAT_VERSION=`socat -V 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
+ if [[ -z "$SOCAT_VERSION" ]]; then
+ wsrep_log_error "******** FATAL ERROR **************** "
+ wsrep_log_error "* Cannot determine the socat version. "
+ wsrep_log_error "************************************* "
+ exit 2
+ fi
+
+ # socat versions < 1.7.3 will have 512-bit dhparams (too small)
+ # so create 2048-bit dhparams and send that as a parameter
+ # socat version >= 1.7.3, checks to see if the peername matches the hostname
+ # set commonname="" to disable the peername checks
+ #
+ if ! check_for_version "$SOCAT_VERSION" "1.7.3"; then
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ # dhparams check (will create ssl_dhparams if needed)
+ check_for_dhparams
+ joiner_extra=",dhparam=$ssl_dhparams"
+ fi
+ fi
+ if check_for_version "$SOCAT_VERSION" "1.7.3"; then
+ donor_extra=',commonname=""'
+ fi
+ fi
+
+ if [[ $encrypt -eq 2 ]]; then
+ wsrep_log_warning "**** WARNING **** encrypt=2 is deprecated and will be removed in a future release"
+ wsrep_log_info "Using openssl based encryption with socat: with crt and ca"
+
+ verify_file_exists "$tcert" "Both certificate and CA files are required." \
+ "Please check the 'tcert' option. "
+ verify_file_exists "$tca" "Both certificate and CA files are required." \
+ "Please check the 'tca' option. "
+
+ stagemsg+="-OpenSSL-Encrypted-2"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with CERT: $tcert, CA: $tca"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},cafile=${tca}${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $tcert, CA: $tca"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},cafile=${tca}${donor_extra}${sockopt}"
+ fi
+ elif [[ $encrypt -eq 3 ]];then
+ wsrep_log_warning "**** WARNING **** encrypt=3 is deprecated and will be removed in a future release"
+ wsrep_log_info "Using openssl based encryption with socat: with key and crt"
+
+ verify_file_exists "$tcert" "Both certificate and key files are required." \
+ "Please check the 'tcert' option. "
+ verify_file_exists "$tkey" "Both certificate and key files are required." \
+ "Please check the 'tkey' option. "
+
+ stagemsg+="-OpenSSL-Encrypted-3"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with CERT: $tcert, KEY: $tkey"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},key=${tkey},verify=0${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $tcert, KEY: $tkey"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},key=${tkey},verify=0${sockopt}"
+ fi
+ elif [[ $encrypt -eq 4 ]]; then
+ wsrep_log_info "Using openssl based encryption with socat: with key, crt, and ca"
+
+ verify_file_exists "$ssl_ca" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-ca' option. "
+ verify_file_exists "$ssl_cert" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-cert' option. "
+ verify_file_exists "$ssl_key" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-key' option. "
+
+ # Check to see that the key matches the cert
+ verify_cert_matches_key $ssl_cert $ssl_key
+
+ stagemsg+="-OpenSSL-Encrypted-4"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ wsrep_log_info "Decrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}"
+ fi
+
+ else
+ if [[ $encrypt -eq 1 ]]; then
+ wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
+ else
+ tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
+ fi
+ fi
+ fi
+}
+
+get_footprint()
+{
+ pushd $WSREP_SST_OPT_DATA 1>/dev/null
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
+ # QuickLZ has around 50% compression ratio
+ # When compression/compaction used, the progress is only an approximate.
+ payload=$(( payload*1/2 ))
+ fi
+ popd 1>/dev/null
+ pcmd+=" -s $payload"
+ adjust_progress
+}
+
+adjust_progress()
+{
+
+ if ! command -v pv >/dev/null;then
+ wsrep_log_error "pv not found in path: $PATH"
+ wsrep_log_error "Disabling all progress/rate-limiting"
+ pcmd=""
+ rlimit=""
+ progress=""
+ return
+ fi
+
+ if [[ -n $progress && $progress != '1' ]];then
+ if [[ -e $progress ]];then
+ pcmd+=" 2>>$progress"
+ else
+ pcmd+=" 2>$progress"
+ fi
+ elif [[ -z $progress && -n $rlimit ]];then
+ # When rlimit is non-zero
+ pcmd="pv -q"
+ fi
+
+ if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ wsrep_log_info "Rate-limiting SST to $rlimit"
+ pcmd+=" -L \$rlimit"
+ fi
+}
+
+read_cnf()
+{
+ sfmt=$(parse_cnf sst streamfmt "xbstream")
+ tfmt=$(parse_cnf sst transferfmt "socat")
+ tca=$(parse_cnf sst tca "")
+ tcert=$(parse_cnf sst tcert "")
+ tkey=$(parse_cnf sst tkey "")
+ encrypt=$(parse_cnf sst encrypt 0)
+ sockopt=$(parse_cnf sst sockopt "")
+ progress=$(parse_cnf sst progress "")
+ rebuild=$(parse_cnf sst rebuild 0)
+ ttime=$(parse_cnf sst time 0)
+ if [ "${OS}" = "FreeBSD" ]; then
+ cpat=$(parse_cnf sst cpat '.*\.pem$|.*init\.ok$|.*galera\.cache$|.*sst_in_progress$|.*\.sst$|.*gvwstate\.dat$|.*grastate\.dat$|.*\.err$|.*\.log$|.*RPM_UPGRADE_MARKER$|.*RPM_UPGRADE_HISTORY$')
+ else
+ cpat=$(parse_cnf sst cpat '.*\.pem$\|.*init\.ok$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
+ fi
+ ealgo=$(parse_cnf xtrabackup encrypt "")
+ ekey=$(parse_cnf xtrabackup encrypt-key "")
+ ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
+ scomp=$(parse_cnf sst compressor "")
+ sdecomp=$(parse_cnf sst decompressor "")
+
+
+ # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+ if [[ -z $ealgo ]];then
+ ealgo=$(parse_cnf sst encrypt-algo "")
+ ekey=$(parse_cnf sst encrypt-key "")
+ ekeyfile=$(parse_cnf sst encrypt-key-file "")
+ fi
+
+ # Pull the parameters needed for encrypt=4
+ ssl_ca=$(parse_cnf sst ssl-ca "")
+ if [[ -z "$ssl_ca" ]]; then
+ ssl_ca=$(parse_cnf --mysqld ssl-ca "")
+ fi
+ ssl_cert=$(parse_cnf sst ssl-cert "")
+ if [[ -z "$ssl_cert" ]]; then
+ ssl_cert=$(parse_cnf --mysqld ssl-cert "")
+ fi
+ ssl_key=$(parse_cnf sst ssl-key "")
+ if [[ -z "$ssl_key" ]]; then
+ ssl_key=$(parse_cnf --mysqld ssl-key "")
+ fi
+
+ rlimit=$(parse_cnf sst rlimit "")
+ uextra=$(parse_cnf sst use-extra 0)
+ iopts=$(parse_cnf sst inno-backup-opts "")
+ iapts=$(parse_cnf sst inno-apply-opts "")
+ impts=$(parse_cnf sst inno-move-opts "")
+ stimeout=$(parse_cnf sst sst-initial-timeout 100)
+ ssyslog=$(parse_cnf sst sst-syslog 0)
+ ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
+ ssystag+="-"
+
+ if [[ $ssyslog -ne -1 ]];then
+ if $MY_PRINT_DEFAULTS mysqld_safe | grep -q -- "--syslog";then
+ ssyslog=1
+ fi
+ fi
+}
+
+get_stream()
+{
+ if [[ $sfmt == 'xbstream' ]];then
+ wsrep_log_info "Streaming with xbstream"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="xbstream -x"
+ else
+ strmcmd="xbstream -c \${INFO_FILE}"
+ fi
+ else
+ sfmt="tar"
+ wsrep_log_info "Streaming with tar"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="tar xfi - "
+ else
+ strmcmd="tar cf - \${INFO_FILE} "
+ fi
+
+ fi
+}
+
+get_proc()
+{
+ set +e
+ nproc=$(grep -c processor /proc/cpuinfo)
+ [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
+ set -e
+}
+
+sig_joiner_cleanup()
+{
+ wsrep_log_error "Removing $MAGIC_FILE file due to signal"
+ rm -f "$MAGIC_FILE"
+}
+
+cleanup_joiner()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_log_info "Removing the sst_in_progress file"
+ wsrep_cleanup_progress_file
+ fi
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+ if [[ -n ${STATDIR:-} ]];then
+ [[ -d $STATDIR ]] && rm -rf $STATDIR
+ fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
+}
+
+check_pid()
+{
+ local pid_file="$1"
+ [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
+}
+
+cleanup_donor()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+
+ if [[ -n ${XTRABACKUP_PID:-} ]];then
+ if check_pid $XTRABACKUP_PID
+ then
+ wsrep_log_error "xtrabackup process is still running. Killing... "
+ kill_xtrabackup
+ fi
+
+ fi
+ rm -f ${DATA}/${IST_FILE} || true
+
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm -f $progress || true
+ fi
+
+ wsrep_log_info "Cleaning up temporary directories"
+
+ if [[ -n $xtmpdir ]];then
+ [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
+ fi
+
+ if [[ -n $itmpdir ]];then
+ [[ -d $itmpdir ]] && rm -rf $itmpdir || true
+ fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
+
+}
+
+kill_xtrabackup()
+{
+ local PID=$(cat $XTRABACKUP_PID)
+ [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
+ wsrep_log_info "Removing xtrabackup pid file $XTRABACKUP_PID"
+ rm -f "$XTRABACKUP_PID" || true
+}
+
+# waits ~1 minute for nc/socat to open the port and then reports ready
+# (regardless of timeout)
+wait_for_listen()
+{
+ local HOST=$1
+ local PORT=$2
+ local MODULE=$3
+ local LSOF_OUT
+
+ for i in {1..300}
+ do
+ LSOF_OUT=$(lsof -sTCP:LISTEN -i TCP:${PORT} -a -c nc -c socat -F c 2> /dev/null || :)
+ [ -n "${LSOF_OUT}" ] && break
+ sleep 0.2
+ done
+
+ echo "ready ${HOST}:${PORT}/${MODULE}//${WSREP_SST_OPT_SST_VER:-1}"
+}
+
+check_extra()
+{
+ local use_socket=1
+ if [[ $uextra -eq 1 ]];then
+ if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
+ local eport=$(parse_cnf --mysqld extra-port)
+ if [[ -n $eport ]];then
+ # Xtrabackup works only locally.
+ # Hence, setting host to 127.0.0.1 unconditionally.
+ wsrep_log_info "SST through extra_port $eport"
+ INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
+ use_socket=0
+ else
+ wsrep_log_error "Extra port $eport null, failing"
+ exit 1
+ fi
+ else
+ wsrep_log_info "Thread pool not set, ignore the option use_extra"
+ fi
+ fi
+ if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
+ INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
+ fi
+}
+
+recv_joiner()
+{
+ local dir=$1
+ local msg=$2
+ local tmt=$3
+ local checkf=$4
+ local ltcmd
+
+ if [[ ! -d ${dir} ]];then
+ # This indicates that IST is in progress
+ return
+ fi
+
+ pushd ${dir} 1>/dev/null
+ set +e
+
+ if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
+ if timeout --help | grep -q -- '-k';then
+ ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
+ else
+ ltcmd="timeout -s9 $tmt $tcmd"
+ fi
+ timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ else
+ timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ fi
+
+ set -e
+ popd 1>/dev/null
+
+ if [[ ${RC[0]} -eq 124 ]];then
+ wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
+ exit 32
+ fi
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+ if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
+ # this message should cause joiner to abort
+ wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
+ wsrep_log_info "Contents of datadir"
+ wsrep_log_info "$(ls -l ${dir}/*)"
+ exit 32
+ fi
+}
+
+
+send_donor()
+{
+ local dir=$1
+ local msg=$2
+
+ pushd ${dir} 1>/dev/null
+ set +e
+ timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+ popd 1>/dev/null
+
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+}
+
+# Returns the version string in a standardized format
+# Input "1.2.3" => echoes "010203"
+# Wrongly formatted values => echoes "000000"
+normalize_version()
+{
+ local major=0
+ local minor=0
+ local patch=0
+
+ # Only parses purely numeric version numbers, 1.2.3
+ # Everything after the first three values are ignored
+ if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then
+ major=${BASH_REMATCH[1]}
+ minor=${BASH_REMATCH[2]}
+ patch=${BASH_REMATCH[3]}
+ fi
+
+ printf %02d%02d%02d $major $minor $patch
+}
+
+# Compares two version strings
+# The first parameter is the version to be checked
+# The second parameter is the minimum version required
+# Returns 1 (failure) if $1 >= $2, 0 (success) otherwise
+check_for_version()
+{
+ local local_version_str="$( normalize_version $1 )"
+ local required_version_str="$( normalize_version $2 )"
+
+ if [[ "$local_version_str" < "$required_version_str" ]]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+monitor_process()
+{
+ local sst_stream_pid=$1
+
+ while true ; do
+
+ if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ kill -- -"${WSREP_SST_OPT_PARENT}"
+ exit 32
+ fi
+
+ if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
+ break
+ fi
+
+ sleep 0.1
+
+ done
+}
+
+
+wsrep_check_programs "$INNOBACKUPEX_BIN"
+
+# check the version, we require XB-2.4 to ensure that we can pass the
+# datadir via the command-line option
+XB_REQUIRED_VERSION="2.3.5"
+
+XB_VERSION=`$INNOBACKUPEX_BIN --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
+if [[ -z $XB_VERSION ]]; then
+ wsrep_log_error "FATAL: Cannot determine the $INNOBACKUPEX_BIN version. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
+ exit 2
+fi
+
+if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then
+ wsrep_log_error "FATAL: The $INNOBACKUPEX_BIN version is $XB_VERSION. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
+ exit 2
+fi
+
+
+rm -f "${MAGIC_FILE}"
+
+if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
+ wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
+ exit 22
+fi
+
+read_cnf
+
+if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
+ disver="--no-version-check"
+fi
+
+if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
+ wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
+ iopts+=" --no-backup-locks "
+fi
+
+
+INNOEXTRA=""
+
+if [[ $ssyslog -eq 1 ]];then
+
+ if ! command -v logger >/dev/null;then
+ wsrep_log_error "logger not in path: $PATH. Ignoring"
+ else
+
+ wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
+
+ exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
+
+ wsrep_log_error()
+ {
+ logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ wsrep_log_info()
+ {
+ logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ INNOAPPLY="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
+ INNOMOVE="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move "
+ INNOBACKUP="2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
+ fi
+
+else
+ INNOAPPLY="&>\${DATA}/innobackup.prepare.log"
+ INNOMOVE="&>\${DATA}/innobackup.move.log"
+ INNOBACKUP="2>\${DATA}/innobackup.backup.log"
+fi
+
+get_stream
+get_transfer
+
+INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
+# Try to set INNODB_DATA_HOME_DIR from the command line:
+if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
+ INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
+fi
+# if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf
+if [ -z "$INNODB_DATA_HOME_DIR" ]; then
+ INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
+fi
+if [ -z "$INNODB_DATA_HOME_DIR" ]; then
+ INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir "")
+fi
+if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then
+ INNOEXTRA+=" --innodb-data-home-dir=$INNODB_DATA_HOME_DIR"
+fi
+
+if [ -n "$INNODB_DATA_HOME_DIR" ]; then
+ # handle both relative and absolute paths
+ INNODB_DATA_HOME_DIR=$(cd $DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P)
+else
+ # default to datadir
+ INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P)
+fi
+
+INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} ${INNOAPPLY}"
+INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} ${INNOMOVE}"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir ${INNOBACKUP}"
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+ trap cleanup_donor EXIT
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+ usrst=0
+ if [[ -z $WSREP_SST_OPT_SST_VER ]];then
+ wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
+ wsrep_log_error "The joiner is not supported for this version of donor"
+ exit 93
+ fi
+
+ if [[ -z $(parse_cnf --mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then
+ xtmpdir=$(mktemp -d)
+ tmpopts=" --tmpdir=$xtmpdir "
+ wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
+ fi
+
+ itmpdir=$(mktemp -d)
+ wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
+
+ if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ usrst=1
+ fi
+
+ if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
+ INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ elif [[ $usrst -eq 1 ]];then
+ # Empty password, used for testing, debugging etc.
+ INNOEXTRA+=" --password="
+ fi
+
+ get_keys
+ check_extra
+
+ wsrep_log_info "Streaming GTID file before SST"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+
+ ttcmd="$tcmd"
+
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" \$ecmd | $scomp | $tcmd "
+ else
+ tcmd=" \$ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+
+ send_donor $DATA "${stagemsg}-gtid"
+
+ # Restore the transport commmand to its original state
+ tcmd="$ttcmd"
+ if [[ -n $progress ]];then
+ get_footprint
+ tcmd="$pcmd | $tcmd"
+ elif [[ -n $rlimit ]];then
+ adjust_progress
+ tcmd="$pcmd | $tcmd"
+ fi
+
+ wsrep_log_info "Sleeping before data transfer for SST"
+ sleep 10
+
+ wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444}"
+
+ # Add compression to the head of the stream (if specified)
+ if [[ -n $scomp ]]; then
+ tcmd="$scomp | $tcmd"
+ fi
+
+ # Add encryption to the head of the stream (if specified)
+ if [[ $encrypt -eq 1 ]]; then
+ tcmd=" \$ecmd | $tcmd "
+ fi
+
+ set +e
+ timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+
+ if [ ${RC[0]} -ne 0 ]; then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
+ "Check ${DATA}/innobackup.backup.log"
+ exit 22
+ elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "$tcmd finished with error: ${RC[1]}"
+ exit 22
+ fi
+
+ # innobackupex implicitly writes PID to fixed location in $xtmpdir
+ XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
+
+
+ else # BYPASS FOR IST
+
+ wsrep_log_info "Bypassing the SST for IST"
+ echo "continue" # now server can resume updating data
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+ echo "1" > "${DATA}/${IST_FILE}"
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" \$ecmd | $scomp | $tcmd "
+ else
+ tcmd=" \$ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+ strmcmd+=" \${IST_FILE}"
+
+ send_donor $DATA "${stagemsg}-IST"
+
+ fi
+
+ echo "done ${WSREP_SST_OPT_GTID}"
+ wsrep_log_info "Total time on donor: $totime seconds"
+
+elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
+then
+ [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
+
+ ib_home_dir=$INNODB_DATA_HOME_DIR
+ ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "")
+ ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "")
+
+ stagemsg="Joiner-Recv"
+
+ sencrypted=1
+ nthreads=1
+
+ MODULE="xtrabackup_sst"
+
+ rm -f "${DATA}/${IST_FILE}"
+
+ # May need xtrabackup_checkpoints later on
+ rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
+
+ wait_for_listen ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444} ${MODULE} &
+
+ trap sig_joiner_cleanup HUP PIPE INT TERM
+ trap cleanup_joiner EXIT
+
+ if [[ -n $progress ]];then
+ adjust_progress
+ tcmd+=" | $pcmd"
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
+ if [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | \$ecmd | $strmcmd"
+ else
+ strmcmd=" \$ecmd | $strmcmd"
+ fi
+ elif [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | $strmcmd"
+ fi
+
+ STATDIR=$(mktemp -d)
+ MAGIC_FILE="${STATDIR}/${INFO_FILE}"
+ recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
+
+
+ if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
+ then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ exit 32
+ fi
+
+ if [ ! -r "${STATDIR}/${IST_FILE}" ]
+ then
+
+ if [[ -d ${DATA}/.sst ]];then
+ wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
+ rm -rf ${DATA}/.sst
+ fi
+ mkdir -p ${DATA}/.sst
+ (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
+ jpid=$!
+ wsrep_log_info "Proceeding with SST"
+
+
+ wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
+ if [ "${OS}" = "FreeBSD" ]; then
+ find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
+ else
+ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
+ fi
+
+ tempdir=$(parse_cnf --mysqld log-bin "")
+ if [[ -n ${tempdir:-} ]];then
+ binlog_dir=$(dirname $tempdir)
+ binlog_file=$(basename $tempdir)
+ if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
+ pattern="$binlog_dir/$binlog_file\.[0-9]+$"
+ wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
+ find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
+ rm $binlog_dir/*.index || true
+ fi
+ fi
+
+
+
+ TDATA=${DATA}
+ DATA="${DATA}/.sst"
+
+
+ MAGIC_FILE="${DATA}/${INFO_FILE}"
+ wsrep_log_info "Waiting for SST streaming to complete!"
+ monitor_process $jpid
+
+ get_proc
+
+ if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
+ wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
+ exit 2
+ fi
+
+ # Rebuild indexes for compact backups
+ if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
+ wsrep_log_info "Index compaction detected"
+ rebuild=1
+ fi
+
+ if [[ $rebuild -eq 1 ]];then
+ nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
+ wsrep_log_info "Rebuilding during prepare with $nthreads threads"
+ rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
+ fi
+
+ if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
+
+ wsrep_log_info "Compressed qpress files found"
+
+ if ! command -v qpress >/dev/null;then
+ wsrep_log_error "qpress not found in path: $PATH"
+ exit 22
+ fi
+
+ if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
+ count=$(find ${DATA} -type f -name '*.qp' | wc -l)
+ count=$(( count*2 ))
+ if pv --help | grep -q FORMAT;then
+ pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
+ else
+ pvopts="-f -s $count -l -N Decompression"
+ fi
+ pcmd="pv $pvopts"
+ adjust_progress
+ dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
+ else
+ dcmd="xargs -n 2 qpress -T${nproc}d"
+ fi
+
+
+ # Decompress the qpress files
+ wsrep_log_info "Decompression with $nproc threads"
+ timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ extcode=$?
+
+ if [[ $extcode -eq 0 ]];then
+ wsrep_log_info "Removing qpress files after decompression"
+ find ${DATA} -type f -name '*.qp' -delete
+ if [[ $? -ne 0 ]];then
+ wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ fi
+ else
+ wsrep_log_error "Decompression failed. Exit code: $extcode"
+ exit 22
+ fi
+ fi
+
+
+ if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
+
+ BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
+ BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
+
+ # To avoid comparing data directory and BINLOG_DIRNAME
+ mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
+
+ pushd $BINLOG_DIRNAME &>/dev/null
+ for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
+ echo ${BINLOG_DIRNAME}/${bfiles} >> ${BINLOG_FILENAME}.index
+ done
+ popd &> /dev/null
+
+ fi
+
+ wsrep_log_info "Preparing the backup at ${DATA}"
+ timeit "Xtrabackup prepare stage" "$INNOAPPLY"
+
+ if [ $? -ne 0 ];
+ then
+ wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log"
+ exit 22
+ fi
+
+ MAGIC_FILE="${TDATA}/${INFO_FILE}"
+ set +e
+ rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
+ set -e
+ wsrep_log_info "Moving the backup to ${TDATA}"
+ timeit "Xtrabackup move stage" "$INNOMOVE"
+ if [[ $? -eq 0 ]];then
+ wsrep_log_info "Move successful, removing ${DATA}"
+ rm -rf $DATA
+ DATA=${TDATA}
+ else
+ wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
+ wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
+ exit 22
+ fi
+
+
+ else
+ wsrep_log_info "${IST_FILE} received from donor: Running IST"
+ fi
+
+ if [[ ! -r ${MAGIC_FILE} ]];then
+ wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
+ exit 2
+ fi
+ wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
+ cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
+ wsrep_log_info "Total time on joiner: $totime seconds"
+fi
+
+exit 0
diff --git a/storage/rocksdb/myrocks_hotbackup b/storage/rocksdb/myrocks_hotbackup
new file mode 100755
index 00000000000..ef1e934f3fd
--- /dev/null
+++ b/storage/rocksdb/myrocks_hotbackup
@@ -0,0 +1,686 @@
+#!/usr/bin/env python
+
+from __future__ import division
+from optparse import OptionParser
+import collections
+import signal
+import os
+import stat
+import sys
+import re
+import commands
+import subprocess
+import logging
+import logging.handlers
+import time
+import datetime
+import shutil
+import traceback
+import tempfile
+
+import MySQLdb
+import MySQLdb.connections
+from MySQLdb import OperationalError, ProgrammingError
+
+logger = None
+opts = None
+rocksdb_files = ['MANIFEST', 'CURRENT', 'OPTIONS']
+rocksdb_data_suffix = '.sst'
+rocksdb_wal_suffix = '.log'
+exclude_files = ['master.info', 'relay-log.info', 'worker-relay-log.info',
+ 'auto.cnf', 'gaplock.log', 'ibdata', 'ib_logfile', '.trash']
+wdt_bin = 'wdt'
+
+def is_manifest(fname):
+ for m in rocksdb_files:
+ if fname.startswith(m):
+ return True
+ return False
+
+class Writer(object):
+ a = None
+ def __init__(self):
+ a = None
+
+class StreamWriter(Writer):
+ stream_cmd= ''
+
+ def __init__(self, stream_option):
+ super(StreamWriter, self).__init__()
+ if stream_option == 'tar':
+ self.stream_cmd= 'tar chf -'
+ elif stream_option == 'xbstream':
+ self.stream_cmd= 'xbstream -c'
+ else:
+ raise Exception("Only tar or xbstream is supported as streaming option.")
+
+ def write(self, file_name):
+ rc= os.system(self.stream_cmd + " " + file_name)
+ if (rc != 0):
+ raise Exception("Got error on stream write: " + str(rc) + " " + file_name)
+
+
+class MiscFilesProcessor():
+ datadir = None
+ wildcard = r'.*\.[frm|MYD|MYI|MAD|MAI|MRG|TRG|TRN|ARM|ARZ|CSM|CSV|opt|par]'
+ regex = None
+ start_backup_time = None
+ skip_check_frm_timestamp = None
+
+ def __init__(self, datadir, skip_check_frm_timestamp, start_backup_time):
+ self.datadir = datadir
+ self.regex = re.compile(self.wildcard)
+ self.skip_check_frm_timestamp = skip_check_frm_timestamp
+ self.start_backup_time = start_backup_time
+
+ def process_db(self, db):
+ # do nothing
+ pass
+
+ def process_file(self, path):
+ # do nothing
+ pass
+
+ def check_frm_timestamp(self, fname, path):
+ if not self.skip_check_frm_timestamp and fname.endswith('.frm'):
+ if os.path.getmtime(path) > self.start_backup_time:
+ logger.error('FRM file %s was updated after starting backups. '
+ 'Schema could have changed and the resulting copy may '
+ 'not be valid. Aborting. '
+ '(backup time: %s, file modifled time: %s)',
+ path, datetime.datetime.fromtimestamp(self.start_backup_time).strftime('%Y-%m-%d %H:%M:%S'),
+ datetime.datetime.fromtimestamp(os.path.getmtime(path)).strftime('%Y-%m-%d %H:%M:%S'))
+ raise Exception("Inconsistent frm file timestamp");
+
+ def process(self):
+ os.chdir(self.datadir)
+ for db in self.get_databases():
+ logger.info("Starting MySQL misc file traversal from database %s..", db)
+ self.process_db(db)
+ for f in self.get_files(db):
+ if self.match(f):
+ rel_path = os.path.join(db, f)
+ self.check_frm_timestamp(f, rel_path)
+ self.process_file(rel_path)
+ logger.info("Traversing misc files from data directory..")
+ for f in self.get_files(""):
+ should_skip = False
+ for e in exclude_files:
+ if f.startswith(e) or f.endswith(e):
+ logger.info("Skipping %s", f)
+ should_skip = True
+ break
+ if not should_skip:
+ self.process_file(f)
+
+ def match(self, filename):
+ if self.regex.match(filename):
+ return True
+ else:
+ return False
+
+ def get_databases(self):
+ dbs = []
+ dirs = [ d for d in os.listdir(self.datadir) \
+ if not os.path.isfile(os.path.join(self.datadir,d))]
+ for db in dirs:
+ if not db.startswith('.') and not self._is_socket(db) and not db == "#rocksdb":
+ dbs.append(db)
+ return dbs
+
+ def get_files(self, db):
+ dbdir = self.datadir + "/" + db
+ return [ f for f in os.listdir(dbdir) \
+ if os.path.isfile(os.path.join(dbdir,f))]
+
+ def _is_socket(self, item):
+ mode = os.stat(os.path.join(self.datadir, item)).st_mode
+ if stat.S_ISSOCK(mode):
+ return True
+ return False
+
+
+class MySQLBackup(MiscFilesProcessor):
+ writer = None
+
+ def __init__(self, datadir, writer, skip_check_frm_timestamp, start_backup_time):
+ MiscFilesProcessor.__init__(self, datadir, skip_check_frm_timestamp, start_backup_time)
+ self.writer = writer
+
+ def process_file(self, fname): # overriding base class
+ self.writer.write(fname)
+
+
+class MiscFilesLinkCreator(MiscFilesProcessor):
+ snapshot_dir = None
+
+ def __init__(self, datadir, snapshot_dir, skip_check_frm_timestamp, start_backup_time):
+ MiscFilesProcessor.__init__(self, datadir, skip_check_frm_timestamp, start_backup_time)
+ self.snapshot_dir = snapshot_dir
+
+ def process_db(self, db):
+ snapshot_sub_dir = os.path.join(self.snapshot_dir, db)
+ os.makedirs(snapshot_sub_dir)
+
+ def process_file(self, path):
+ dst_path = os.path.join(self.snapshot_dir, path)
+ os.link(path, dst_path)
+
+
+# RocksDB backup
+class RocksDBBackup():
+ source_dir = None
+ writer = None
+ # sst files sent in this backup round
+ sent_sst = {}
+ # target sst files in this backup round
+ target_sst = {}
+ # sst files sent in all backup rounds
+ total_sent_sst= {}
+ # sum of sst file size sent in this backup round
+ sent_sst_size = 0
+ # sum of target sst file size in this backup round
+ # if sent_sst_size becomes equal to target_sst_size,
+ # it means the backup round finished backing up all sst files
+ target_sst_size = 0
+ # sum of all sst file size sent all backup rounds
+ total_sent_sst_size= 0
+ # sum of all target sst file size from all backup rounds
+ total_target_sst_size = 0
+ show_progress_size_interval= 1073741824 # 1GB
+ wal_files= []
+ manifest_files= []
+ finished= False
+
+ def __init__(self, source_dir, writer, prev):
+ self.source_dir = source_dir
+ self.writer = writer
+ os.chdir(self.source_dir)
+ self.init_target_files(prev)
+
+ def init_target_files(self, prev):
+ sst = {}
+ self.sent_sst = {}
+ self.target_sst= {}
+ self.total_sent_sst = {}
+ self.sent_sst_size = 0
+ self.target_sst_size = 0
+ self.total_sent_sst_size= 0
+ self.total_target_sst_size= 0
+ self.wal_files= []
+ self.manifest_files= []
+
+ for f in os.listdir(self.source_dir):
+ if f.endswith(rocksdb_data_suffix):
+ # exactly the same file (same size) was sent in previous backup rounds
+ if prev is not None and f in prev.total_sent_sst and int(os.stat(f).st_size) == prev.total_sent_sst[f]:
+ continue
+ sst[f]= int(os.stat(f).st_size)
+ self.target_sst_size = self.target_sst_size + os.stat(f).st_size
+ elif is_manifest(f):
+ self.manifest_files.append(f)
+ elif f.endswith(rocksdb_wal_suffix):
+ self.wal_files.append(f)
+ self.target_sst= collections.OrderedDict(sorted(sst.items()))
+
+ if prev is not None:
+ self.total_sent_sst = prev.total_sent_sst
+ self.total_sent_sst_size = prev.total_sent_sst_size
+ self.total_target_sst_size = self.target_sst_size + prev.total_sent_sst_size
+ else:
+ self.total_target_sst_size = self.target_sst_size
+
+ def do_backup_single(self, fname):
+ self.writer.write(fname)
+ os.remove(fname)
+
+ def do_backup_sst(self, fname, size):
+ self.do_backup_single(fname)
+ self.sent_sst[fname]= size
+ self.total_sent_sst[fname]= size
+ self.sent_sst_size = self.sent_sst_size + size
+ self.total_sent_sst_size = self.total_sent_sst_size + size
+
+ def do_backup_manifest(self):
+ for f in self.manifest_files:
+ self.do_backup_single(f)
+
+ def do_backup_wal(self):
+ for f in self.wal_files:
+ self.do_backup_single(f)
+
+ # this is the last snapshot round. backing up all the rest files
+ def do_backup_final(self):
+ logger.info("Backup WAL..")
+ self.do_backup_wal()
+ logger.info("Backup Manifest..")
+ self.do_backup_manifest()
+ self.do_cleanup()
+ self.finished= True
+
+ def do_cleanup(self):
+ shutil.rmtree(self.source_dir)
+ logger.info("Cleaned up checkpoint from %s", self.source_dir)
+
+ def do_backup_until(self, time_limit):
+ logger.info("Starting backup from snapshot: target files %d", len(self.target_sst))
+ start_time= time.time()
+ last_progress_time= start_time
+ progress_size= 0
+ for fname, size in self.target_sst.iteritems():
+ self.do_backup_sst(fname, size)
+ progress_size= progress_size + size
+ elapsed_seconds = time.time() - start_time
+ progress_seconds = time.time() - last_progress_time
+
+ if self.should_show_progress(size):
+ self.show_progress(progress_size, progress_seconds)
+ progress_size=0
+ last_progress_time= time.time()
+
+ if elapsed_seconds > time_limit and self.has_sent_all_sst() is False:
+ logger.info("Snapshot round finished. Elapsed Time: %5.2f. Remaining sst files: %d",
+ elapsed_seconds, len(self.target_sst) - len(self.sent_sst))
+ self.do_cleanup()
+ break;
+ if self.has_sent_all_sst():
+ self.do_backup_final()
+
+ return self
+
+ def should_show_progress(self, size):
+ if int(self.total_sent_sst_size/self.show_progress_size_interval) > int((self.total_sent_sst_size-size)/self.show_progress_size_interval):
+ return True
+ else:
+ return False
+
+ def show_progress(self, size, seconds):
+ logger.info("Backup Progress: %5.2f%% Sent %6.2f GB of %6.2f GB data, Transfer Speed: %6.2f MB/s",
+ self.total_sent_sst_size*100/self.total_target_sst_size,
+ self.total_sent_sst_size/1024/1024/1024,
+ self.total_target_sst_size/1024/1024/1024,
+ size/seconds/1024/1024)
+
+ def print_backup_report(self):
+ logger.info("Sent %6.2f GB of sst files, %d files in total.",
+ self.total_sent_sst_size/1024/1024/1024,
+ len(self.total_sent_sst))
+
+ def has_sent_all_sst(self):
+ if self.sent_sst_size == self.target_sst_size:
+ return True
+ return False
+
+
+class MySQLUtil:
+ @staticmethod
+ def connect(user, password, port, socket=None):
+ if socket:
+ dbh = MySQLdb.Connect(user=user,
+ passwd=password,
+ unix_socket=socket)
+ else:
+ dbh = MySQLdb.Connect(user=user,
+ passwd=password,
+ port=port,
+ host="127.0.0.1")
+ return dbh
+
+ @staticmethod
+ def create_checkpoint(dbh, checkpoint_dir):
+ sql = ("SET GLOBAL rocksdb_create_checkpoint='{0}'"
+ .format(checkpoint_dir))
+ cur= dbh.cursor()
+ cur.execute(sql)
+ cur.close()
+
+ @staticmethod
+ def get_datadir(dbh):
+ sql = "SELECT @@datadir"
+ cur = dbh.cursor()
+ cur.execute(sql)
+ row = cur.fetchone()
+ return row[0]
+
+
+class BackupRunner:
+ datadir = None
+ start_backup_time = None
+
+ def __init__(self, datadir):
+ self.datadir = datadir
+ self.start_backup_time = time.time()
+
+ def start_backup_round(self, backup_round, prev_backup):
+ def signal_handler(*args):
+ logger.info("Got signal. Exit")
+ if b is not None:
+ logger.info("Cleaning up snapshot directory..")
+ b.do_cleanup()
+ sys.exit(1)
+
+ b = None
+ try:
+ signal.signal(signal.SIGINT, signal_handler)
+ w = None
+ if opts.output_stream:
+ w = StreamWriter(opts.output_stream)
+ else:
+ raise Exception("Currently only streaming backup is supported.")
+
+ snapshot_dir = opts.checkpoint_directory + '/' + str(backup_round)
+ dbh = MySQLUtil.connect(opts.mysql_user,
+ opts.mysql_password,
+ opts.mysql_port,
+ opts.mysql_socket)
+ if not self.datadir:
+ self.datadir = MySQLUtil.get_datadir(dbh)
+ logger.info("Set datadir: %s", self.datadir)
+ logger.info("Creating checkpoint at %s", snapshot_dir)
+ MySQLUtil.create_checkpoint(dbh, snapshot_dir)
+ logger.info("Created checkpoint at %s", snapshot_dir)
+ b = RocksDBBackup(snapshot_dir, w, prev_backup)
+ return b.do_backup_until(opts.checkpoint_interval)
+ except Exception as e:
+ logger.error(e)
+ logger.error(traceback.format_exc())
+ if b is not None:
+ logger.info("Cleaning up snapshot directory.")
+ b.do_cleanup()
+ sys.exit(1)
+
+ def backup_mysql(self):
+ try:
+ w = None
+ if opts.output_stream:
+ w = StreamWriter(opts.output_stream)
+ else:
+ raise Exception("Currently only streaming backup is supported.")
+ b = MySQLBackup(self.datadir, w, opts.skip_check_frm_timestamp,
+ self.start_backup_time)
+ logger.info("Taking MySQL misc backups..")
+ b.process()
+ logger.info("MySQL misc backups done.")
+ except Exception as e:
+ logger.error(e)
+ logger.error(traceback.format_exc())
+ sys.exit(1)
+
+
+class WDTBackup:
+ datadir = None
+ start_backup_time = None
+
+ def __init__(self, datadir):
+ self.datadir = datadir
+ self.start_backup_time = time.time()
+
+ def cleanup(self, snapshot_dir, server_log):
+ if server_log:
+ server_log.seek(0)
+ logger.info("WDT server log:")
+ logger.info(server_log.read())
+ server_log.close()
+ if snapshot_dir:
+ logger.info("Cleaning up snapshot dir %s", snapshot_dir)
+ shutil.rmtree(snapshot_dir)
+
+ def backup_with_timeout(self, backup_round):
+ def signal_handler(*args):
+ logger.info("Got signal. Exit")
+ self.cleanup(snapshot_dir, server_log)
+ sys.exit(1)
+
+ logger.info("Starting backup round %d", backup_round)
+ snapshot_dir = None
+ server_log = None
+ try:
+ signal.signal(signal.SIGINT, signal_handler)
+ # create rocksdb snapshot
+ snapshot_dir = os.path.join(opts.checkpoint_directory, str(backup_round))
+ dbh = MySQLUtil.connect(opts.mysql_user,
+ opts.mysql_password,
+ opts.mysql_port,
+ opts.mysql_socket)
+ logger.info("Creating checkpoint at %s", snapshot_dir)
+ MySQLUtil.create_checkpoint(dbh, snapshot_dir)
+ logger.info("Created checkpoint at %s", snapshot_dir)
+
+ # get datadir if not provided
+ if not self.datadir:
+ self.datadir = MySQLUtil.get_datadir(dbh)
+ logger.info("Set datadir: %s", self.datadir)
+
+ # create links for misc files
+ link_creator = MiscFilesLinkCreator(self.datadir, snapshot_dir,
+ opts.skip_check_frm_timestamp,
+ self.start_backup_time)
+ link_creator.process()
+
+ current_path = os.path.join(opts.backupdir, "CURRENT")
+
+ # construct receiver cmd, using the data directory as recovery-id.
+ # we delete the current file because it is not append-only, therefore not
+ # resumable.
+ remote_cmd = (
+ "ssh {0} rm -f {1}; "
+ "{2} -directory {3} -enable_download_resumption "
+ "-recovery_id {4} -start_port 0 -abort_after_seconds {5} {6}"
+ ).format(opts.destination,
+ current_path,
+ wdt_bin,
+ opts.backupdir,
+ self.datadir,
+ opts.checkpoint_interval,
+ opts.extra_wdt_receiver_options)
+ logger.info("WDT remote cmd %s", remote_cmd)
+ server_log = tempfile.TemporaryFile()
+ remote_process = subprocess.Popen(remote_cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=server_log)
+ wdt_url = remote_process.stdout.readline().strip()
+ if not wdt_url:
+ raise Exception("Unable to get connection url from wdt receiver")
+ sender_cmd = (
+ "{0} -connection_url \'{1}\' -directory {2} -app_name=myrocks "
+ "-avg_mbytes_per_sec {3} "
+ "-enable_download_resumption -abort_after_seconds {4} {5}"
+ ).format(wdt_bin,
+ wdt_url,
+ snapshot_dir,
+ opts.avg_mbytes_per_sec,
+ opts.checkpoint_interval,
+ opts.extra_wdt_sender_options)
+ sender_status = os.system(sender_cmd) >> 8
+ remote_status = remote_process.wait()
+ self.cleanup(snapshot_dir, server_log)
+ # TODO: handle retryable and non-retyable errors differently
+ return (sender_status == 0 and remote_status == 0)
+
+ except Exception as e:
+ logger.error(e)
+ logger.error(traceback.format_exc())
+ self.cleanup(snapshot_dir, server_log)
+ sys.exit(1)
+
+
+def backup_using_wdt():
+ if not opts.destination:
+ logger.error("Must provide remote destination when using WDT")
+ sys.exit(1)
+
+ # TODO: detect whether WDT is installed
+ logger.info("Backing up myrocks to %s using WDT", opts.destination)
+ wdt_backup = WDTBackup(opts.datadir)
+ finished = False
+ backup_round = 1
+ while not finished:
+ start_time = time.time()
+ finished = wdt_backup.backup_with_timeout(backup_round)
+ end_time = time.time()
+ duration_seconds = end_time - start_time
+ if (not finished) and (duration_seconds < opts.checkpoint_interval):
+ # round finished before timeout
+ sleep_duration = (opts.checkpoint_interval - duration_seconds)
+ logger.info("Sleeping for %f seconds", sleep_duration)
+ time.sleep(sleep_duration)
+
+ backup_round = backup_round + 1
+ logger.info("Finished myrocks backup using WDT")
+
+
+def init_logger():
+ global logger
+ logger = logging.getLogger('myrocks_hotbackup')
+ logger.setLevel(logging.INFO)
+ h1= logging.StreamHandler(sys.stderr)
+ f = logging.Formatter("%(asctime)s.%(msecs)03d %(levelname)s %(message)s",
+ "%Y-%m-%d %H:%M:%S")
+ h1.setFormatter(f)
+ logger.addHandler(h1)
+
+backup_wdt_usage = ("Backup using WDT: myrocks_hotbackup "
+ "--user=root --password=pw --stream=wdt "
+ "--checkpoint_dir=<directory where temporary backup hard links "
+ "are created> --destination=<remote host name> --backup_dir="
+ "<remote directory name>. This has to be executed at the src "
+ "host.")
+backup_usage= "Backup: set -o pipefail; myrocks_hotbackup --user=root --password=pw --port=3306 --checkpoint_dir=<directory where temporary backup hard links are created> | ssh -o NoneEnabled=yes remote_server 'tar -xi -C <directory on remote server where backups will be sent>' . You need to execute backup command on a server where you take backups."
+move_back_usage= "Move-Back: myrocks_hotbackup --move_back --datadir=<dest mysql datadir> --rocksdb_datadir=<dest rocksdb datadir> --rocksdb_waldir=<dest rocksdb wal dir> --backup_dir=<where backup files are stored> . You need to execute move-back command on a server where backup files are sent."
+
+
+def parse_options():
+ global opts
+ parser = OptionParser(usage = "\n\n" + backup_usage + "\n\n" + \
+ backup_wdt_usage + "\n\n" + move_back_usage)
+ parser.add_option('-i', '--interval', type='int', dest='checkpoint_interval',
+ default=300,
+ help='Number of seconds to renew checkpoint')
+ parser.add_option('-c', '--checkpoint_dir', type='string', dest='checkpoint_directory',
+ default='/data/mysql/backup/snapshot',
+ help='Local directory name where checkpoints will be created.')
+ parser.add_option('-d', '--datadir', type='string', dest='datadir',
+ default=None,
+ help='backup mode: src MySQL datadir. move_back mode: dest MySQL datadir')
+ parser.add_option('-s', '--stream', type='string', dest='output_stream',
+ default='tar',
+ help='Setting streaming backup options. Currently tar, WDT '
+ 'and xbstream are supported. Default is tar')
+ parser.add_option('--destination', type='string', dest='destination',
+ default='',
+ help='Remote server name. Only used for WDT mode so far.')
+ parser.add_option('--avg_mbytes_per_sec', type='int',
+ dest='avg_mbytes_per_sec',
+ default=500,
+ help='Average backup rate in MBytes/sec. WDT only.')
+ parser.add_option('--extra_wdt_sender_options', type='string',
+ dest='extra_wdt_sender_options',
+ default='',
+ help='Extra options for WDT sender')
+ parser.add_option('--extra_wdt_receiver_options', type='string',
+ dest='extra_wdt_receiver_options',
+ default='',
+ help='Extra options for WDT receiver')
+ parser.add_option('-u', '--user', type='string', dest='mysql_user',
+ default='root',
+ help='MySQL user name')
+ parser.add_option('-p', '--password', type='string', dest='mysql_password',
+ default='',
+ help='MySQL password name')
+ parser.add_option('-P', '--port', type='int', dest='mysql_port',
+ default=3306,
+ help='MySQL port number')
+ parser.add_option('-S', '--socket', type='string', dest='mysql_socket',
+ default=None,
+ help='MySQL socket path. Takes precedence over --port.')
+ parser.add_option('-m', '--move_back', action='store_true', dest='move_back',
+ default=False,
+ help='Moving MyRocks backup files to proper locations.')
+ parser.add_option('-r', '--rocksdb_datadir', type='string', dest='rocksdb_datadir',
+ default=None,
+ help='RocksDB target data directory where backup data files will be moved. Must be empty.')
+ parser.add_option('-w', '--rocksdb_waldir', type='string', dest='rocksdb_waldir',
+ default=None,
+ help='RocksDB target data directory where backup wal files will be moved. Must be empty.')
+ parser.add_option('-b', '--backup_dir', type='string', dest='backupdir',
+ default=None,
+ help='backup mode for WDT: Remote directory to store '
+ 'backup. move_back mode: Locations where backup '
+ 'files are stored.')
+ parser.add_option('-f', '--skip_check_frm_timestamp',
+ dest='skip_check_frm_timestamp',
+ action='store_true', default=False,
+ help='skipping to check if frm files are updated after starting backup.')
+ parser.add_option('-D', '--debug_signal_file', type='string', dest='debug_signal_file',
+ default=None,
+ help='debugging purpose: waiting until the specified file is created')
+
+ opts, args = parser.parse_args()
+
+
+def create_moveback_dir(directory):
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+ else:
+ for f in os.listdir(directory):
+ logger.error("Directory %s has file or directory %s!", directory, f)
+ raise
+
+def print_move_back_usage():
+ logger.warning(move_back_usage)
+
+def move_back():
+ if opts.rocksdb_datadir is None or opts.rocksdb_waldir is None or opts.backupdir is None or opts.datadir is None:
+ print_move_back_usage()
+ sys.exit()
+ create_moveback_dir(opts.datadir)
+ create_moveback_dir(opts.rocksdb_datadir)
+ create_moveback_dir(opts.rocksdb_waldir)
+
+ os.chdir(opts.backupdir)
+ for f in os.listdir(opts.backupdir):
+ if os.path.isfile(os.path.join(opts.backupdir,f)):
+ if f.endswith(rocksdb_wal_suffix):
+ shutil.move(f, opts.rocksdb_waldir)
+ elif f.endswith(rocksdb_data_suffix) or is_manifest(f):
+ shutil.move(f, opts.rocksdb_datadir)
+ else:
+ shutil.move(f, opts.datadir)
+ else: #directory
+ if f.endswith('.rocksdb'):
+ continue
+ shutil.move(f, opts.datadir)
+
+def start_backup():
+ logger.info("Starting backup.")
+ runner = BackupRunner(opts.datadir)
+ b = None
+ backup_round= 1
+ while True:
+ b = runner.start_backup_round(backup_round, b)
+ backup_round = backup_round + 1
+ if b.finished is True:
+ b.print_backup_report()
+ logger.info("RocksDB Backup Done.")
+ break
+ if opts.debug_signal_file:
+ while not os.path.exists(opts.debug_signal_file):
+ logger.info("Waiting until %s is created..", opts.debug_signal_file)
+ time.sleep(1)
+ runner.backup_mysql()
+ logger.info("All Backups Done.")
+
+
+def main():
+ parse_options()
+ init_logger()
+
+ if opts.move_back is True:
+ move_back()
+ elif opts.output_stream == 'wdt':
+ backup_using_wdt()
+ else:
+ start_backup()
+
+if __name__ == "__main__":
+ main()
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index bd302f155d2..e60355958bd 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)
{
@@ -7375,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",
@@ -7963,7 +7968,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 +9964,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 +10086,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<Item> *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<Item> *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 +10131,13 @@ int ha_spider::direct_update_rows_init(List<Item> *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 +10241,7 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
#else
+#ifdef SPIDER_MDEV_16246
/**
Perform initialization for a direct update request.
@@ -10209,37 +10251,43 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
0 Success.
*/
-int ha_spider::direct_update_rows_init(List<Item> *update_fields)
+int ha_spider::direct_update_rows_init(
+ List<Item> *update_fields
+)
+#else
+int ha_spider::direct_update_rows_init()
+#endif
{
st_select_lex *select_lex;
longlong select_limit;
longlong offset_limit;
- List_iterator<Item> it(*update_fields);
+ List_iterator<Item> 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 +10305,12 @@ int ha_spider::direct_update_rows_init(List<Item> *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<Item> *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 +10381,54 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields)
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
-int ha_spider::pre_direct_update_rows_init(List<Item> *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<Item> *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 +10439,34 @@ int ha_spider::pre_direct_update_rows_init(List<Item> *update_fields,
0 Success.
*/
-int ha_spider::pre_direct_update_rows_init(List<Item> *update_fields)
+int ha_spider::pre_direct_update_rows_init(
+ List<Item> *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 +11395,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 +11591,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 +11787,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 +13604,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 +13613,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 +15767,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 +15881,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<Item> *update_fields)
- {
+#ifdef SPIDER_MDEV_16246
+ inline int direct_update_rows_init(
+ List<Item> *update_fields
+ ) {
return direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL);
}
- int direct_update_rows_init(List<Item> *update_fields, uint mode,
- KEY_MULTI_RANGE *ranges, uint range_count,
- bool sorted, const uchar *new_data);
+ int direct_update_rows_init(
+ List<Item> *update_fields,
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+ );
+#else
+ 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
- int direct_update_rows_init(List<Item> *update_fields);
+#ifdef SPIDER_MDEV_16246
+ int direct_update_rows_init(
+ List<Item> *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<Item> *update_fields)
+#ifdef SPIDER_MDEV_16246
+ inline int pre_direct_update_rows_init(
+ List<Item> *update_fields
+ ) {
+ return pre_direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL);
+ }
+ int pre_direct_update_rows_init(
+ List<Item> *update_fields,
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+ );
+#else
+ inline int pre_direct_update_rows_init()
{
- return pre_direct_update_rows_init(update_fields,
- 2, NULL, 0, FALSE, NULL);
+ return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL);
}
- int pre_direct_update_rows_init(List<Item> *update_fields,
- uint mode, KEY_MULTI_RANGE *ranges,
- uint range_count, bool sorted,
- uchar *new_data);
+ int pre_direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+ );
+#endif
#else
- int pre_direct_update_rows_init(List<Item> *update_fields);
+#ifdef SPIDER_MDEV_16246
+ int pre_direct_update_rows_init(
+ List<Item> *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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/quick_mode_0.test b/storage/spider/mysql-test/spider/t/quick_mode_0.test
new file mode 100644
index 00000000000..6945d97a049
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/quick_mode_0.test
@@ -0,0 +1,294 @@
+--source ../include/quick_mode_0_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;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ 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
+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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ 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_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..d382d5dbe95
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/quick_mode_1.test
@@ -0,0 +1,294 @@
+--source ../include/quick_mode_1_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;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ 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
+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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ 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_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..ebb889868a6
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/quick_mode_2.test
@@ -0,0 +1,294 @@
+--source ../include/quick_mode_2_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;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ 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
+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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ 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_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..5992284f301
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/quick_mode_3.test
@@ -0,0 +1,294 @@
+--source ../include/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;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ 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
+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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ 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_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/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/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..507e5340779
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test
@@ -0,0 +1,148 @@
+--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;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ 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
+if ($USE_REPLICATION)
+{
+ 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
+if ($USE_REPLICATION)
+{
+ 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);
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ SET SESSION sql_log_bin= 0;
+}
+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/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..ba59acd64bc 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;
@@ -2086,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_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, &param_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 = &copy_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..c2cd4beccdb 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
@@ -3445,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
@@ -3971,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),
@@ -3987,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];
@@ -4011,9 +4100,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, &current->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, &current->result_tmp_tbl_prm, "a", "b", "c",
&my_charset_bin)))
+#endif
{
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
@@ -4039,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"));
@@ -5324,7 +5426,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 +5513,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 +5605,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 +5617,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 +8581,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 +8636,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 +8672,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,28 +8713,37 @@ 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)
- {
+ 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);
+ item->print(str->get_str(), QT_IS);
#else
- item->print(str->get_str(), QT_TO_SYSTEM_CHARSET);
+ item->print(str->get_str(), QT_TO_SYSTEM_CHARSET);
#endif
- } else {
- item->print(str->get_str(), QT_ORDINARY);
- }
- str->mem_calc();
- }
- break;
+ } else {
+ item->print(str->get_str(), QT_ORDINARY);
+ }
+ str->mem_calc();
}
-
DBUG_RETURN(0);
}
@@ -8641,8 +8776,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 +8810,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 +8919,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 +8936,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 +8950,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 +9043,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 +9116,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 +9127,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 +9156,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 +9176,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 +9187,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 +9214,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 +9230,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 +9263,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 +9281,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 +9314,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 +9334,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 +9379,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 +9399,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 +9414,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 +9427,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 +9447,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 +9467,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 +9491,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 +9556,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 +9576,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 +10776,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..bf09d672685 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
);
@@ -566,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
@@ -859,6 +876,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..4aebc7811b4 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
@@ -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);
}
@@ -2755,10 +2761,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 +2830,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 +2846,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 +2860,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 +2870,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 +2883,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 +2920,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 +2945,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 +2972,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 +3061,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 +3124,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 +3133,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 +3387,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 +3404,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 +3427,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 +3561,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 +3579,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 +3606,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 +3627,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 +3642,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 +3660,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 +3692,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 +3726,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 +3736,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 +3754,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 +3768,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 +3856,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 +3867,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 +3908,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 +4218,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..075f8720abf 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,
@@ -142,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();
@@ -170,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 d19306b1b1a..cc4d2bcd3a1 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,
@@ -937,6 +941,7 @@ public:
TABLE *tmp_table,
spider_string *str
) = 0;
+ virtual uint get_byte_size() = 0;
};
class spider_db_result_buffer
@@ -1943,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 ada9aa20821..ceb38f886aa 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()
{
@@ -406,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,
@@ -442,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;
@@ -484,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)
@@ -550,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);
}
@@ -573,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);
}
@@ -605,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)
@@ -713,8 +749,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,
&not_used_long, &not_used_uint);
@@ -738,8 +774,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,
&not_used_long, &not_used_uint);
@@ -763,8 +799,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,
&not_used_long, &not_used_uint);
@@ -831,8 +867,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,
&not_used_long, &not_used_uint);
@@ -856,8 +892,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,
&not_used_long, &not_used_uint);
@@ -881,8 +917,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,
&not_used_long, &not_used_uint);
@@ -1524,7 +1560,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 +3128,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 +3253,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 +3330,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 +3386,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 +3656,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 +3728,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 +3743,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 +3757,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 +3767,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 +3780,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 +3818,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 +3843,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 +3959,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 +4021,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 +4030,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 +4284,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 +4301,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 +4332,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 +4525,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 +4627,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 +4634,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 +4662,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 +4679,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 +4766,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 +4778,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 +4794,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 +4861,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;
- DBUG_ENTER("spider_db_mysql_util::append_from_and_tables");
+ 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<String> *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<String> 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<TABLE_LIST> 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);
+ }
+ }
+ }
- /* calculate from size */
- from_length = SPIDER_SQL_FROM_LEN;
- fields->set_pos_to_first_table_holder();
- while ((table_holder = fields->get_next_table_holder()))
+ 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)
{
- 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)
+ {
+ 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<String> *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<String> 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<TABLE_LIST> 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);
+}
- if (str->reserve(from_length))
+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);
- str->q_append(SPIDER_SQL_FROM_STR, 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];
- 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])))
+ if (str->reserve(SPIDER_SQL_FROM_LEN))
{
- DBUG_RETURN(error_num);
+ my_afree(used_table_list);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
- 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->q_append(SPIDER_SQL_FROM_STR, SPIDER_SQL_FROM_LEN);
}
- str->length(str->length() - SPIDER_SQL_COMMA_LEN);
+
+ do {
+ table = table_list->table;
+ if (table->const_table)
+ continue;
+
+ 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,
+ &current_pos, &cond_table_list, FALSE, FALSE)))
+ {
+ my_afree(used_table_list);
+ DBUG_RETURN(error_num);
+ }
+ 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, 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 +5862,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);
@@ -5377,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++)
{
@@ -5613,6 +6131,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 +6159,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 +7802,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 +8190,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 +8813,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 +8904,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 +9039,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 +9364,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 +9557,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 +11185,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 +11884,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 +12084,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 +13327,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 +13339,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 +13428,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 +13476,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 +13496,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 +13551,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 +13609,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 +13732,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 +13861,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 +13891,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 +14023,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..9a709f46c51 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_table(
+ 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,
+ 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
+ spider_string *str,
+ TABLE_LIST *table_list,
+ uint table_count
);
int reappend_tables(
spider_fields *fields,
@@ -147,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();
@@ -175,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 b852a43282c..82a1e9a0fbc 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,
@@ -516,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())
@@ -568,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;
@@ -693,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)
@@ -754,6 +766,7 @@ int spider_db_oracle_row::fetch()
}
}
row_size[i] = val_str[i].length();
+ record_size += row_size[i];
}
DBUG_RETURN(0);
}
@@ -908,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);
}
@@ -2410,8 +2424,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 +2548,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 +2647,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 +2934,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 +3006,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 +3022,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 +3036,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 +3046,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 +3059,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 +3096,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 +3121,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 +3148,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 +3237,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 +3300,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 +3309,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 +3575,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 +3594,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 +3641,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 +3658,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 +3739,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 +3873,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 +3891,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 +3918,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 +3939,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 +3954,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 +3972,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 +4004,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 +4038,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 +4071,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 +4085,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 +4173,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 +4184,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 +4244,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 +4783,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);
@@ -4778,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++)
{
@@ -5188,6 +5226,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 +5254,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 +6460,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 +6478,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 +6880,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 +7483,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 +7571,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 +7712,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 +8034,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 +8373,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 +8464,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 +10296,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 +12557,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 +12569,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 +12656,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 +12698,26 @@ int spider_oracle_handler::append_list_item_select(
uint dbton_id = spider_dbton_oracle.dbton_id, length;
List_iterator_fast<Item> 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 +12725,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 +12779,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 +12837,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 +12948,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 +13094,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 +13128,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 +13192,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 +13225,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 +13433,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..d0bd1757418 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,
@@ -167,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;
@@ -200,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_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, &param_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..3b57092c4ce 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;
@@ -819,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;
@@ -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);
@@ -1767,12 +1790,21 @@ 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);
@@ -2036,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_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..23bbff22fbb 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)))
@@ -907,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 9c7aa4dcdcb..6b237bbfff8 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
@@ -1364,6 +1364,31 @@ longlong spider_param_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.
1 :It uses low memory mode.
*/
@@ -3123,6 +3148,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
@@ -3279,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 };
@@ -3330,6 +3406,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
@@ -3421,11 +3498,13 @@ 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),
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 06df06a3129..8fdf2e452b2 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
@@ -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
@@ -397,6 +401,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
);
@@ -413,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_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..cd1c56a077e 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,
&not_used_long, &not_used_uint);
@@ -2394,7 +2471,7 @@ void spider_get_sys_table_sts_info(
*check_time = (time_t) my_system_gmt_sec(&mysql_time,
&not_used_long, &not_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,
&not_used_long, &not_used_uint);
@@ -2402,7 +2479,7 @@ void spider_get_sys_table_sts_info(
*create_time = (time_t) my_system_gmt_sec(&mysql_time,
&not_used_long, &not_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,
&not_used_long, &not_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<Item> 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);
@@ -3244,8 +3331,9 @@ 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,
- HA_POS_ERROR, &empty_clex_string)))
+ 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);
@@ -3270,6 +3358,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 +3377,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<Item> 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 +3410,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 +3432,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(
@@ -3355,8 +3453,9 @@ 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,
- HA_POS_ERROR, &empty_clex_string)))
+ 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);
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..fe5265184b6 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; \
} \
@@ -2046,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;
@@ -2291,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);
@@ -2460,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);
@@ -3825,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)
@@ -5219,15 +5223,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 (
@@ -7993,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;
@@ -8965,7 +8976,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 +9050,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 +9066,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 +9508,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 +9522,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..6204ca9852c 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"
@@ -1587,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);
}
@@ -1648,9 +1649,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 +2763,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 +2813,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 +3048,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];