summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku <kentokushiba@gmail.com>2019-04-05 06:23:57 +0900
committerKentoku <kentokushiba@gmail.com>2019-04-05 06:26:13 +0900
commit58c9874c42944e540e6bbdf77fddb471e3f8cbc2 (patch)
treec96a4ff347be9e56d39044a436b5b1c18c6f25a9
parent3f154ef1c820d53d61b9da6f6fa439b09b0d183d (diff)
downloadmariadb-git-bb-10.4-vp-ks.tar.gz
MDEV-7795 Merge vertical partitioning storage enginebb-10.4-vp-ks
-rw-r--r--storage/vp/CMakeLists.txt33
-rw-r--r--storage/vp/Makefile.am39
-rw-r--r--storage/vp/configure.in95
-rw-r--r--storage/vp/ha_vp.cc12562
-rw-r--r--storage/vp/ha_vp.h1160
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child2_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child2_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child3_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child3_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_child3_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_master_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_slave1_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/deinit_vp.inc2
-rw-r--r--storage/vp/mysql-test/vp/include/init_child2_1.inc234
-rw-r--r--storage/vp/mysql-test/vp/include/init_child2_2.inc105
-rw-r--r--storage/vp/mysql-test/vp/include/init_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/init_child3_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/init_child3_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/init_child3_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/include/init_master_1.inc113
-rw-r--r--storage/vp/mysql-test/vp/include/init_slave1_1.inc10
-rw-r--r--storage/vp/mysql-test/vp/include/init_vp.inc17
-rw-r--r--storage/vp/mysql-test/vp/my.cnf86
-rw-r--r--storage/vp/mysql-test/vp/r/basic_sql.result736
-rw-r--r--storage/vp/mysql-test/vp/r/basic_sql_part.result136
-rw-r--r--storage/vp/mysql-test/vp/r/direct_aggregate.result88
-rw-r--r--storage/vp/mysql-test/vp/r/direct_aggregate_part.result78
-rw-r--r--storage/vp/mysql-test/vp/r/direct_update.result141
-rw-r--r--storage/vp/mysql-test/vp/r/direct_update_part.result131
-rw-r--r--storage/vp/mysql-test/vp/r/fulltext.result70
-rw-r--r--storage/vp/mysql-test/vp/r/fulltext_part.result59
-rw-r--r--storage/vp/mysql-test/vp/r/function.result154
-rw-r--r--storage/vp/mysql-test/vp/r/geometry.result103
-rw-r--r--storage/vp/mysql-test/vp/r/geometry_normal.result85
-rw-r--r--storage/vp/mysql-test/vp/r/geometry_part.result86
-rw-r--r--storage/vp/mysql-test/vp/r/ha.result2
-rw-r--r--storage/vp/mysql-test/vp/r/ha_part.result2
-rw-r--r--storage/vp/mysql-test/vp/r/handler.result122
-rw-r--r--storage/vp/mysql-test/vp/r/handler_part.result112
-rw-r--r--storage/vp/mysql-test/vp/r/spider3_fixes.result206
-rw-r--r--storage/vp/mysql-test/vp/r/spider3_fixes_part.result204
-rw-r--r--storage/vp/mysql-test/vp/r/spider_fixes.result542
-rw-r--r--storage/vp/mysql-test/vp/r/spider_fixes_part.result219
-rw-r--r--storage/vp/mysql-test/vp/r/vp_fixes.result89
-rw-r--r--storage/vp/mysql-test/vp/spider/disabled.def1
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child2_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child2_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child3_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child3_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_child3_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_master_1.inc5
-rw-r--r--storage/vp/mysql-test/vp/spider/include/deinit_slave1_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_1.inc2
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_2.inc2
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_3.inc2
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_deinit_master_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child2_1.inc16
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child2_2.inc8
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child2_3.inc8
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child3_1.inc109
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child3_2.inc109
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_child3_3.inc109
-rw-r--r--storage/vp/mysql-test/vp/spider/include/ha_init_master_1.inc117
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_2.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_deinit_master_1.inc3
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_init_child2_1.inc37
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_init_child2_2.inc19
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_init_child2_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/hs_init_master_1.inc61
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child2_1.inc234
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child2_2.inc105
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child2_3.inc17
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child3_1.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child3_2.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_child3_3.inc0
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_master_1.inc425
-rw-r--r--storage/vp/mysql-test/vp/spider/include/init_slave1_1.inc10
-rw-r--r--storage/vp/mysql-test/vp/spider/include/item_insert_value_deinit.inc18
-rw-r--r--storage/vp/mysql-test/vp/spider/include/item_insert_value_init.inc73
-rw-r--r--storage/vp/mysql-test/vp/spider/my.cnf147
-rw-r--r--storage/vp/mysql-test/vp/spider/r/basic_sql.result742
-rw-r--r--storage/vp/mysql-test/vp/spider/r/basic_sql_part.result142
-rw-r--r--storage/vp/mysql-test/vp/spider/r/direct_aggregate.result100
-rw-r--r--storage/vp/mysql-test/vp/spider/r/direct_aggregate_part.result90
-rw-r--r--storage/vp/mysql-test/vp/spider/r/direct_update.result155
-rw-r--r--storage/vp/mysql-test/vp/spider/r/direct_update_part.result145
-rw-r--r--storage/vp/mysql-test/vp/spider/r/fulltext.result76
-rw-r--r--storage/vp/mysql-test/vp/spider/r/fulltext_part.result65
-rw-r--r--storage/vp/mysql-test/vp/spider/r/function.result160
-rw-r--r--storage/vp/mysql-test/vp/spider/r/geometry.result109
-rw-r--r--storage/vp/mysql-test/vp/spider/r/geometry_part.result92
-rw-r--r--storage/vp/mysql-test/vp/spider/r/ha.result510
-rw-r--r--storage/vp/mysql-test/vp/spider/r/ha_part.result511
-rw-r--r--storage/vp/mysql-test/vp/spider/r/handler.result128
-rw-r--r--storage/vp/mysql-test/vp/spider/r/handler_part.result118
-rw-r--r--storage/vp/mysql-test/vp/spider/r/handlersocket.result141
-rw-r--r--storage/vp/mysql-test/vp/spider/r/handlersocket_part.result141
-rw-r--r--storage/vp/mysql-test/vp/spider/r/item_insert_value.result107
-rw-r--r--storage/vp/mysql-test/vp/spider/r/spider3_fixes.result240
-rw-r--r--storage/vp/mysql-test/vp/spider/r/spider3_fixes_part.result238
-rw-r--r--storage/vp/mysql-test/vp/spider/r/spider_fixes.result574
-rw-r--r--storage/vp/mysql-test/vp/spider/r/spider_fixes_part.result241
-rw-r--r--storage/vp/mysql-test/vp/spider/r/vp_fixes.result95
-rw-r--r--storage/vp/mysql-test/vp/spider/suite.opt2
-rw-r--r--storage/vp/mysql-test/vp/spider/suite.pm11
-rw-r--r--storage/vp/mysql-test/vp/spider/t/basic_sql.test2699
-rw-r--r--storage/vp/mysql-test/vp/spider/t/basic_sql_part.test571
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child2_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child2_2.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child2_3.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child3_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child3_2.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_child3_3.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_master_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/connect_slave1_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/spider/t/direct_aggregate.test179
-rw-r--r--storage/vp/mysql-test/vp/spider/t/direct_aggregate_part.test192
-rw-r--r--storage/vp/mysql-test/vp/spider/t/direct_update.test198
-rw-r--r--storage/vp/mysql-test/vp/spider/t/direct_update_part.test211
-rw-r--r--storage/vp/mysql-test/vp/spider/t/fulltext.test181
-rw-r--r--storage/vp/mysql-test/vp/spider/t/fulltext_part.test195
-rw-r--r--storage/vp/mysql-test/vp/spider/t/function.test253
-rw-r--r--storage/vp/mysql-test/vp/spider/t/geometry.test192
-rw-r--r--storage/vp/mysql-test/vp/spider/t/geometry_part.test206
-rw-r--r--storage/vp/mysql-test/vp/spider/t/ha.test878
-rw-r--r--storage/vp/mysql-test/vp/spider/t/ha_part.test1017
-rw-r--r--storage/vp/mysql-test/vp/spider/t/ha_test_deinit.inc30
-rw-r--r--storage/vp/mysql-test/vp/spider/t/ha_test_init.inc30
-rw-r--r--storage/vp/mysql-test/vp/spider/t/handler.test188
-rw-r--r--storage/vp/mysql-test/vp/spider/t/handler_part.test201
-rw-r--r--storage/vp/mysql-test/vp/spider/t/have_engine.inc7
-rw-r--r--storage/vp/mysql-test/vp/spider/t/have_func.inc5
-rw-r--r--storage/vp/mysql-test/vp/spider/t/have_partition.inc7
-rw-r--r--storage/vp/mysql-test/vp/spider/t/have_plugin.inc5
-rw-r--r--storage/vp/mysql-test/vp/spider/t/have_trigger.inc2
-rw-r--r--storage/vp/mysql-test/vp/spider/t/hs_test_deinit.inc17
-rw-r--r--storage/vp/mysql-test/vp/spider/t/hs_test_init.inc17
-rw-r--r--storage/vp/mysql-test/vp/spider/t/item_insert_value.test154
-rw-r--r--storage/vp/mysql-test/vp/spider/t/slave_test_deinit.inc6
-rw-r--r--storage/vp/mysql-test/vp/spider/t/slave_test_init.inc44
-rw-r--r--storage/vp/mysql-test/vp/spider/t/spider3_fixes.test292
-rw-r--r--storage/vp/mysql-test/vp/spider/t/spider3_fixes_part.test345
-rw-r--r--storage/vp/mysql-test/vp/spider/t/spider_fixes.test1419
-rw-r--r--storage/vp/mysql-test/vp/spider/t/spider_fixes_part.test645
-rw-r--r--storage/vp/mysql-test/vp/spider/t/test_deinit.inc37
-rw-r--r--storage/vp/mysql-test/vp/spider/t/test_init.inc74
-rw-r--r--storage/vp/mysql-test/vp/spider/t/vp_fixes.test335
-rw-r--r--storage/vp/mysql-test/vp/suite.opt2
-rw-r--r--storage/vp/mysql-test/vp/suite.pm11
-rw-r--r--storage/vp/mysql-test/vp/t/basic_sql.test2699
-rw-r--r--storage/vp/mysql-test/vp/t/basic_sql_part.test571
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child2_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child2_2.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child2_3.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child3_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child3_2.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_child3_3.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_master_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/connect_slave1_1.inc1
-rw-r--r--storage/vp/mysql-test/vp/t/direct_aggregate.test179
-rw-r--r--storage/vp/mysql-test/vp/t/direct_aggregate_part.test192
-rw-r--r--storage/vp/mysql-test/vp/t/direct_update.test198
-rw-r--r--storage/vp/mysql-test/vp/t/direct_update_part.test211
-rw-r--r--storage/vp/mysql-test/vp/t/fulltext.test181
-rw-r--r--storage/vp/mysql-test/vp/t/fulltext_part.test195
-rw-r--r--storage/vp/mysql-test/vp/t/function.test253
-rw-r--r--storage/vp/mysql-test/vp/t/geometry.test192
-rw-r--r--storage/vp/mysql-test/vp/t/geometry_normal.test81
-rw-r--r--storage/vp/mysql-test/vp/t/geometry_part.test206
-rw-r--r--storage/vp/mysql-test/vp/t/ha.test878
-rw-r--r--storage/vp/mysql-test/vp/t/ha_part.test1017
-rw-r--r--storage/vp/mysql-test/vp/t/ha_test_deinit.inc30
-rw-r--r--storage/vp/mysql-test/vp/t/ha_test_init.inc30
-rw-r--r--storage/vp/mysql-test/vp/t/handler.test188
-rw-r--r--storage/vp/mysql-test/vp/t/handler_part.test201
-rw-r--r--storage/vp/mysql-test/vp/t/have_engine.inc7
-rw-r--r--storage/vp/mysql-test/vp/t/have_func.inc5
-rw-r--r--storage/vp/mysql-test/vp/t/have_partition.inc7
-rw-r--r--storage/vp/mysql-test/vp/t/have_plugin.inc5
-rw-r--r--storage/vp/mysql-test/vp/t/have_trigger.inc2
-rw-r--r--storage/vp/mysql-test/vp/t/hs_test_deinit.inc17
-rw-r--r--storage/vp/mysql-test/vp/t/hs_test_init.inc17
-rw-r--r--storage/vp/mysql-test/vp/t/slave_test_deinit.inc6
-rw-r--r--storage/vp/mysql-test/vp/t/slave_test_init.inc44
-rw-r--r--storage/vp/mysql-test/vp/t/spider3_fixes.test292
-rw-r--r--storage/vp/mysql-test/vp/t/spider3_fixes_part.test345
-rw-r--r--storage/vp/mysql-test/vp/t/spider_fixes.test1419
-rw-r--r--storage/vp/mysql-test/vp/t/spider_fixes_part.test645
-rw-r--r--storage/vp/mysql-test/vp/t/test_deinit.inc37
-rw-r--r--storage/vp/mysql-test/vp/t/test_init.inc74
-rw-r--r--storage/vp/mysql-test/vp/t/vp_fixes.test335
-rw-r--r--storage/vp/scripts/install_vp.sql46
-rw-r--r--storage/vp/vp_copy_tables.cc1141
-rw-r--r--storage/vp/vp_copy_tables.h67
-rw-r--r--storage/vp/vp_environ.h66
-rw-r--r--storage/vp/vp_err.h60
-rw-r--r--storage/vp/vp_include.h434
-rw-r--r--storage/vp/vp_param.cc384
-rw-r--r--storage/vp/vp_param.h56
-rw-r--r--storage/vp/vp_table.cc2705
-rw-r--r--storage/vp/vp_table.h461
-rw-r--r--storage/vp/vp_udf.cc44
-rw-r--r--storage/vp/vp_udf.def6
-rw-r--r--storage/vp/vp_udf.h31
211 files changed, 51515 insertions, 0 deletions
diff --git a/storage/vp/CMakeLists.txt b/storage/vp/CMakeLists.txt
new file mode 100644
index 00000000000..98ddd78eb9d
--- /dev/null
+++ b/storage/vp/CMakeLists.txt
@@ -0,0 +1,33 @@
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET")
+
+IF(HAVE_WVLA)
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
+ENDIF()
+
+SET(VP_SOURCES
+ vp_param.cc vp_table.cc vp_udf.cc vp_copy_tables.cc ha_vp.cc vp_udf.def)
+
+IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake)
+ SET(CMAKE_CXX_FLAGS_DEBUG
+ "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
+ SET(CMAKE_C_FLAGS_DEBUG
+ "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
+ SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS")
+ INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
+
+ INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex)
+
+ MYSQL_STORAGE_ENGINE(VP)
+ELSE()
+ INSTALL(FILES
+ ${CMAKE_SOURCE_DIR}/storage/vp/scripts/install_vp.sql
+ DESTINATION ${INSTALL_MYSQLSHAREDIR} COMPONENT Server
+ )
+ SET(VP_DEB_FILES "usr/lib/mysql/plugin/ha_vp.so usr/share/mysql/install_vp.sql" PARENT_SCOPE)
+ MYSQL_ADD_PLUGIN(vp ${VP_SOURCES} STORAGE_ENGINE MODULE_ONLY MODULE_OUTPUT_NAME "ha_vp")
+ENDIF()
diff --git a/storage/vp/Makefile.am b/storage/vp/Makefile.am
new file mode 100644
index 00000000000..3d88f9fa639
--- /dev/null
+++ b/storage/vp/Makefile.am
@@ -0,0 +1,39 @@
+pkgplugindir = $(pkglibdir)/plugin
+INCLUDES = -I$(MYSQL_INC)$(top_srcdir)/include \
+ -I$(MYSQL_INC)$(top_srcdir)/regex \
+ -I$(MYSQL_INC)$(top_srcdir)/sql \
+ -I$(MYSQL_INC)$(top_srcdir)/extra/yassl/include \
+ $(MYSQL_INCLUDE_PATH)
+
+noinst_HEADERS = ha_vp.h vp_err.h \
+ vp_table.h vp_include.h vp_param.h \
+ vp_udf.h vp_copy_tables.h
+
+lib_LTLIBRARIES = $(PLUGIN_VP_LTLIBRARIES_TARGET)
+EXTRA_LTLIBRARIES = ha_vp.la
+pkgplugin_LTLIBRARIES = @plugin_vp_shared_target@
+ha_vp_la_LDFLAGS = -shared -module -rpath $(pkgplugindir)
+ha_vp_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_vp_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_vp_la_SOURCES = \
+ vp_param.cc \
+ vp_table.cc \
+ vp_udf.cc \
+ vp_copy_tables.cc \
+ ha_vp.cc
+
+lib_LIBRARIES = $(PLUGIN_VP_LIBRARIES_TARGET)
+EXTRA_LIBRARIES = libvp.a
+noinst_LIBRARIES = @plugin_vp_static_target@
+libvp_a_CXXFLAGS = $(AM_CFLAGS)
+libvp_a_CFLAGS = $(AM_CFLAGS)
+libvp_a_SOURCES = \
+ vp_param.cc \
+ vp_table.cc \
+ vp_udf.cc \
+ vp_copy_tables.cc \
+ ha_vp.cc
+
+EXTRA_DIST = plug.in
+# Don't update the files from bitkeeper
+%::SCCS/s.%
diff --git a/storage/vp/configure.in b/storage/vp/configure.in
new file mode 100644
index 00000000000..b67c5513f16
--- /dev/null
+++ b/storage/vp/configure.in
@@ -0,0 +1,95 @@
+AC_INIT([vp_engine], [1.0], [kentokushiba@gmail.com])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE
+
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+
+AC_TYPE_SIZE_T
+
+AC_DEFUN([MYSQL_PATH_TEST],[
+ AC_MSG_CHECKING([mysql source path])
+ AC_ARG_WITH([mysql],
+ [AS_HELP_STRING([--with-mysql=PATH],[mysql source directory PATH])],
+ [
+ if test \
+ -f $withval/include/mysql/plugin.h -a \
+ -f $withval/include/mysql.h -a \
+ -f $withval/include/errmsg.h -a \
+ \( -f $withval/sql/mysql_priv.h -o -f $withval/sql/sql_priv.h \) ;
+ then
+ MYSQL_INC="$withval/"
+ AC_MSG_RESULT([yes])
+ plugin_vp_shared_target=""
+ AC_SUBST(plugin_vp_shared_target)
+ plugin_vp_static_target=""
+ AC_SUBST(plugin_vp_static_target)
+ PLUGIN_VP_LTLIBRARIES_TARGET="ha_vp.la"
+ AC_SUBST(PLUGIN_VP_LTLIBRARIES_TARGET)
+ PLUGIN_VP_LIBRARIES_TARGET="libvp.a"
+ AC_SUBST(PLUGIN_VP_LIBRARIES_TARGET)
+ LIBTOOL="$LIBTOOL --preserve-dup-deps"
+ AC_SUBST(LIBTOOL)
+ else
+ AC_MSG_ERROR([Can't find header files. Please check --with-mysql=PATH option])
+ fi
+ ],
+ [
+ if test \
+ -f ../../include/mysql/plugin.h -a \
+ -f ../../include/mysql.h -a \
+ -f ../../include/errmsg.h -a \
+ \( -f ../../sql/mysql_priv.h -o ../../sql/sql_priv.h \) ;
+ then
+ MYSQL_INC="../../"
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_ERROR([Can't find header files. Please set --with-mysql=PATH option])
+ fi
+ ]
+ )
+])
+
+MYSQL_PATH_TEST
+AC_SUBST(MYSQL_INC)
+
+AC_DEFUN([MYSQL_INCLUDE_PATH_TEST],[
+ AC_MSG_CHECKING([mysql include path])
+ AC_ARG_WITH([mysql-include],
+ [AS_HELP_STRING([--with-mysql-include=PATH],[mysql include directory PATH])],
+ [
+ if test \
+ -f $withval/mysql_version.h -a \
+ -f $withval/my_config.h ;
+ then
+ MYSQL_INCLUDE_PATH="-I $withval/"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_ERROR([Can't find "my_config.h". Please check --with-mysql-include=PATH option])
+ fi
+ ],
+ [
+ if test \
+ -f ../../include/mysql_version.h -a \
+ -f ../../include/my_config.h ;
+ then
+ MYSQL_INCLUDE_PATH="-I ../../include/"
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_ERROR([Can't find "my_config.h". Please set --with-mysql-include=PATH option])
+ fi
+ ]
+ )
+])
+
+MYSQL_INCLUDE_PATH_TEST
+AC_SUBST(MYSQL_INCLUDE_PATH)
+
+CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
+
+
+AC_CHECK_FUNCS([memset strchr strncasecmp])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/storage/vp/ha_vp.cc b/storage/vp/ha_vp.cc
new file mode 100644
index 00000000000..cde8d0cdd33
--- /dev/null
+++ b/storage/vp/ha_vp.cc
@@ -0,0 +1,12562 @@
+/* Copyright (C) 2009-2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
+#pragma implementation
+#endif
+
+#define MYSQL_SERVER 1
+#include <my_global.h>
+#include "mysql_version.h"
+#include "vp_environ.h"
+#if MYSQL_VERSION_ID < 50500
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#else
+#include "sql_priv.h"
+#include "probes_mysql.h"
+#include "sql_class.h"
+#include "sql_partition.h"
+#include "key.h"
+#include "sql_select.h"
+#ifdef HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
+#include "opt_range.h"
+#endif
+#endif
+#include "vp_param.h"
+#include "vp_err.h"
+#include "vp_include.h"
+#include "ha_vp.h"
+#include "vp_table.h"
+
+#ifdef HA_CAN_BG_SEARCH
+#define VP_CAN_BG_SEARCH HA_CAN_BG_SEARCH
+#else
+#define VP_CAN_BG_SEARCH 0
+#endif
+#ifdef HA_CAN_BG_INSERT
+#define VP_CAN_BG_INSERT HA_CAN_BG_INSERT
+#else
+#define VP_CAN_BG_INSERT 0
+#endif
+#ifdef HA_CAN_BG_UPDATE
+#define VP_CAN_BG_UPDATE HA_CAN_BG_UPDATE
+#else
+#define VP_CAN_BG_UPDATE 0
+#endif
+
+static longlong vp_base_table_flags =
+ (
+ HA_HAS_RECORDS |
+ HA_BINLOG_ROW_CAPABLE |
+ HA_BINLOG_STMT_CAPABLE |
+#ifdef HA_CAN_BULK_ACCESS
+ HA_CAN_BULK_ACCESS |
+#endif
+#ifdef HA_CAN_DIRECT_UPDATE_AND_DELETE
+ HA_CAN_DIRECT_UPDATE_AND_DELETE |
+#endif
+ VP_CAN_BG_SEARCH | VP_CAN_BG_INSERT | VP_CAN_BG_UPDATE
+ );
+
+
+extern handlerton *vp_hton_ptr;
+#ifndef WITHOUT_VP_BG_ACCESS
+extern pthread_attr_t vp_pt_attr;
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+#ifndef WITHOUT_VP_BG_ACCESS
+extern PSI_mutex_key vp_key_mutex_bg_sync;
+extern PSI_mutex_key vp_key_mutex_bg;
+extern PSI_cond_key vp_key_cond_bg_sync;
+extern PSI_cond_key vp_key_cond_bg;
+extern PSI_thread_key vp_key_thd_bg;
+#endif
+#endif
+
+ha_vp::ha_vp(
+) : handler(vp_hton_ptr, NULL)
+#ifdef HA_CAN_BULK_ACCESS
+ , bulk_access_started(FALSE)
+ , bulk_access_executing(FALSE)
+ , bulk_access_pre_called(FALSE)
+ , bulk_access_info_first(NULL)
+ , bulk_access_info_current(NULL)
+ , bulk_access_info_exec_tgt(NULL)
+ , bulk_access_exec_bitmap(NULL)
+#endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ , handler_close(FALSE)
+#endif
+ , mr_init(FALSE)
+{
+ DBUG_ENTER("ha_vp::ha_vp");
+ DBUG_PRINT("info",("vp this=%p", this));
+ share = NULL;
+ part_tables = NULL;
+ use_tables = NULL;
+ work_bitmap = NULL;
+ ref_length = 0;
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ allocated_top_table_fields = 0;
+#endif
+ additional_table_flags = vp_base_table_flags;
+ ins_child_bitmaps[0] = NULL;
+ condition = NULL;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_handler_share = NULL;
+ pt_handler_share_creator = NULL;
+ clone_partition_handler_share = NULL;
+#endif
+ is_clone = FALSE;
+ pt_clone_source_handler = NULL;
+ ft_first = NULL;
+ ft_current = NULL;
+ ft_inited = FALSE;
+ ft_count = 0;
+#if MYSQL_VERSION_ID < 50500
+#else
+ children_l = NULL;
+ children_attached = FALSE;
+#endif
+ suppress_autoinc = FALSE;
+ use_pre_call = FALSE;
+#ifdef VP_SUPPORT_MRR
+ m_mrr_range_first = NULL;
+ m_child_mrr_range_first = NULL;
+ m_range_info = NULL;
+ m_mrr_full_buffer = NULL;
+ m_mrr_full_buffer_size = 0;
+ m_mrr_new_full_buffer_size = 0;
+#endif
+ DBUG_VOID_RETURN;
+}
+
+ha_vp::ha_vp(
+ handlerton *hton,
+ TABLE_SHARE *table_arg
+) : handler(hton, table_arg)
+#ifdef HA_CAN_BULK_ACCESS
+ , bulk_access_started(FALSE)
+ , bulk_access_executing(FALSE)
+ , bulk_access_pre_called(FALSE)
+ , bulk_access_info_first(NULL)
+ , bulk_access_info_current(NULL)
+ , bulk_access_info_exec_tgt(NULL)
+ , bulk_access_exec_bitmap(NULL)
+#endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ , handler_close(FALSE)
+#endif
+ , mr_init(FALSE)
+{
+ DBUG_ENTER("ha_vp::ha_vp");
+ DBUG_PRINT("info",("vp this=%p", this));
+ share = NULL;
+ part_tables = NULL;
+ use_tables = NULL;
+ work_bitmap = NULL;
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ allocated_top_table_fields = 0;
+#endif
+ additional_table_flags = vp_base_table_flags;
+ ins_child_bitmaps[0] = NULL;
+ condition = NULL;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_handler_share = NULL;
+ pt_handler_share_creator = NULL;
+ clone_partition_handler_share = NULL;
+#endif
+ is_clone = FALSE;
+ pt_clone_source_handler = NULL;
+ ref_length = 0;
+ ft_first = NULL;
+ ft_current = NULL;
+ ft_inited = FALSE;
+ ft_count = 0;
+#if MYSQL_VERSION_ID < 50500
+#else
+ children_l = NULL;
+ children_attached = FALSE;
+#endif
+ suppress_autoinc = FALSE;
+ use_pre_call = FALSE;
+#ifdef VP_SUPPORT_MRR
+ m_mrr_range_first = NULL;
+ m_child_mrr_range_first = NULL;
+ m_range_info = NULL;
+ m_mrr_full_buffer = NULL;
+ m_mrr_full_buffer_size = 0;
+ m_mrr_new_full_buffer_size = 0;
+#endif
+ DBUG_VOID_RETURN;
+}
+
+static const char *ha_vp_exts[] = {
+ NullS
+};
+
+handler *ha_vp::clone(
+ const char *name,
+ MEM_ROOT *mem_root
+) {
+ ha_vp *vp;
+ DBUG_ENTER("ha_vp::clone");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (
+ !(vp = (ha_vp *)
+ get_new_handler(table->s, mem_root, vp_hton_ptr)) ||
+ !(vp->ref = (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length) * 2))
+ )
+ DBUG_RETURN(NULL);
+ vp->is_clone = TRUE;
+ vp->pt_clone_source_handler = this;
+ if (vp->ha_open(table, name, table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
+ DBUG_RETURN(NULL);
+
+ DBUG_RETURN((handler *) vp);
+}
+
+const char **ha_vp::bas_ext() const
+{
+ return ha_vp_exts;
+}
+
+int ha_vp::open(
+ const char* name,
+ int mode,
+ uint test_if_locked
+) {
+ int error_num, roop_count;
+ THD *thd = ha_thd();
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_SHARE *partition_share;
+ my_bitmap_map *tmp_idx_read_bitmap, *tmp_idx_write_bitmap,
+ *tmp_rnd_read_bitmap, *tmp_rnd_write_bitmap,
+ *tmp_idx_init_read_bitmap, *tmp_idx_init_write_bitmap,
+ *tmp_rnd_init_read_bitmap, *tmp_rnd_init_write_bitmap;
+ uint part_num;
+ bool create_pt_handler_share = FALSE, pt_handler_mutex = FALSE,
+ may_be_clone = FALSE;
+ ha_vp **pt_handler_share_handlers;
+#endif
+ TABLE *clone_tables = NULL;
+#ifndef DBUG_OFF
+ TABLE *tmp_table;
+#endif
+ DBUG_ENTER("ha_vp::open");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ table_lock_count = 0;
+ bitmap_map_size =
+ sizeof(my_bitmap_map) * ((table_share->fields +
+ sizeof(my_bitmap_map) * 8 - 1) / sizeof(my_bitmap_map) / 8);
+ DBUG_PRINT("info",("vp bitmap_map_size=%d", bitmap_map_size));
+ sql_command = thd_sql_command(thd);
+ DBUG_PRINT("info",("vp sql_command=%u", sql_command));
+ ref_buf = NULL;
+ ref_buf_length = 0;
+ VP_INIT_ALLOC_ROOT(&mr, 1024, 0, MYF(MY_WME));
+
+ if (!vp_get_share(name, table, thd, this, &error_num))
+ goto error_get_share;
+ thr_lock_data_init(&share->lock, &lock, NULL);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_share = share->partition_share;
+ table->file->get_no_parts("", &part_num);
+ if (partition_share)
+ {
+ pt_handler_mutex = TRUE;
+ pthread_mutex_lock(&partition_share->pt_handler_mutex);
+/*
+ if (
+ !partition_share->partition_handler_share ||
+ partition_share->partition_handler_share->table != table
+ )
+ create_pt_handler_share = TRUE;
+*/
+ if (
+ sql_command == SQLCOM_ALTER_TABLE ||
+ !(partition_handler_share = (VP_PARTITION_HANDLER_SHARE*)
+ my_hash_search(&partition_share->pt_handler_hash, (uchar*) &table,
+ sizeof(TABLE *)))
+ )
+ create_pt_handler_share = TRUE;
+ }
+
+#if MYSQL_VERSION_ID < 50500
+#else
+ init_correspond_columns = FALSE;
+#endif
+ if (create_pt_handler_share)
+ {
+ if (!(part_tables = (TABLE_LIST*)
+ my_multi_malloc(MYF(MY_WME),
+ &part_tables, sizeof(TABLE_LIST) * share->table_count,
+#if MYSQL_VERSION_ID < 50500
+#else
+ &children_info, sizeof(VP_CHILD_INFO) * share->table_count,
+#endif
+ &use_tables, sizeof(uchar) * share->use_tables_size,
+ &use_tables2, sizeof(uchar) * share->use_tables_size,
+ &use_tables3, sizeof(uchar) * share->use_tables_size,
+ &sel_key_init_use_tables, sizeof(uchar) * share->use_tables_size,
+ &sel_key_use_tables, sizeof(uchar) * share->use_tables_size,
+ &sel_rnd_use_tables, sizeof(uchar) * share->use_tables_size,
+ &upd_target_tables, sizeof(uchar) * share->use_tables_size,
+ &key_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &rnd_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &ft_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &select_ignore, sizeof(uchar) * share->use_tables_size,
+ &select_ignore_with_lock, sizeof(uchar) * share->use_tables_size,
+ &update_ignore, sizeof(uchar) * share->use_tables_size,
+ &pruned_tables, sizeof(uchar) * share->use_tables_size,
+#ifdef HA_CAN_BULK_ACCESS
+ &bulk_access_exec_bitmap, sizeof(uchar) * share->use_tables_size,
+#endif
+ &work_bitmap, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap2, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap3, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap4, sizeof(uchar) * ((table_share->fields + 7) / 8),
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ &top_table_field_for_childs, sizeof(Field **) * share->table_count,
+#endif
+#ifndef WITHOUT_VP_BG_ACCESS
+ &bg_base, sizeof(VP_BG_BASE) * share->table_count,
+#endif
+ &child_cond_count, sizeof(uint) * share->table_count,
+ &child_record0, sizeof(uchar *) * share->table_count,
+ &child_record1, sizeof(uchar *) * share->table_count,
+ &idx_init_read_bitmap, bitmap_map_size,
+ &idx_init_write_bitmap, bitmap_map_size,
+ &rnd_init_read_bitmap, bitmap_map_size,
+ &rnd_init_write_bitmap, bitmap_map_size,
+ &idx_read_bitmap, bitmap_map_size,
+ &idx_write_bitmap, bitmap_map_size,
+ &rnd_read_bitmap, bitmap_map_size,
+ &rnd_write_bitmap, bitmap_map_size,
+ &partition_handler_share, sizeof(VP_PARTITION_HANDLER_SHARE),
+ &tmp_idx_init_read_bitmap, bitmap_map_size,
+ &tmp_idx_init_write_bitmap, bitmap_map_size,
+ &tmp_rnd_init_read_bitmap, bitmap_map_size,
+ &tmp_rnd_init_write_bitmap, bitmap_map_size,
+ &rnd_init_write_bitmap, bitmap_map_size,
+ &tmp_idx_read_bitmap, bitmap_map_size,
+ &tmp_idx_write_bitmap, bitmap_map_size,
+ &tmp_rnd_read_bitmap, bitmap_map_size,
+ &tmp_rnd_write_bitmap, bitmap_map_size,
+#if defined(HAVE_HANDLERSOCKET)
+ &child_multi_range, sizeof(KEY_MULTI_RANGE) * share->table_count,
+ &child_key_buff, MAX_KEY_LENGTH * share->table_count,
+#endif
+#ifdef VP_SUPPORT_MRR
+ &m_range_info, sizeof(range_id_t) * share->table_count,
+ &m_stock_range_seq, sizeof(uint) * share->table_count,
+ &m_mrr_buffer, sizeof(HANDLER_BUFFER) * share->table_count,
+ &m_mrr_buffer_size, sizeof(uint) * share->table_count,
+ &m_child_mrr_range_length, sizeof(uint) * share->table_count,
+ &m_child_mrr_range_first,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE *) * share->table_count,
+ &m_child_mrr_range_current,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE *) * share->table_count,
+ &m_child_key_multi_range_hld,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE_HLD) * share->table_count,
+#endif
+ &pt_handler_share_handlers, sizeof(ha_vp *) * part_num,
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_tables_alloc;
+ }
+ DBUG_PRINT("info",("vp create partition_handler_share"));
+ partition_handler_share->use_count = 1;
+/*
+ if (partition_handler_share->use_count < part_num)
+ partition_share->partition_handler_share = partition_handler_share;
+*/
+ DBUG_PRINT("info",("vp table=%p", table));
+ partition_handler_share->table = table;
+ partition_handler_share->idx_init_read_bitmap = tmp_idx_init_read_bitmap;
+ partition_handler_share->idx_init_write_bitmap = tmp_idx_init_write_bitmap;
+ partition_handler_share->rnd_init_read_bitmap = tmp_rnd_init_read_bitmap;
+ partition_handler_share->rnd_init_write_bitmap = tmp_rnd_init_write_bitmap;
+ partition_handler_share->idx_read_bitmap = tmp_idx_read_bitmap;
+ partition_handler_share->idx_write_bitmap = tmp_idx_write_bitmap;
+ partition_handler_share->rnd_read_bitmap = tmp_rnd_read_bitmap;
+ partition_handler_share->rnd_write_bitmap = tmp_rnd_write_bitmap;
+ partition_handler_share->idx_init_flg = FALSE;
+ partition_handler_share->rnd_init_flg = FALSE;
+ partition_handler_share->idx_bitmap_is_set = FALSE;
+ partition_handler_share->rnd_bitmap_is_set = FALSE;
+ partition_handler_share->creator = this;
+ if (part_num)
+ {
+ partition_handler_share->handlers = (void **) pt_handler_share_handlers;
+ partition_handler_share->handlers[0] = this;
+ }
+ pt_handler_share_creator = this;
+ if (my_hash_insert(&partition_share->pt_handler_hash,
+ (uchar*) partition_handler_share))
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_hash_insert;
+ }
+ pthread_mutex_unlock(&partition_share->pt_handler_mutex);
+ pt_handler_mutex = FALSE;
+ } else {
+#endif
+ if (!(part_tables = (TABLE_LIST*)
+ my_multi_malloc(MYF(MY_WME),
+ &part_tables, sizeof(TABLE_LIST) * share->table_count,
+#if MYSQL_VERSION_ID < 50500
+#else
+ &children_info, sizeof(VP_CHILD_INFO) * share->table_count,
+#endif
+ &use_tables, sizeof(uchar) * share->use_tables_size,
+ &use_tables2, sizeof(uchar) * share->use_tables_size,
+ &use_tables3, sizeof(uchar) * share->use_tables_size,
+ &sel_key_init_use_tables, sizeof(uchar) * share->use_tables_size,
+ &sel_key_use_tables, sizeof(uchar) * share->use_tables_size,
+ &sel_rnd_use_tables, sizeof(uchar) * share->use_tables_size,
+ &upd_target_tables, sizeof(uchar) * share->use_tables_size,
+ &key_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &rnd_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &ft_inited_tables, sizeof(uchar) * share->use_tables_size,
+ &select_ignore, sizeof(uchar) * share->use_tables_size,
+ &select_ignore_with_lock, sizeof(uchar) * share->use_tables_size,
+ &update_ignore, sizeof(uchar) * share->use_tables_size,
+ &pruned_tables, sizeof(uchar) * share->use_tables_size,
+#ifdef HA_CAN_BULK_ACCESS
+ &bulk_access_exec_bitmap, sizeof(uchar) * share->use_tables_size,
+#endif
+ &work_bitmap, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap2, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap3, sizeof(uchar) * ((table_share->fields + 7) / 8),
+ &work_bitmap4, sizeof(uchar) * ((table_share->fields + 7) / 8),
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ &top_table_field_for_childs, sizeof(Field **) * share->table_count,
+#endif
+#ifndef WITHOUT_VP_BG_ACCESS
+ &bg_base, sizeof(VP_BG_BASE) * share->table_count,
+#endif
+ &child_cond_count, sizeof(uint) * share->table_count,
+ &child_record0, sizeof(uchar *) * share->table_count,
+ &child_record1, sizeof(uchar *) * share->table_count,
+ &idx_init_read_bitmap, bitmap_map_size,
+ &idx_init_write_bitmap, bitmap_map_size,
+ &rnd_init_read_bitmap, bitmap_map_size,
+ &rnd_init_write_bitmap, bitmap_map_size,
+ &idx_read_bitmap, bitmap_map_size,
+ &idx_write_bitmap, bitmap_map_size,
+ &rnd_read_bitmap, bitmap_map_size,
+ &rnd_write_bitmap, bitmap_map_size,
+#if defined(HAVE_HANDLERSOCKET)
+ &child_multi_range, sizeof(KEY_MULTI_RANGE) * share->table_count,
+ &child_key_buff, MAX_KEY_LENGTH * share->table_count,
+#endif
+#ifdef VP_SUPPORT_MRR
+ &m_range_info, sizeof(range_id_t) * share->table_count,
+ &m_stock_range_seq, sizeof(uint) * share->table_count,
+ &m_mrr_buffer, sizeof(HANDLER_BUFFER) * share->table_count,
+ &m_mrr_buffer_size, sizeof(uint) * share->table_count,
+ &m_child_mrr_range_length, sizeof(uint) * share->table_count,
+ &m_child_mrr_range_first,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE *) * share->table_count,
+ &m_child_mrr_range_current,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE *) * share->table_count,
+ &m_child_key_multi_range_hld,
+ sizeof(VP_CHILD_KEY_MULTI_RANGE_HLD) * share->table_count,
+#endif
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_tables_alloc;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_share)
+ {
+ DBUG_PRINT("info",("vp copy partition_handler_share"));
+/*
+ partition_handler_share = (VP_PARTITION_HANDLER_SHARE *)
+ partition_share->partition_handler_share;
+*/
+ if (part_num)
+ {
+ if (partition_handler_share->use_count >= part_num)
+ may_be_clone = TRUE;
+ else {
+ partition_handler_share->handlers[
+ partition_handler_share->use_count] = this;
+ partition_handler_share->use_count++;
+ }
+ }
+/*
+ if (partition_handler_share->use_count == part_num)
+ partition_share->partition_handler_share = NULL;
+*/
+ pthread_mutex_unlock(&partition_share->pt_handler_mutex);
+ pt_handler_mutex = FALSE;
+ }
+ }
+#endif
+ memcpy(part_tables, share->part_tables,
+ sizeof(TABLE_LIST) * share->table_count);
+ memcpy(select_ignore, share->select_ignore,
+ sizeof(uchar) * share->use_tables_size);
+ memcpy(select_ignore_with_lock, share->select_ignore_with_lock,
+ sizeof(uchar) * share->use_tables_size);
+ memset((uchar *) update_ignore, 0,
+ sizeof(uchar) * share->use_tables_size);
+#ifdef HA_CAN_BULK_ACCESS
+ memset(bulk_access_exec_bitmap, 0, sizeof(uchar) * share->use_tables_size);
+#endif
+ memset(idx_read_bitmap, 0, bitmap_map_size);
+ memset(idx_write_bitmap, 0, bitmap_map_size);
+ memset(rnd_read_bitmap, 0, bitmap_map_size);
+ memset(rnd_write_bitmap, 0, bitmap_map_size);
+#ifdef VP_SUPPORT_MRR
+ bzero(m_mrr_buffer, share->table_count * sizeof(HANDLER_BUFFER));
+ bzero(m_child_mrr_range_first,
+ share->table_count * sizeof(VP_CHILD_KEY_MULTI_RANGE *));
+#endif
+
+#if MYSQL_VERSION_ID < 50500
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ /* for table partitioning */
+ if (table->child_l)
+ *(table->child_last_l) = part_tables;
+#endif
+#endif
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+#if MYSQL_VERSION_ID < 50500
+ part_tables[roop_count].lock_type = (thr_lock_type) mode;
+ if (roop_count < share->table_count - 1)
+ part_tables[roop_count].next_global = &part_tables[roop_count + 1];
+#endif
+ part_tables[roop_count].parent_l = NULL;
+#ifndef WITHOUT_VP_BG_ACCESS
+ bg_base[roop_count].table_idx = roop_count;
+ bg_base[roop_count].part_table = &part_tables[roop_count];
+ bg_base[roop_count].parent = this;
+ bg_base[roop_count].bg_init = FALSE;
+ bg_base[roop_count].bg_caller_sync_wait = FALSE;
+#endif
+ }
+
+#if MYSQL_VERSION_ID < 50500
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ /* for table partitioning */
+ if (!table->child_l)
+#endif
+ table->child_l = part_tables;
+
+ table->child_last_l = &part_tables[share->table_count - 1].next_global;
+#else
+ children_l = part_tables;
+ children_last_l = &part_tables[share->table_count - 1].next_global;
+#endif
+
+ DBUG_PRINT("info",("vp blob_fields=%d", table_share->blob_fields));
+ if (table_share->blob_fields)
+ {
+ if (!(blob_buff = new (&mr) String[table_share->fields]))
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_init_blob_buff;
+ }
+ for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++)
+ blob_buff[roop_count].set_charset(table->field[roop_count]->charset());
+ }
+
+ child_table_idx = share->table_count;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (may_be_clone)
+ is_clone = TRUE;
+#endif
+ if (is_clone)
+ {
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (part_num)
+ {
+ for (roop_count = 0; roop_count < (int) part_num; roop_count++)
+ {
+ if (((ha_vp *) partition_handler_share->handlers[roop_count])->share ==
+ share)
+ {
+ pt_clone_source_handler =
+ (ha_vp *) partition_handler_share->handlers[roop_count];
+ break;
+ }
+ }
+ }
+#endif
+
+ sql_command = pt_clone_source_handler->sql_command;
+ lock_type_sto = pt_clone_source_handler->lock_type_sto;
+ lock_mode = pt_clone_source_handler->lock_mode;
+ update_request = pt_clone_source_handler->update_request;
+
+ pt_clone_source_handler->init_select_column(FALSE);
+ clone_init_select_column();
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (
+ partition_handler_share->clone_partition_handler_share &&
+ partition_handler_share->clone_partition_handler_share->use_count <
+ part_num
+ ) {
+ clone_partition_handler_share =
+ partition_handler_share->clone_partition_handler_share;
+ clone_partition_handler_share->handlers[
+ clone_partition_handler_share->use_count] = this;
+ clone_partition_handler_share->use_count++;
+#endif
+ if (!(clone_tables = (TABLE *)
+ my_multi_malloc(MYF(MY_WME),
+ &clone_tables, sizeof(TABLE) * share->table_count,
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_clone_tables_alloc;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ } else {
+ if (!(clone_tables = (TABLE *)
+ my_multi_malloc(MYF(MY_WME),
+ &clone_tables, sizeof(TABLE) * share->table_count,
+ &clone_partition_handler_share,
+ sizeof(VP_CLONE_PARTITION_HANDLER_SHARE),
+ &pt_handler_share_handlers, sizeof(ha_vp *) * part_num,
+ &tmp_idx_read_bitmap, bitmap_map_size,
+ &tmp_idx_write_bitmap, bitmap_map_size,
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_clone_tables_alloc;
+ }
+ clone_partition_handler_share->use_count = 1;
+ clone_partition_handler_share->handlers =
+ (void **) pt_handler_share_handlers;
+ clone_partition_handler_share->idx_read_bitmap = tmp_idx_read_bitmap;
+ clone_partition_handler_share->idx_write_bitmap = tmp_idx_write_bitmap;
+ clone_partition_handler_share->idx_bitmap_is_set = FALSE;
+ clone_partition_handler_share->handlers[0] = this;
+ partition_handler_share->clone_partition_handler_share =
+ clone_partition_handler_share;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].table =
+ pt_clone_source_handler->part_tables[roop_count].table;
+ clear_child_bitmap(roop_count);
+ set_child_bitmap((uchar *) idx_init_write_bitmap, roop_count, TRUE);
+ set_child_bitmap((uchar *) idx_init_read_bitmap, roop_count, FALSE);
+
+ part_tables[roop_count].table = &clone_tables[roop_count];
+ memcpy(part_tables[roop_count].table,
+ pt_clone_source_handler->part_tables[roop_count].table, sizeof(TABLE));
+ if (!(part_tables[roop_count].table->file = pt_clone_source_handler->
+ part_tables[roop_count].table->file->clone(
+ part_tables[roop_count].table->s->normalized_path.str,
+ thd->mem_root)))
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_clone;
+ }
+ }
+
+ table_lock_count = pt_clone_source_handler->table_lock_count;
+ child_ref_length = pt_clone_source_handler->child_ref_length;
+ ref_length = (child_ref_length * share->table_count) +
+ sizeof(ha_vp *) +
+ table->key_info[table_share->primary_key].key_length;
+ additional_table_flags = pt_clone_source_handler->additional_table_flags;
+
+ ins_child_bitmaps[0] = pt_clone_source_handler->ins_child_bitmaps[0];
+ ins_child_bitmaps[1] = pt_clone_source_handler->ins_child_bitmaps[1];
+ upd_child_bitmaps[0] = pt_clone_source_handler->upd_child_bitmaps[0];
+ upd_child_bitmaps[1] = pt_clone_source_handler->upd_child_bitmaps[1];
+ del_child_bitmaps[0] = pt_clone_source_handler->del_child_bitmaps[0];
+ del_child_bitmaps[1] = pt_clone_source_handler->del_child_bitmaps[1];
+ add_from_child_bitmaps[0] =
+ pt_clone_source_handler->add_from_child_bitmaps[0];
+ add_from_child_bitmaps[1] =
+ pt_clone_source_handler->add_from_child_bitmaps[1];
+ sel_key_init_child_bitmaps[0] =
+ pt_clone_source_handler->sel_key_init_child_bitmaps[0];
+ sel_key_init_child_bitmaps[1] =
+ pt_clone_source_handler->sel_key_init_child_bitmaps[1];
+ sel_key_child_bitmaps[0] =
+ pt_clone_source_handler->sel_key_child_bitmaps[0];
+ sel_key_child_bitmaps[1] =
+ pt_clone_source_handler->sel_key_child_bitmaps[1];
+ sel_rnd_child_bitmaps[0] =
+ pt_clone_source_handler->sel_rnd_child_bitmaps[0];
+ sel_rnd_child_bitmaps[1] =
+ pt_clone_source_handler->sel_rnd_child_bitmaps[1];
+
+ cached_table_flags = table_flags();
+ }
+ if (reset())
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error;
+ }
+#ifndef DBUG_OFF
+ tmp_table = thd->open_tables;
+ while (tmp_table)
+ {
+ DBUG_PRINT("info",("vp tmp_table=%p", tmp_table));
+ DBUG_PRINT("info",("vp tmp_table->file=%p", tmp_table->file));
+ if (tmp_table->file)
+ DBUG_PRINT("info",("vp tmp_table->file->inited=%x",
+ tmp_table->file->inited));
+ tmp_table = tmp_table->next;
+ }
+#endif
+ child_multi_range_first = NULL;
+
+ DBUG_RETURN(0);
+
+error:
+error_clone:
+ if (clone_tables)
+ vp_my_free(clone_tables, MYF(0));
+error_clone_tables_alloc:
+error_init_blob_buff:
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (
+ partition_handler_share &&
+ pt_handler_share_creator == this
+ ) {
+ partition_share = share->partition_share;
+ if (!pt_handler_mutex)
+ pthread_mutex_lock(&partition_share->pt_handler_mutex);
+/*
+ if (partition_share->partition_handler_share == partition_handler_share)
+ partition_share->partition_handler_share = NULL;
+*/
+ my_hash_delete(&partition_share->pt_handler_hash,
+ (uchar*) partition_handler_share);
+ pthread_mutex_unlock(&partition_share->pt_handler_mutex);
+ pt_handler_mutex = FALSE;
+ }
+error_hash_insert:
+ partition_handler_share = NULL;
+ pt_handler_share_creator = NULL;
+#endif
+ vp_my_free(part_tables, MYF(0));
+ part_tables = NULL;
+#ifdef VP_SUPPORT_MRR
+ m_range_info = NULL;
+#endif
+error_tables_alloc:
+ if (pt_handler_mutex)
+ pthread_mutex_unlock(&partition_share->pt_handler_mutex);
+ vp_free_share(share);
+ share = NULL;
+error_get_share:
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::close()
+{
+#ifndef WITHOUT_VP_BG_ACCESS
+ int roop_count;
+ VP_BG_BASE *base;
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_SHARE *partition_share;
+#endif
+ DBUG_ENTER("ha_vp::close");
+ DBUG_PRINT("info",("vp this=%p", this));
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_info_first)
+ {
+ do {
+ bulk_access_info_current = bulk_access_info_first->next;
+ delete_bulk_access_info(bulk_access_info_first);
+ bulk_access_info_first = bulk_access_info_current;
+ } while (bulk_access_info_first);
+ }
+#endif
+#ifdef VP_SUPPORT_MRR
+ int i;
+ if (m_child_mrr_range_first)
+ {
+ for (i = 0; i < share->table_count; i++)
+ {
+ if (m_child_mrr_range_first[i])
+ {
+ VP_CHILD_KEY_MULTI_RANGE *tmp_mrr_range_first =
+ m_child_mrr_range_first[i];
+ VP_CHILD_KEY_MULTI_RANGE *tmp_mrr_range_current;
+ do {
+ tmp_mrr_range_current = tmp_mrr_range_first;
+ tmp_mrr_range_first = tmp_mrr_range_first->next;
+ vp_my_free(tmp_mrr_range_current, MYF(0));
+ } while (tmp_mrr_range_first);
+ }
+ }
+ m_child_mrr_range_first = NULL;
+ }
+ if (m_mrr_range_first)
+ {
+ do {
+ m_mrr_range_current = m_mrr_range_first;
+ m_mrr_range_first = m_mrr_range_first->next;
+ if (m_mrr_range_current->key[0])
+ vp_my_free(m_mrr_range_current->key[0], MYF(0));
+ if (m_mrr_range_current->key[1])
+ vp_my_free(m_mrr_range_current->key[1], MYF(0));
+ vp_my_free(m_mrr_range_current, MYF(0));
+ } while (m_mrr_range_first);
+ }
+ if (m_mrr_full_buffer)
+ {
+ vp_my_free(m_mrr_full_buffer, MYF(0));
+ m_mrr_full_buffer = NULL;
+ m_mrr_full_buffer_size = 0;
+ }
+#endif
+ if (is_clone)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+#ifdef VP_HANDLER_HAS_HA_CLOSE
+ part_tables[roop_count].table->file->ha_close();
+#else
+ part_tables[roop_count].table->file->close();
+#endif
+ }
+ vp_my_free(part_tables[0].table, MYF(0));
+ }
+
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ base = &bg_base[roop_count];
+ free_bg_thread(base);
+ }
+#endif
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ if (allocated_top_table_fields)
+ {
+ vp_my_free(top_table_field_for_childs[0], MYF(0));
+ allocated_top_table_fields = 0;
+ }
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (
+ partition_handler_share &&
+ pt_handler_share_creator == this
+ ) {
+ partition_share = share->partition_share;
+ pthread_mutex_lock(&partition_share->pt_handler_mutex);
+/*
+ if (partition_share->partition_handler_share == partition_handler_share)
+ partition_share->partition_handler_share = NULL;
+*/
+ my_hash_delete(&partition_share->pt_handler_hash,
+ (uchar*) partition_handler_share);
+ pthread_mutex_unlock(&partition_share->pt_handler_mutex);
+ }
+ partition_handler_share = NULL;
+ pt_handler_share_creator = NULL;
+ clone_partition_handler_share = NULL;
+#endif
+ if (part_tables)
+ {
+ vp_my_free(part_tables, MYF(0));
+ part_tables = NULL;
+#ifdef VP_SUPPORT_MRR
+ m_range_info = NULL;
+#endif
+ }
+ if (ref_buf)
+ {
+ vp_my_free(ref_buf, MYF(0));
+ ref_buf = NULL;
+ }
+ if (share)
+ {
+ vp_free_share(share);
+ share = NULL;
+ }
+#if MYSQL_VERSION_ID < 50500
+ table->child_l = NULL;
+#else
+ children_l = NULL;
+#endif
+ if (!is_clone)
+ free_child_bitmap_buff();
+ is_clone = FALSE;
+ pt_clone_source_handler = NULL;
+ while (ft_first)
+ {
+ ft_current = ft_first;
+ ft_first = ft_current->next;
+ vp_my_free(ft_current, MYF(0));
+ }
+ ft_current = NULL;
+ if (child_multi_range_first)
+ {
+ vp_my_free(child_multi_range_first, MYF(0));
+ child_multi_range_first = NULL;
+ }
+ if (mr_init)
+ {
+ free_root(&mr, MYF(0));
+ mr_init = FALSE;
+ }
+ DBUG_RETURN(0);
+}
+
+uint ha_vp::lock_count() const
+{
+ DBUG_ENTER("ha_vp::lock_count");
+#if MYSQL_VERSION_ID < 50500
+ DBUG_RETURN(table_lock_count);
+#else
+ if (
+ thd_sql_command(ha_thd()) == SQLCOM_HA_OPEN ||
+ thd_sql_command(ha_thd()) == SQLCOM_HA_READ
+ ) {
+ DBUG_PRINT("info",("vp table_lock_count=%u", table_lock_count));
+ DBUG_RETURN(table_lock_count);
+ }
+ DBUG_RETURN(0);
+#endif
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::additional_lock(
+ THD *thd,
+ enum thr_lock_type lock_type
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::additional_lock");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->additional_lock(thd,
+ lock_type)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+#endif
+
+THR_LOCK_DATA **ha_vp::store_lock(
+ THD *thd,
+ THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type
+) {
+ int roop_count;
+ DBUG_ENTER("ha_vp::store_lock");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ sql_command = thd_sql_command(thd);
+ DBUG_PRINT("info",("vp sql_command=%u", sql_command));
+ lock_type_sto = lock_type;
+ DBUG_PRINT("info",("vp lock_type=%u", lock_type));
+ switch (sql_command)
+ {
+ case SQLCOM_SELECT:
+ if (lock_type == TL_READ_WITH_SHARED_LOCKS)
+ lock_mode = 1;
+ else if (lock_type <= TL_READ_NO_INSERT)
+ lock_mode = 0;
+ else
+ lock_mode = -1;
+ break;
+ case SQLCOM_CREATE_TABLE:
+ case SQLCOM_UPDATE:
+ case SQLCOM_INSERT:
+ case SQLCOM_INSERT_SELECT:
+ case SQLCOM_DELETE:
+ case SQLCOM_LOAD:
+ case SQLCOM_REPLACE:
+ case SQLCOM_REPLACE_SELECT:
+ case SQLCOM_DELETE_MULTI:
+ case SQLCOM_UPDATE_MULTI:
+ if (lock_type >= TL_READ && lock_type <= TL_READ_NO_INSERT)
+ lock_mode = 1;
+ else
+ lock_mode = -1;
+ break;
+ default:
+ lock_mode = -1;
+ break;
+ }
+#if MYSQL_VERSION_ID < 50500
+#else
+ if (sql_command == SQLCOM_HA_OPEN || sql_command == SQLCOM_HA_READ)
+ {
+#endif
+ if (table_lock_count > 0)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ to = part_tables[roop_count].table->file->store_lock(thd, to,
+ lock_type);
+ DBUG_PRINT("info",("vp lock->type=%u", to ? (*(to - 1))->type : 0));
+ }
+ }
+#if MYSQL_VERSION_ID < 50500
+#else
+ }
+#endif
+ DBUG_RETURN(to);
+}
+
+int ha_vp::external_lock(
+ THD *thd,
+ int lock_type
+) {
+ int error_num, error_num2, roop_count;
+ DBUG_ENTER("ha_vp::external_lock");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ DBUG_PRINT("info",("vp lock_type=%x", lock_type));
+ sql_command = thd_sql_command(thd);
+ if (
+ /* SQLCOM_RENAME_TABLE and SQLCOM_DROP_DB don't come here */
+ sql_command == SQLCOM_DROP_TABLE ||
+ sql_command == SQLCOM_ALTER_TABLE
+ ) {
+ if (store_error_num)
+ DBUG_RETURN(store_error_num);
+ DBUG_RETURN(0);
+ }
+#if MYSQL_VERSION_ID < 50500
+ DBUG_PRINT("info",("vp thd->options=%x", (int) thd->options));
+ if (table_lock_count == 0)
+#else
+ if (!children_attached && !is_clone && lock_type != F_UNLCK)
+#endif
+ {
+ my_error(ER_WRONG_OBJECT, MYF(0), table->s->db.str,
+ table->s->table_name.str, "BASE TABLE");
+ DBUG_RETURN(ER_WRONG_OBJECT);
+ }
+ if (store_error_num)
+ DBUG_RETURN(store_error_num);
+
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ if (
+ !set_top_table_fields &&
+ (error_num = set_top_table_and_fields(table, table->field,
+ table_share->fields, TRUE))
+ )
+ DBUG_RETURN(error_num);
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->
+ set_top_table_and_fields(
+ top_table,
+ top_table_field_for_childs[roop_count],
+ top_table_fields)))
+ DBUG_RETURN(error_num);
+ }
+#endif
+
+ lock_type_ext = lock_type;
+ if (lock_type == F_WRLCK)
+ update_request = TRUE;
+ else
+ update_request = FALSE;
+ error_num = 0;
+#if MYSQL_VERSION_ID < 50500
+#else
+ if (
+ is_clone ||
+ sql_command == SQLCOM_HA_READ
+ ) {
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_external_lock(thd, lock_type)))
+ {
+ if (lock_type != F_UNLCK)
+ goto error_external_lock;
+ else
+ error_num = error_num2;
+ }
+ }
+#if MYSQL_VERSION_ID < 50500
+#else
+ }
+#endif
+ DBUG_RETURN(error_num);
+
+error_external_lock:
+#if MYSQL_VERSION_ID < 50500
+#else
+ if (
+ is_clone ||
+ sql_command == SQLCOM_HA_READ
+ ) {
+#endif
+ while (roop_count)
+ {
+ roop_count--;
+ part_tables[roop_count].table->file->ha_external_lock(thd, F_UNLCK);
+ }
+#if MYSQL_VERSION_ID < 50500
+#else
+ }
+#endif
+ DBUG_RETURN(error_num2);
+}
+
+int ha_vp::reset()
+{
+ int error_num, error_num2, roop_count;
+ VP_CONDITION *tmp_cond;
+ DBUG_ENTER("ha_vp::reset");
+ DBUG_PRINT("info",("vp this=%p", this));
+ bulk_insert = FALSE;
+ init_sel_key_init_bitmap = FALSE;
+ init_sel_key_bitmap = FALSE;
+ init_sel_rnd_bitmap = FALSE;
+ init_ins_bitmap = FALSE;
+ init_upd_bitmap = FALSE;
+ init_del_bitmap = FALSE;
+ cb_state = CB_NO_SET;
+ child_keyread = FALSE;
+#ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
+ extra_use_cmp_ref = FALSE;
+#else
+ extra_use_cmp_ref = TRUE;
+#endif
+ rnd_scan = FALSE;
+ child_table_idx = 0;
+ error_num = 0;
+ store_error_num = 0;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share)
+ {
+ if (!is_clone)
+ {
+ partition_handler_share->idx_init_flg = FALSE;
+ partition_handler_share->clone_partition_handler_share = NULL;
+ } else
+ clone_partition_handler_share->idx_bitmap_is_set = FALSE;
+ partition_handler_share->rnd_init_flg = FALSE;
+ partition_handler_share->idx_bitmap_is_set = FALSE;
+ partition_handler_share->rnd_bitmap_is_set = FALSE;
+ }
+#endif
+ if (!is_clone)
+ idx_bitmap_init_flg = FALSE;
+ rnd_bitmap_init_flg = FALSE;
+ idx_bitmap_is_set = FALSE;
+ rnd_bitmap_is_set = FALSE;
+#if MYSQL_VERSION_ID < 50500
+ if (table->children_attached || is_clone)
+#else
+ if (children_attached || is_clone)
+#endif
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num2 = part_tables[roop_count].table->file->ha_reset()))
+ error_num = error_num2;
+ }
+ }
+ while (condition)
+ {
+ tmp_cond = condition->next;
+ vp_my_free(condition, MYF(0));
+ condition = tmp_cond;
+ }
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ ft_current = NULL;
+ ft_inited = FALSE;
+ ft_count = 0;
+ use_pre_call = FALSE;
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_info_first)
+ {
+ VP_BULK_ACCESS_INFO *bulk_access_info = bulk_access_info_first;
+ while (
+ bulk_access_info &&
+ bulk_access_info->used
+ ) {
+ bulk_access_info->idx_bitmap_init_flg = FALSE;
+ bulk_access_info->rnd_bitmap_init_flg = FALSE;
+ bulk_access_info->idx_bitmap_is_set = FALSE;
+ bulk_access_info->rnd_bitmap_is_set = FALSE;
+ bulk_access_info->child_keyread = FALSE;
+ bulk_access_info->single_table = FALSE;
+ bulk_access_info->set_used_table = FALSE;
+ bulk_access_info->init_sel_key_init_bitmap = FALSE;
+ bulk_access_info->init_sel_key_bitmap = FALSE;
+ bulk_access_info->init_sel_rnd_bitmap = FALSE;
+ bulk_access_info->init_ins_bitmap = FALSE;
+ bulk_access_info->used = FALSE;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share && partition_handler_share->creator == this)
+ {
+ VP_PARTITION_HANDLER_SHARE *tmp_partition_handler_share =
+ bulk_access_info->partition_handler_share;
+ if (tmp_partition_handler_share)
+ {
+ tmp_partition_handler_share->idx_init_flg = FALSE;
+ tmp_partition_handler_share->rnd_init_flg = FALSE;
+ tmp_partition_handler_share->idx_bitmap_is_set = FALSE;
+ tmp_partition_handler_share->rnd_bitmap_is_set = FALSE;
+ }
+ VP_CLONE_PARTITION_HANDLER_SHARE *tmp_clone_partition_handler_share =
+ bulk_access_info->clone_partition_handler_share;
+ if (tmp_clone_partition_handler_share)
+ {
+ tmp_clone_partition_handler_share->idx_bitmap_is_set = FALSE;
+ }
+ }
+#endif
+ bulk_access_info = bulk_access_info->next;
+ }
+ memset(bulk_access_exec_bitmap, 0, sizeof(uchar) * share->use_tables_size);
+ }
+ bulk_access_started = FALSE;
+ bulk_access_executing = FALSE;
+ bulk_access_pre_called = FALSE;
+ bulk_access_info_current = NULL;
+ bulk_access_info_exec_tgt = NULL;
+#endif
+#ifdef VP_SUPPORT_MRR
+ m_mrr_new_full_buffer_size = 0;
+#endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ handler_close = FALSE;
+#endif
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::extra(
+ enum ha_extra_function operation
+) {
+ int error_num, error_num2, roop_count;
+ TABLE_LIST *part_table;
+ bool reinit;
+ longlong additional_table_flags_for_neg;
+#if MYSQL_VERSION_ID < 50500
+#else
+ THD *thd;
+ TABLE_LIST *tmp_table_list;
+#endif
+ DBUG_ENTER("ha_vp::extra");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp operation=%d", (int) operation));
+ switch (operation)
+ {
+ case HA_EXTRA_CACHE:
+ DBUG_PRINT("info",("vp HA_EXTRA_CACHE"));
+ if (child_table_idx < share->table_count)
+ {
+ if ((error_num =
+ part_tables[child_table_idx].table->file->extra(operation)))
+ DBUG_RETURN(error_num);
+ } else {
+ if ((error_num =
+ part_tables[0].table->file->extra(operation)))
+ DBUG_RETURN(error_num);
+ }
+ break;
+ case HA_EXTRA_KEYREAD:
+ DBUG_PRINT("info",("vp HA_EXTRA_KEYREAD"));
+ break;
+ case HA_EXTRA_NO_KEYREAD:
+ DBUG_PRINT("info",("vp HA_EXTRA_NO_KEYREAD"));
+ break;
+ case HA_EXTRA_ATTACH_CHILDREN:
+ DBUG_PRINT("info",("vp HA_EXTRA_ATTACH_CHILDREN"));
+ if (!is_clone)
+ {
+ reinit = FALSE;
+ table_lock_count = 0;
+ child_ref_length = 0;
+ key_used_on_scan = MAX_KEY;
+ additional_table_flags = vp_base_table_flags;
+ if (share->same_all_columns)
+ additional_table_flags_for_neg = 0;
+ else
+ additional_table_flags_for_neg = HA_PARTIAL_COLUMN_READ;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_table = &part_tables[roop_count];
+ DBUG_PRINT("info",("vp part_tables[%d].table=%p", roop_count,
+ part_table->table));
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ if (set_top_table_fields)
+ clear_top_table_fields();
+ part_table->table->file->clear_top_table_fields();
+#endif
+ if ((error_num = part_table->table->file->extra(operation)))
+ DBUG_RETURN(error_num);
+ DBUG_PRINT("info",("vp part_tables[%d] lock_count=%u", roop_count,
+ part_table->table->file->lock_count()));
+ table_lock_count += part_table->table->file->lock_count();
+ if (child_ref_length < part_table->table->file->ref_length)
+ {
+ child_ref_length = part_table->table->file->ref_length;
+ }
+#if MYSQL_VERSION_ID < 50500
+ if (part_table->get_child_def_version() !=
+ part_table->table->s->get_table_def_version())
+ {
+ reinit = TRUE;
+ part_table->set_child_def_version(
+ part_table->table->s->get_table_def_version());
+ }
+#else
+ DBUG_PRINT("info",("vp init=%s", share->init ? "TRUE" : "FALSE"));
+ if (!share->init ||
+ !init_correspond_columns ||
+ children_info[roop_count].child_table_ref_type !=
+ part_table->table->s->get_table_ref_type() ||
+ children_info[roop_count].child_def_version !=
+ part_table->table->s->get_table_def_version()
+ ) {
+ reinit = TRUE;
+ children_info[roop_count].child_table_ref_type =
+ part_table->table->s->get_table_ref_type();
+ children_info[roop_count].child_def_version =
+ part_table->table->s->get_table_def_version();
+ }
+#endif
+ additional_table_flags &=
+ part_table->table->file->ha_table_flags();
+ additional_table_flags_for_neg |=
+ (part_table->table->file->ha_table_flags() &
+ (HA_PARTIAL_COLUMN_READ | HA_PRIMARY_KEY_IN_READ_INDEX));
+ if (key_used_on_scan > part_table->table->file->key_used_on_scan)
+ key_used_on_scan = part_table->table->file->key_used_on_scan;
+ }
+ ref_length = (child_ref_length * share->table_count) +
+ sizeof(ha_vp *) +
+ table->key_info[table_share->primary_key].key_length;
+ if (ref_length > ref_buf_length)
+ {
+ if (ref_buf)
+ vp_my_free(ref_buf, MYF(0));
+ if (!(ref_buf =
+ (uchar*) my_malloc(ALIGN_SIZE(ref_length) * 2, MYF(MY_WME))))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ ref_buf_length = ref_length;
+ }
+ ref = ref_buf;
+ dup_ref = ref + ALIGN_SIZE(ref_length);
+ DBUG_PRINT("info",("vp ref_length=%u", ref_length));
+ additional_table_flags |= additional_table_flags_for_neg;
+ if (!share->init || reinit)
+ {
+ free_child_bitmap_buff();
+ if (
+ (error_num = create_child_bitmap_buff()) ||
+ (error_num =
+ vp_correspond_columns(this, table, share, table_share,
+ part_tables, reinit))
+ )
+ DBUG_RETURN(error_num);
+ }
+ cached_table_flags = table_flags();
+#if MYSQL_VERSION_ID < 50500
+#else
+ children_attached = TRUE;
+ init_correspond_columns = TRUE;
+#endif
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ TABLE *child_table = part_tables[roop_count].table;
+ bool done_already =
+ (child_table->record[0] == table->record[0]);
+ if (!done_already)
+ {
+ my_ptrdiff_t ptr_diff =
+ PTR_BYTE_DIFF(table->record[0], child_table->record[0]);
+ child_record0[roop_count] = child_table->record[0];
+ child_table->record[0] = table->record[0];
+ child_record1[roop_count] = child_table->record[1];
+ child_table->record[1] = table->record[1];
+ Field **field = child_table->field;
+ for (; *field; field++)
+ (*field)->move_field_offset(ptr_diff);
+ }
+ if ((error_num = child_table->file->
+ extra(HA_EXTRA_INIT_AFTER_ATTACH_CHILDREN))
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ if (
+ !table->pos_in_table_list->parent_l &&
+ (error_num =
+ info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST))
+ ) {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ TABLE *child_table = part_tables[roop_count].table;
+ bool done_already =
+ (child_table->record[0] == child_record0[roop_count]);
+ if (!done_already)
+ {
+ child_table->record[0] = child_record0[roop_count];
+ child_table->record[1] = child_record1[roop_count];
+ my_ptrdiff_t ptr_diff =
+ PTR_BYTE_DIFF(table->record[0], child_table->record[0]);
+ Field **field = child_table->field;
+ for (; *field; field++)
+ (*field)->move_field_offset(-ptr_diff);
+ }
+ }
+ }
+ DBUG_RETURN(error_num);
+ }
+ break;
+ case HA_EXTRA_DETACH_CHILDREN:
+ DBUG_PRINT("info",("vp HA_EXTRA_DETACH_CHILDREN"));
+#if MYSQL_VERSION_ID < 50500
+ if (table->children_attached)
+#else
+ if (children_attached)
+#endif
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ TABLE *child_table = part_tables[roop_count].table;
+ bool done_already =
+ (child_table->record[0] == child_record0[roop_count]);
+ if (!done_already)
+ {
+ child_table->record[0] = child_record0[roop_count];
+ child_table->record[1] = child_record1[roop_count];
+ my_ptrdiff_t ptr_diff =
+ PTR_BYTE_DIFF(table->record[0], child_table->record[0]);
+ Field **field = child_table->field;
+ for (; *field; field++)
+ (*field)->move_field_offset(-ptr_diff);
+ }
+ }
+ }
+ }
+#if MYSQL_VERSION_ID < 50500
+ if (table->children_attached && !is_clone)
+#else
+ if (children_attached && !is_clone)
+#endif
+ {
+ error_num = 0;
+ additional_table_flags = vp_base_table_flags;
+ cached_table_flags = table_flags();
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ TABLE *child_table = part_tables[roop_count].table;
+#if MYSQL_VERSION_ID < 50500
+#else
+ if (child_table)
+ {
+#endif
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ child_table->file->clear_top_table_fields();
+#endif
+ if ((error_num2 = child_table->file->extra(operation)))
+ error_num = error_num2;
+#if MYSQL_VERSION_ID < 50500
+#else
+ }
+#endif
+ }
+#if MYSQL_VERSION_ID < 50500
+ table->children_attached = FALSE;
+#else
+ children_attached = FALSE;
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ if (!handler_close)
+ {
+#endif
+ thd = ha_thd();
+ tmp_table_list = table->pos_in_table_list;
+ tmp_table_list->next_global = *children_last_l;
+ if (*children_last_l)
+ (*children_last_l)->prev_global = &tmp_table_list->next_global;
+ if (thd->lex->query_tables_last == children_last_l)
+ thd->lex->query_tables_last = &tmp_table_list->next_global;
+ if (thd->lex->query_tables_own_last == children_last_l)
+ thd->lex->query_tables_own_last = &tmp_table_list->next_global;
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ }
+#endif
+#endif
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ break;
+#if MYSQL_VERSION_ID < 50500
+#else
+ case HA_EXTRA_ADD_CHILDREN_LIST:
+ DBUG_PRINT("info",("vp HA_EXTRA_ADD_CHILDREN_LIST"));
+ thd = ha_thd();
+ tmp_table_list = table->pos_in_table_list;
+ DBUG_PRINT("info",("vp tmp_table_list=%p", tmp_table_list));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].parent_l = tmp_table_list;
+ if (roop_count == 0)
+ part_tables[roop_count].prev_global = &tmp_table_list->next_global;
+ else
+ part_tables[roop_count].prev_global =
+ &part_tables[roop_count - 1].next_global;
+ part_tables[roop_count].next_global = part_tables + roop_count + 1;
+ part_tables[roop_count].select_lex = tmp_table_list->select_lex;
+
+ part_tables[roop_count].table = NULL;
+ part_tables[roop_count].lock_type = tmp_table_list->lock_type;
+ part_tables[roop_count].mdl_request.init(
+ MDL_key::TABLE, VP_TABLE_LIST_db_str(&part_tables[roop_count]),
+ VP_TABLE_LIST_table_name_str(&part_tables[roop_count]),
+ (tmp_table_list->lock_type >= TL_WRITE_ALLOW_WRITE) ?
+ MDL_SHARED_WRITE : MDL_SHARED_READ,
+ MDL_TRANSACTION);
+
+ if (!thd->locked_tables_mode &&
+ tmp_table_list->mdl_request.type == MDL_SHARED_NO_WRITE)
+ part_tables[roop_count].mdl_request.set_type(MDL_SHARED_NO_WRITE);
+ }
+
+ if (tmp_table_list->next_global)
+ {
+ DBUG_PRINT("info",("vp parent->next_global=%p",
+ tmp_table_list->next_global));
+ tmp_table_list->next_global->prev_global = children_last_l;
+ }
+ *children_last_l = tmp_table_list->next_global;
+ tmp_table_list->next_global = part_tables;
+
+ if (thd->lex->query_tables_last == &tmp_table_list->next_global)
+ thd->lex->query_tables_last = children_last_l;
+ if (thd->lex->query_tables_own_last == &tmp_table_list->next_global)
+ thd->lex->query_tables_own_last = children_last_l;
+ break;
+ case HA_EXTRA_IS_ATTACHED_CHILDREN:
+ DBUG_PRINT("info",("vp HA_EXTRA_IS_ATTACHED_CHILDREN"));
+ DBUG_RETURN(is_clone || children_attached);
+#endif
+#ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
+ case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN:
+ DBUG_PRINT("info",("vp HA_EXTRA_STARTING_ORDERED_INDEX_SCAN"));
+ extra_use_cmp_ref = TRUE;
+ add_pk_bitmap_to_child();
+ break;
+#endif
+ default:
+ DBUG_PRINT("info",("vp default"));
+#if MYSQL_VERSION_ID < 50500
+ if (table->children_attached || is_clone)
+#else
+ if (children_attached || is_clone)
+#endif
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->extra(operation)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ break;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::extra_opt(
+ enum ha_extra_function operation,
+ ulong cachesize
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::extra_opt");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp operation=%d", (int) operation));
+ DBUG_PRINT("info",("vp cachesize=%lu", cachesize));
+ switch (operation)
+ {
+ case HA_EXTRA_CACHE:
+ if (child_table_idx < share->table_count)
+ {
+ if ((error_num =
+ part_tables[child_table_idx].table->file->extra_opt(operation,
+ cachesize)))
+ DBUG_RETURN(error_num);
+ } else {
+ if ((error_num =
+ part_tables[0].table->file->extra_opt(operation,
+ cachesize)))
+ DBUG_RETURN(error_num);
+ }
+ break;
+ default:
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->extra_opt(operation,
+ cachesize)))
+ DBUG_RETURN(error_num);
+ }
+ break;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::index_init(
+ uint idx,
+ bool sorted
+) {
+ int error_num, roop_count;
+ TABLE *child_table;
+ DBUG_ENTER("ha_vp::index_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ DBUG_PRINT("info",("vp table=%p", table));
+ DBUG_PRINT("info",("vp idx=%u", idx));
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (!table->pos_in_table_list->parent_l && lock_type_ext == F_WRLCK)
+ {
+ check_and_set_bitmap_for_update(FALSE);
+ }
+#endif
+ init_select_column(FALSE);
+ DBUG_PRINT("info",("vp init_sel_key_init_bitmap=%s",
+ init_sel_key_init_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ memset(key_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ active_index = idx;
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ {
+ memcpy(use_tables, bulk_access_info_exec_tgt->sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ child_keyread = bulk_access_info_exec_tgt->child_keyread;
+ single_table = bulk_access_info_exec_tgt->single_table;
+ set_used_table = bulk_access_info_exec_tgt->set_used_table;
+ child_table_idx = bulk_access_info_exec_tgt->child_table_idx;
+ child_key_idx = bulk_access_info_exec_tgt->child_key_idx;
+ } else
+#endif
+ if (!init_sel_key_init_bitmap)
+ {
+ memset(use_tables, 0, sizeof(uchar) * share->use_tables_size);
+ child_keyread = FALSE;
+ single_table = FALSE;
+ set_used_table = FALSE;
+ child_table_idx = share->table_count;
+ child_key_idx = MAX_KEY;
+ if (
+ (lock_mode > 0 || lock_type_ext == F_WRLCK) &&
+ (sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE_MULTI)
+ ) {
+ if (check_partitioned())
+ {
+ /* need all columns */
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ idx_init_read_bitmap[roop_count] = ~((uchar) 0);
+ idx_init_write_bitmap[roop_count] = ~((uchar) 0);
+ }
+ } else if (share->zero_record_update_mode)
+ {
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ idx_init_read_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ idx_init_write_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ }
+ }
+ }
+ memcpy(work_bitmap3, idx_init_read_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, idx_init_write_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+
+ if (
+ (error_num = choose_child_index(idx, work_bitmap3, work_bitmap4,
+ &child_table_idx, &child_key_idx)) ||
+ (error_num = choose_child_ft_tables(work_bitmap3, work_bitmap4)) ||
+ (!single_table && !ft_correspond_flag &&
+ (error_num = choose_child_tables(work_bitmap3, work_bitmap4)))
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ set_child_pt_bitmap();
+ memcpy(sel_key_init_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ } else if (cb_state != CB_SEL_KEY_INIT)
+ memcpy(use_tables, sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ DBUG_PRINT("info",("vp child_table_idx=%d", child_table_idx));
+ DBUG_PRINT("info",("vp child_key_idx=%d", child_key_idx));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info_exec_tgt->sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info_exec_tgt->sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp init child table bitmaps"));
+ } else
+#endif
+ if (init_sel_key_init_bitmap)
+ {
+ if (cb_state != CB_SEL_KEY_INIT)
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp init child table bitmaps"));
+ }
+ } else {
+ child_table = part_tables[roop_count].table;
+ memcpy(sel_key_init_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(sel_key_init_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ DBUG_PRINT("info",("vp init sel_key_init_child_bitmaps"));
+ }
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (roop_count == child_table_idx)
+ {
+ DBUG_ASSERT(!ft_inited);
+ if (
+ child_keyread &&
+ !(table_share->key_info[active_index].flags & HA_SPATIAL) &&
+ (error_num =
+ part_tables[roop_count].table->file->extra(HA_EXTRA_KEYREAD))
+ )
+ DBUG_RETURN(error_num);
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ vp_set_bit(key_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_index_init(
+ child_key_idx, sorted)))
+ DBUG_RETURN(error_num);
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ vp_set_bit(key_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_index_init(
+ share->correspond_pk[roop_count]->key_idx, FALSE)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ init_sel_key_init_bitmap = TRUE;
+ cb_state = CB_SEL_KEY_INIT;
+ DBUG_RETURN(0);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_index_init(
+ uint idx,
+ bool sorted
+) {
+ int error_num, roop_count;
+ TABLE *child_table;
+ DBUG_ENTER("ha_vp::pre_index_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ DBUG_PRINT("info",("vp table=%p", table));
+ DBUG_PRINT("info",("vp idx=%u", idx));
+ bulk_access_pre_called = TRUE;
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (!table->pos_in_table_list->parent_l && lock_type_ext == F_WRLCK)
+ {
+ check_and_set_bitmap_for_update(FALSE);
+ }
+#endif
+ init_select_column(FALSE);
+ DBUG_PRINT("info",("vp init_sel_key_init_bitmap=%s",
+ init_sel_key_init_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ memset(key_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ active_index = idx;
+ if (!bulk_access_info_current->init_sel_key_init_bitmap)
+ {
+ memset(use_tables, 0, sizeof(uchar) * share->use_tables_size);
+ child_keyread = FALSE;
+ single_table = FALSE;
+ set_used_table = FALSE;
+ child_table_idx = share->table_count;
+ child_key_idx = MAX_KEY;
+ if (
+ (lock_mode > 0 || lock_type_ext == F_WRLCK) &&
+ (sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE_MULTI)
+ ) {
+ if (check_partitioned())
+ {
+ /* need all columns */
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ bulk_access_info_current->idx_init_read_bitmap[roop_count] =
+ ~((uchar) 0);
+ bulk_access_info_current->idx_init_write_bitmap[roop_count] =
+ ~((uchar) 0);
+ }
+ } else if (share->zero_record_update_mode)
+ {
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ bulk_access_info_current->idx_init_read_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ bulk_access_info_current->idx_init_write_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ }
+ }
+ }
+ memcpy(work_bitmap3, bulk_access_info_current->idx_init_read_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, bulk_access_info_current->idx_init_write_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+
+ if (
+ (error_num = choose_child_index(idx, work_bitmap3, work_bitmap4,
+ &child_table_idx, &child_key_idx)) ||
+ (error_num = choose_child_ft_tables(work_bitmap3, work_bitmap4)) ||
+ (!single_table && !ft_correspond_flag &&
+ (error_num = choose_child_tables(work_bitmap3, work_bitmap4)))
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ set_child_pt_bitmap();
+ memcpy(bulk_access_info_current->sel_key_init_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ bulk_access_info_current->child_keyread = child_keyread;
+ bulk_access_info_current->single_table = single_table;
+ bulk_access_info_current->set_used_table = set_used_table;
+ bulk_access_info_current->child_table_idx = child_table_idx;
+ bulk_access_info_current->child_key_idx = child_key_idx;
+ } else if (cb_state != CB_SEL_KEY_INIT)
+ memcpy(use_tables, bulk_access_info_current->sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ DBUG_PRINT("info",("vp child_table_idx=%d", child_table_idx));
+ DBUG_PRINT("info",("vp child_key_idx=%d", child_key_idx));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ if (bulk_access_info_current->init_sel_key_init_bitmap)
+ {
+ if (cb_state != CB_SEL_KEY_INIT)
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info_current->
+ sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info_current->
+ sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp init child table bitmaps"));
+ }
+ } else {
+ child_table = part_tables[roop_count].table;
+ memcpy(bulk_access_info_current->
+ sel_key_init_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(bulk_access_info_current->
+ sel_key_init_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ DBUG_PRINT("info",("vp init sel_key_init_child_bitmaps"));
+ }
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (roop_count == child_table_idx)
+ {
+ DBUG_ASSERT(!ft_inited);
+ if (
+ child_keyread &&
+ !(table_share->key_info[active_index].flags & HA_SPATIAL) &&
+ (error_num =
+ part_tables[roop_count].table->file->extra(HA_EXTRA_KEYREAD))
+ )
+ DBUG_RETURN(error_num);
+ vp_set_bit(key_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_pre_index_init(
+ child_key_idx, sorted)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ } else if (update_request) {
+ vp_set_bit(key_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_pre_index_init(
+ share->correspond_pk[roop_count]->key_idx, FALSE)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ if (single_table)
+ need_bulk_access_finish = FALSE;
+ else {
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(pre_index_end());
+ }
+ bulk_access_info_current->init_sel_key_init_bitmap = TRUE;
+ cb_state = CB_SEL_KEY_INIT;
+ DBUG_RETURN(0);
+}
+#endif
+
+int ha_vp::index_end()
+{
+ int error_num, error_num2, roop_count;
+ DBUG_ENTER("ha_vp::index_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ error_num = 0;
+ active_index = MAX_KEY;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(key_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p", part_tables[roop_count].table));
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_index_end()))
+ error_num = error_num2;
+ }
+ }
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_index_end()
+{
+ int error_num, error_num2, roop_count;
+ DBUG_ENTER("ha_vp::pre_index_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ error_num = 0;
+ active_index = MAX_KEY;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(key_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p", part_tables[roop_count].table));
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_pre_index_end()))
+ error_num = error_num2;
+ }
+ }
+ bulk_access_pre_called = FALSE;
+ if (!error_num && need_bulk_access_finish)
+ DBUG_RETURN(ER_NOT_SUPPORTED_YET);
+ DBUG_RETURN(error_num);
+}
+#endif
+
+void ha_vp::index_read_map_init(
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag
+) {
+ DBUG_ENTER("ha_vp::index_read_map_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ uint key_length = calculate_key_len(table, active_index, key, keypart_map);
+ child_key = create_child_key(key, child_key_different, keypart_map,
+ key_length, &child_key_length);
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::pre_index_read_map(
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag,
+ bool use_parallel
+) {
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_index_read_map");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ index_read_map_init(key, keypart_map, find_flag);
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_index_read_map(
+ child_key, keypart_map, find_flag, use_parallel));
+}
+
+int ha_vp::index_read_map(
+ uchar *buf,
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_read_map");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else
+ index_read_map_init(key, keypart_map, find_flag);
+
+ table2 = part_tables[child_table_idx].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_read_map(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, keypart_map, find_flag)) ||
+#else
+ (error_num = table2->file->index_read_map(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, keypart_map, find_flag)) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ DBUG_PRINT("info",("vp single_table=%s", single_table ? "TRUE" : "FALSE"));
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(index_next(buf));
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+#ifdef VP_HANDLER_HAS_HA_INDEX_READ_LAST_MAP
+void ha_vp::index_read_last_map_init(
+ const uchar *key,
+ key_part_map keypart_map
+) {
+ DBUG_ENTER("ha_vp::index_read_last_map_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ uint key_length = calculate_key_len(table, active_index, key, keypart_map);
+ child_key = create_child_key(key, child_key_different, keypart_map,
+ key_length, &child_key_length);
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::pre_index_read_last_map(
+ const uchar *key,
+ key_part_map keypart_map,
+ bool use_parallel
+) {
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_index_read_last_map");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ index_read_last_map_init(key, keypart_map);
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_index_read_last_map(child_key, keypart_map,
+ use_parallel));
+}
+
+int ha_vp::index_read_last_map(
+ uchar *buf,
+ const uchar *key,
+ key_part_map keypart_map
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_read_last_map");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else
+ index_read_last_map_init(key, keypart_map);
+
+ table2 = part_tables[child_table_idx].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_read_last_map(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, keypart_map)) ||
+#else
+ (error_num = table2->file->index_read_last_map(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, keypart_map)) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(index_prev(buf));
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+#endif
+
+int ha_vp::index_next(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+
+ table2 = part_tables[child_table_idx].table;
+ do {
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_next(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#else
+ (error_num = table2->file->index_next(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::index_prev(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_prev");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+
+ table2 = part_tables[child_table_idx].table;
+ do {
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_prev(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#else
+ (error_num = table2->file->index_prev(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+void ha_vp::index_first_init()
+{
+ DBUG_ENTER("ha_vp::index_first_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::pre_index_first(
+ bool use_parallel
+) {
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_index_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ index_first_init();
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_index_first(use_parallel));
+}
+
+int ha_vp::index_first(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else
+ index_first_init();
+
+ table2 = part_tables[child_table_idx].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_first(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#else
+ (error_num = table2->file->index_first(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(index_next(buf));
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+void ha_vp::index_last_init()
+{
+ DBUG_ENTER("ha_vp::index_last_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::pre_index_last(
+ bool use_parallel
+) {
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_index_last");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ index_last_init();
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_index_last(use_pre_call));
+}
+
+int ha_vp::index_last(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_last");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else
+ index_last_init();
+
+ table2 = part_tables[child_table_idx].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_last(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#else
+ (error_num = table2->file->index_last(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(index_prev(buf));
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::index_next_same(
+ uchar *buf,
+ const uchar *key,
+ uint keylen
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::index_next_same");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ table2 = part_tables[child_table_idx].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_next_same(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, child_key_length)) ||
+#else
+ (error_num = table2->file->index_next_same(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0], child_key, child_key_length)) ||
+#endif
+ (error_num = get_child_record_by_idx(child_table_idx, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(index_next(buf));
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+void ha_vp::read_range_first_init(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted
+) {
+ DBUG_ENTER("ha_vp::read_range_first_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp start_key=%p", start_key));
+ DBUG_PRINT("info",("vp end_key=%p", end_key));
+ DBUG_PRINT("info",("vp eq_range=%s", eq_range ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp sorted=%s", sorted ? "TRUE" : "FALSE"));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ if (start_key)
+ {
+ DBUG_PRINT("info",("vp start_key->flag=%d", start_key->flag));
+ DBUG_PRINT("info",("vp start_key->length=%d", start_key->length));
+ child_start_key.keypart_map = start_key->keypart_map;
+ child_start_key.flag = start_key->flag;
+ child_start_key.key = create_child_key(
+ start_key->key, child_key_different, start_key->keypart_map,
+ start_key->length, &child_start_key.length
+ );
+ }
+ if (end_key)
+ {
+ DBUG_PRINT("info",("vp end_key->flag=%d", end_key->flag));
+ DBUG_PRINT("info",("vp end_key->length=%d", end_key->length));
+ child_end_key.keypart_map = end_key->keypart_map;
+ child_end_key.flag = end_key->flag;
+ child_end_key.key = create_child_key(
+ end_key->key, child_end_key_different, end_key->keypart_map,
+ end_key->length, &child_end_key.length
+ );
+
+ key_compare_result_on_equal =
+ ((end_key->flag == HA_READ_BEFORE_KEY) ? 1 :
+ (end_key->flag == HA_READ_AFTER_KEY) ? -1 : 0);
+ }
+ range_key_part = table->key_info[active_index].key_part;
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::pre_read_range_first(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted,
+ bool use_parallel
+) {
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_read_range_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp start_key=%p", start_key));
+ DBUG_PRINT("info",("vp end_key=%p", end_key));
+ DBUG_PRINT("info",("vp eq_range=%s", eq_range ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp sorted=%s", sorted ? "TRUE" : "FALSE"));
+ use_pre_call = TRUE;
+ read_range_first_init(start_key, end_key, eq_range, sorted);
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_read_range_first(
+ start_key ? &child_start_key : NULL,
+ end_key ? &child_end_key : NULL, eq_range, sorted, use_parallel));
+}
+
+int ha_vp::read_range_first(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted
+) {
+ int error_num;
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::read_range_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp start_key=%p", start_key));
+ DBUG_PRINT("info",("vp end_key=%p", end_key));
+ DBUG_PRINT("info",("vp eq_range=%s", eq_range ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp sorted=%s", sorted ? "TRUE" : "FALSE"));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else
+ read_range_first_init(start_key, end_key, eq_range, sorted);
+
+ table2 = part_tables[child_table_idx].table;
+ if (
+ (error_num = table2->file->read_range_first(
+ start_key ? &child_start_key : NULL,
+ end_key ? &child_end_key : NULL, eq_range, sorted)) ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+#ifndef DBUG_OFF
+ int roop_count, roop_count2;
+ uint store_length;
+ uchar tmp_key[MAX_KEY_LENGTH], *tmp_ptr;
+ KEY *key_info;
+ KEY_PART_INFO *key_part;
+ key_part_map tmp_key_part_map, tmp_key_part_map2 = 0;
+ key_info = &table2->key_info[child_key_idx];
+ key_part = key_info->key_part;
+ if (start_key)
+ tmp_key_part_map2 |= start_key->keypart_map;
+ if (end_key)
+ tmp_key_part_map2 |= end_key->keypart_map;
+ tmp_key_part_map =
+ make_prev_keypart_map(vp_user_defined_key_parts(key_info));
+ tmp_key_part_map &= tmp_key_part_map2;
+ key_copy(
+ tmp_key,
+ table2->record[0],
+ key_info,
+ key_info->key_length);
+ for (
+ roop_count = 0, tmp_ptr = tmp_key,
+ store_length = key_part->store_length;
+ tmp_key_part_map > 0;
+ tmp_ptr += store_length, roop_count++, tmp_key_part_map >>= 1,
+ key_part++, store_length = key_part->store_length
+ ) {
+ for (roop_count2 = 0; roop_count2 < (int) store_length; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp tmp_key[%d][%d]=%x",
+ roop_count, roop_count2, tmp_ptr[roop_count2]));
+ }
+ }
+ /* primary key */
+ key_info = &table2->key_info[0];
+ key_part = key_info->key_part;
+ tmp_key_part_map =
+ make_prev_keypart_map(vp_user_defined_key_parts(key_info));
+ key_copy(
+ tmp_key,
+ table2->record[0],
+ key_info,
+ key_info->key_length);
+ for (
+ roop_count = 0, tmp_ptr = tmp_key,
+ store_length = key_part->store_length;
+ tmp_key_part_map > 0;
+ tmp_ptr += store_length, roop_count++, tmp_key_part_map >>= 1,
+ key_part++, store_length = key_part->store_length
+ ) {
+ for (roop_count2 = 0; roop_count2 < (int) store_length; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp tmp_pk[%d][%d]=%x",
+ roop_count, roop_count2, tmp_ptr[roop_count2]));
+ }
+ }
+#endif
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else
+ DBUG_RETURN(read_range_next());
+ }
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::read_range_next()
+{
+ int error_num;
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::read_range_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ table2 = part_tables[child_table_idx].table;
+ do {
+ if (
+ (error_num = table2->file->read_range_next()) ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+#ifdef VP_SUPPORT_MRR
+int ha_vp::multi_range_key_create_key(
+ RANGE_SEQ_IF *seq,
+ range_seq_t seq_it,
+ int target_table_idx
+) {
+ uint length;
+ key_range *start_key, *end_key;
+ KEY_MULTI_RANGE *range;
+ DBUG_ENTER("ha_vp::multi_range_key_create_key");
+ DBUG_PRINT("info",("vp this=%p", this));
+ m_mrr_range_length = 0;
+ m_child_mrr_range_length[target_table_idx] = 0;
+ if (!m_mrr_range_first)
+ {
+ if (!(m_mrr_range_first = (VP_KEY_MULTI_RANGE *)
+ my_multi_malloc(MYF(MY_WME),
+ &m_mrr_range_current, sizeof(VP_KEY_MULTI_RANGE),
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ m_mrr_range_first->id = 1;
+ m_mrr_range_first->key[0] = NULL;
+ m_mrr_range_first->key[1] = NULL;
+ m_mrr_range_first->next = NULL;
+ } else {
+ m_mrr_range_current = m_mrr_range_first;
+ }
+ if (!m_child_mrr_range_first[target_table_idx])
+ {
+ if (!(m_child_mrr_range_first[target_table_idx] =
+ (VP_CHILD_KEY_MULTI_RANGE *) my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &m_child_mrr_range_current[target_table_idx],
+ sizeof(VP_CHILD_KEY_MULTI_RANGE),
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ } else {
+ m_child_mrr_range_current[target_table_idx] =
+ m_child_mrr_range_first[target_table_idx];
+ m_child_mrr_range_current[target_table_idx]->vp_key_multi_range = NULL;
+ }
+
+ while (!seq->next(seq_it, &m_mrr_range_current->key_multi_range))
+ {
+ m_mrr_range_length++;
+ range = &m_mrr_range_current->key_multi_range;
+ DBUG_PRINT("info",("vp range->range_flag=%u", range->range_flag));
+ start_key = &range->start_key;
+ DBUG_PRINT("info",("vp start_key->key=%p", start_key->key));
+ DBUG_PRINT("info",("vp start_key->length=%u", start_key->length));
+ DBUG_PRINT("info",("vp start_key->keypart_map=%lu", start_key->keypart_map));
+ DBUG_PRINT("info",("vp start_key->flag=%u", start_key->flag));
+ if (start_key->key)
+ {
+ length = start_key->length;
+ if (
+ !m_mrr_range_current->key[0] ||
+ m_mrr_range_current->length[0] < length
+ ) {
+ if (m_mrr_range_current->key[0])
+ {
+ vp_my_free(m_mrr_range_current->key[0], MYF(0));
+ }
+ if (!(m_mrr_range_current->key[0] = (uchar *)
+ my_multi_malloc(MYF(MY_WME),
+ &m_mrr_range_current->key[0], length,
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ m_mrr_range_current->length[0] = length;
+ }
+ memcpy(m_mrr_range_current->key[0], start_key->key, length);
+ start_key->key = m_mrr_range_current->key[0];
+ }
+
+ end_key = &range->end_key;
+ DBUG_PRINT("info",("vp end_key->key=%p", end_key->key));
+ DBUG_PRINT("info",("vp end_key->length=%u", end_key->length));
+ DBUG_PRINT("info",("vp end_key->keypart_map=%lu", end_key->keypart_map));
+ DBUG_PRINT("info",("vp end_key->flag=%u", end_key->flag));
+ if (end_key->key)
+ {
+ length = end_key->length;
+ if (
+ !m_mrr_range_current->key[1] ||
+ m_mrr_range_current->length[1] < length
+ ) {
+ if (m_mrr_range_current->key[1])
+ {
+ vp_my_free(m_mrr_range_current->key[1], MYF(0));
+ }
+ if (!(m_mrr_range_current->key[1] = (uchar *)
+ my_multi_malloc(MYF(MY_WME),
+ &m_mrr_range_current->key[1], length,
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ m_mrr_range_current->length[1] = length;
+ }
+ memcpy(m_mrr_range_current->key[1], end_key->key, length);
+ end_key->key = m_mrr_range_current->key[1];
+ }
+ m_mrr_range_current->ptr = m_mrr_range_current->key_multi_range.ptr;
+ m_mrr_range_current->key_multi_range.ptr = m_mrr_range_current;
+
+ m_child_mrr_range_length[target_table_idx]++;
+ m_child_mrr_range_current[target_table_idx]->vp_key_multi_range =
+ m_mrr_range_current;
+
+ if (!m_child_mrr_range_current[target_table_idx]->next)
+ {
+ VP_CHILD_KEY_MULTI_RANGE *tmp_child_mrr_range;
+ if (!(tmp_child_mrr_range = (VP_CHILD_KEY_MULTI_RANGE *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &tmp_child_mrr_range, sizeof(VP_CHILD_KEY_MULTI_RANGE),
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ m_child_mrr_range_current[target_table_idx]->next = tmp_child_mrr_range;
+ m_child_mrr_range_current[target_table_idx] = tmp_child_mrr_range;
+ } else {
+ m_child_mrr_range_current[target_table_idx] =
+ m_child_mrr_range_current[target_table_idx]->next;
+ m_child_mrr_range_current[target_table_idx]->vp_key_multi_range = NULL;
+ }
+
+ if (!m_mrr_range_current->next)
+ {
+ VP_KEY_MULTI_RANGE *tmp_mrr_range;
+ if (!(tmp_mrr_range = (VP_KEY_MULTI_RANGE *)
+ my_multi_malloc(MYF(MY_WME),
+ &tmp_mrr_range, sizeof(VP_KEY_MULTI_RANGE),
+ NullS))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ tmp_mrr_range->id = m_mrr_range_current->id + 1;
+ tmp_mrr_range->key[0] = NULL;
+ tmp_mrr_range->key[1] = NULL;
+ tmp_mrr_range->next = NULL;
+ m_mrr_range_current->next = tmp_mrr_range;
+ m_mrr_range_current = tmp_mrr_range;
+ } else {
+ m_mrr_range_current = m_mrr_range_current->next;
+ }
+ }
+
+ m_child_key_multi_range_hld[target_table_idx].vp = this;
+ m_child_key_multi_range_hld[target_table_idx].child_table_idx =
+ target_table_idx;
+ m_child_key_multi_range_hld[target_table_idx].vp_child_key_multi_range =
+ m_child_mrr_range_first[target_table_idx];
+ DBUG_PRINT("info",("vp OK"));
+ DBUG_RETURN(0);
+}
+
+static void vp_multi_range_key_get_key_info(
+ void *init_params,
+ uint *length,
+ key_part_map *map
+) {
+ DBUG_ENTER("vp_multi_range_key_get_key_info");
+ VP_CHILD_KEY_MULTI_RANGE_HLD *hld=
+ (VP_CHILD_KEY_MULTI_RANGE_HLD *)init_params;
+ ha_vp *vp = hld->vp;
+ key_range *start_key =
+ &vp->m_mrr_range_first->key_multi_range.start_key;
+ *length = start_key->length;
+ *map = start_key->keypart_map;
+ DBUG_VOID_RETURN;
+}
+
+static range_seq_t vp_multi_range_key_init(
+ void *init_params,
+ uint n_ranges,
+ uint flags
+) {
+ DBUG_ENTER("vp_multi_range_key_init");
+ VP_CHILD_KEY_MULTI_RANGE_HLD *hld =
+ (VP_CHILD_KEY_MULTI_RANGE_HLD *)init_params;
+ ha_vp *vp = hld->vp;
+ int i = hld->child_table_idx;
+ vp->m_mrr_range_init_flags = flags;
+ hld->vp_child_key_multi_range = vp->m_child_mrr_range_first[i];
+ DBUG_RETURN(init_params);
+}
+
+static bool vp_multi_range_key_next(
+ range_seq_t seq,
+ KEY_MULTI_RANGE *range
+) {
+ DBUG_ENTER("vp_multi_range_key_next");
+ VP_CHILD_KEY_MULTI_RANGE_HLD *hld =
+ (VP_CHILD_KEY_MULTI_RANGE_HLD *)seq;
+ VP_KEY_MULTI_RANGE *vp_key_multi_range =
+ hld->vp_child_key_multi_range->vp_key_multi_range;
+ if (!vp_key_multi_range)
+ DBUG_RETURN(TRUE);
+ *range = vp_key_multi_range->key_multi_range;
+ DBUG_PRINT("info",("vp range->range_flag=%u", range->range_flag));
+ DBUG_PRINT("info",("vp start_key->key=%p", range->start_key.key));
+ DBUG_PRINT("info",("vp start_key->length=%u", range->start_key.length));
+ DBUG_PRINT("info",("vp start_key->keypart_map=%lu", range->start_key.keypart_map));
+ DBUG_PRINT("info",("vp start_key->flag=%u", range->start_key.flag));
+ DBUG_PRINT("info",("vp end_key->key=%p", range->end_key.key));
+ DBUG_PRINT("info",("vp end_key->length=%u", range->end_key.length));
+ DBUG_PRINT("info",("vp end_key->keypart_map=%lu", range->end_key.keypart_map));
+ DBUG_PRINT("info",("vp end_key->flag=%u", range->end_key.flag));
+ hld->vp_child_key_multi_range =
+ hld->vp_child_key_multi_range->next;
+ DBUG_RETURN(FALSE);
+}
+
+static bool vp_multi_range_key_skip_record(
+ range_seq_t seq,
+ range_id_t range_info,
+ uchar *rowid
+) {
+ DBUG_ENTER("vp_multi_range_key_skip_record");
+ VP_CHILD_KEY_MULTI_RANGE_HLD *hld =
+ (VP_CHILD_KEY_MULTI_RANGE_HLD *)seq;
+ DBUG_RETURN(hld->vp->m_seq_if->skip_record(
+ hld->vp->m_seq, range_info, rowid));
+}
+
+static bool vp_multi_range_key_skip_index_tuple(
+ range_seq_t seq,
+ range_id_t range_info
+) {
+ DBUG_ENTER("vp_multi_range_key_skip_index_tuple");
+ VP_CHILD_KEY_MULTI_RANGE_HLD *hld =
+ (VP_CHILD_KEY_MULTI_RANGE_HLD *)seq;
+ DBUG_RETURN(hld->vp->m_seq_if->skip_index_tuple(
+ hld->vp->m_seq, range_info));
+}
+
+ha_rows ha_vp::multi_range_read_info_const(
+ uint keyno,
+ RANGE_SEQ_IF *seq,
+ void *seq_init_param,
+ uint n_ranges,
+ uint *bufsz,
+ uint *mrr_mode,
+ Cost_estimate *cost
+) {
+ int error_num;
+ ha_rows rows;
+ range_seq_t seq_it;
+ DBUG_ENTER("ha_vp::multi_range_read_info_const");
+ DBUG_PRINT("info",("vp this=%p", this));
+ child_keyread = FALSE;
+ single_table = FALSE;
+ memcpy(work_bitmap3, table->read_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, table->write_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ if (
+ (error_num = choose_child_index(keyno, work_bitmap3, work_bitmap4,
+ &child_table_idx, &child_key_idx))
+ )
+ DBUG_RETURN(HA_POS_ERROR);
+ set_child_pt_bitmap();
+
+ TABLE *table2 = part_tables[child_table_idx].table;
+ if (!vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ rows =
+ table2->file->multi_range_read_info_const(
+ child_key_idx,
+ seq,
+ seq_init_param,
+ n_ranges,
+ bufsz,
+ mrr_mode,
+ cost
+ );
+ DBUG_PRINT("info",("vp rows=%llu", rows));
+ DBUG_RETURN(rows);
+ }
+ m_mrr_new_full_buffer_size = 0;
+ seq_it = seq->init(seq_init_param, n_ranges, *mrr_mode);
+ if ((error_num = multi_range_key_create_key(seq, seq_it, child_table_idx)))
+ {
+ DBUG_RETURN(HA_POS_ERROR);
+ }
+ m_child_seq_if.get_key_info =
+ seq->get_key_info ? vp_multi_range_key_get_key_info : NULL;
+ m_child_seq_if.init =
+ vp_multi_range_key_init;
+ m_child_seq_if.next =
+ vp_multi_range_key_next;
+ m_child_seq_if.skip_record =
+ seq->skip_record ? vp_multi_range_key_skip_record : NULL;
+ m_child_seq_if.skip_index_tuple =
+ seq->skip_index_tuple ? vp_multi_range_key_skip_index_tuple : NULL;
+
+ m_mrr_buffer_size[child_table_idx] = 0;
+ rows = table2->file->multi_range_read_info_const(
+ child_key_idx,
+ &m_child_seq_if,
+ &m_child_key_multi_range_hld[child_table_idx],
+ m_child_mrr_range_length[child_table_idx],
+ &m_mrr_buffer_size[child_table_idx],
+ mrr_mode,
+ cost
+ );
+ if (rows == HA_POS_ERROR)
+ DBUG_RETURN(HA_POS_ERROR);
+ m_mrr_new_full_buffer_size += m_mrr_buffer_size[child_table_idx];
+
+ DBUG_PRINT("info",("vp rows=%llu", rows));
+ DBUG_RETURN(rows);
+}
+
+ha_rows ha_vp::multi_range_read_info(
+ uint keyno,
+ uint n_ranges,
+ uint keys,
+ uint key_parts,
+ uint *bufsz,
+ uint *mrr_mode,
+ Cost_estimate *cost
+) {
+ int error_num;
+ ha_rows rows;
+ DBUG_ENTER("ha_vp::multi_range_read_info");
+ DBUG_PRINT("info",("vp this=%p", this));
+ child_keyread = FALSE;
+ single_table = FALSE;
+ memcpy(work_bitmap3, table->read_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, table->write_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ if (
+ (error_num = choose_child_index(keyno, work_bitmap3, work_bitmap4,
+ &child_table_idx, &child_key_idx))
+ )
+ DBUG_RETURN(HA_POS_ERROR);
+ set_child_pt_bitmap();
+
+ TABLE *table2 = part_tables[child_table_idx].table;
+ if (!vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ rows =
+ table2->file->multi_range_read_info(
+ child_key_idx,
+ n_ranges,
+ keys,
+ key_parts,
+ bufsz,
+ mrr_mode,
+ cost
+ );
+ DBUG_PRINT("info",("vp rows=%llu", rows));
+ DBUG_RETURN(rows);
+ }
+ m_mrr_new_full_buffer_size = 0;
+ m_mrr_buffer_size[child_table_idx] = 0;
+ rows = table2->file->multi_range_read_info(
+ child_key_idx,
+ n_ranges,
+ keys,
+ key_parts,
+ &m_mrr_buffer_size[child_table_idx],
+ mrr_mode,
+ cost
+ );
+ if (rows == HA_POS_ERROR)
+ DBUG_RETURN(HA_POS_ERROR);
+ m_mrr_new_full_buffer_size += m_mrr_buffer_size[child_table_idx];
+ DBUG_PRINT("info",("vp rows=%llu", rows));
+ DBUG_RETURN(0);
+}
+
+int ha_vp::multi_range_read_init(
+ RANGE_SEQ_IF *seq,
+ void *seq_init_param,
+ uint n_ranges,
+ uint mrr_mode,
+ HANDLER_BUFFER *buf
+) {
+ int error_num;
+ uchar *tmp_buffer;
+ DBUG_ENTER("ha_vp::multi_range_read_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ TABLE *table2 = part_tables[child_table_idx].table;
+ mrr_iter = seq->init(seq_init_param, n_ranges, mrr_mode);
+ mrr_funcs = *seq;
+ mrr_is_output_sorted = MY_TEST(mrr_mode & HA_MRR_SORTED);
+ mrr_have_range = FALSE;
+ if (!vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_init directly",
+ child_table_idx));
+ error_num = table2->file->multi_range_read_init(
+ seq,
+ seq_init_param,
+ n_ranges,
+ mrr_mode,
+ buf
+ );
+ DBUG_RETURN(error_num);
+ }
+
+ m_seq_if = seq;
+ m_seq = seq->init(seq_init_param, n_ranges, mrr_mode);
+ if ((error_num = multi_range_key_create_key(seq, m_seq, child_table_idx)))
+ {
+ DBUG_RETURN(error_num);
+ }
+ m_child_seq_if.get_key_info =
+ seq->get_key_info ? vp_multi_range_key_get_key_info : NULL;
+ m_child_seq_if.init =
+ vp_multi_range_key_init;
+ m_child_seq_if.next =
+ vp_multi_range_key_next;
+ m_child_seq_if.skip_record =
+ seq->skip_record ? vp_multi_range_key_skip_record : NULL;
+ m_child_seq_if.skip_index_tuple =
+ seq->skip_index_tuple ? vp_multi_range_key_skip_index_tuple : NULL;
+ if (m_mrr_full_buffer_size < m_mrr_new_full_buffer_size)
+ {
+ if (m_mrr_full_buffer)
+ vp_my_free(m_mrr_full_buffer, MYF(0));
+ m_mrr_full_buffer_size = 0;
+ if (!(m_mrr_full_buffer = (uchar *)
+ my_multi_malloc(MYF(MY_WME),
+ &m_mrr_full_buffer, m_mrr_new_full_buffer_size,
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error;
+ }
+ m_mrr_full_buffer_size = m_mrr_new_full_buffer_size;
+ }
+
+ if (m_mrr_new_full_buffer_size)
+ {
+ tmp_buffer = m_mrr_full_buffer;
+ if (m_mrr_buffer_size[child_table_idx])
+ {
+ m_mrr_buffer[child_table_idx].buffer = tmp_buffer;
+ m_mrr_buffer[child_table_idx].end_of_used_area = tmp_buffer;
+ tmp_buffer += m_mrr_buffer_size[child_table_idx];
+ m_mrr_buffer[child_table_idx].buffer_end = tmp_buffer;
+ }
+ } else {
+ m_mrr_buffer[child_table_idx] = *buf;
+ }
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_init",
+ child_table_idx));
+ if ((error_num = table2->file->multi_range_read_init(
+ &m_child_seq_if,
+ &m_child_key_multi_range_hld[child_table_idx],
+ m_child_mrr_range_length[child_table_idx],
+ mrr_mode,
+ &m_mrr_buffer[child_table_idx])))
+ goto error;
+ m_stock_range_seq[child_table_idx] = 0;
+
+ m_mrr_range_current = m_mrr_range_first;
+ DBUG_RETURN(0);
+
+error:
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::pre_multi_range_read_next(
+ bool use_parallel
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::pre_multi_range_read_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ if (multi_range_mode == 0)
+ DBUG_RETURN(handler::pre_multi_range_read_next(use_parallel));
+ table2 = part_tables[child_table_idx].table;
+ error_num = table2->file->pre_multi_range_read_next(use_parallel);
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::multi_range_read_next(
+ range_id_t *range_info
+) {
+ int error_num;
+ DBUG_ENTER("ha_vp::multi_range_read_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (!mrr_have_range)
+ {
+ mrr_have_range = TRUE;
+ error_num = multi_range_read_next_first(range_info);
+ } else
+ error_num = multi_range_read_next_next(range_info);
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::multi_range_read_explain_info(
+ uint mrr_mode,
+ char *str,
+ size_t size
+) {
+ DBUG_ENTER("ha_vp::multi_range_read_explain_info");
+ DBUG_PRINT("info",("vp this=%p", this));
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (!table->pos_in_table_list->parent_l && lock_type_ext == F_WRLCK)
+ {
+ check_and_set_bitmap_for_update(TRUE);
+ }
+#endif
+ init_select_column(FALSE);
+ DBUG_RETURN(
+ part_tables[0].table->file->multi_range_read_explain_info(
+ mrr_mode, str, size)
+ );
+}
+
+int ha_vp::multi_range_read_next_first(
+ range_id_t *range_info
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::multi_range_read_next_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (!use_pre_call)
+ {
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ } else {
+ use_pre_call = FALSE;
+ }
+ if (multi_range_mode == 0)
+ {
+ DBUG_PRINT("info",("vp call handler::multi_range_read_next"));
+ DBUG_RETURN(handler::multi_range_read_next(range_info));
+ }
+ table2 = part_tables[child_table_idx].table;
+ if (vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_next",
+ child_table_idx));
+ error_num = table2->file->multi_range_read_next(
+ &m_range_info[child_table_idx]);
+ if (!error_num)
+ *range_info =
+ ((VP_KEY_MULTI_RANGE *) m_range_info[child_table_idx])->ptr;
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_next directly",
+ child_table_idx));
+ error_num = table2->file->multi_range_read_next(range_info);
+ }
+ if (
+ error_num ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else {
+ DBUG_RETURN(multi_range_read_next(range_info));
+ }
+ }
+
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::multi_range_read_next_next(
+ range_id_t *range_info
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::multi_range_read_next_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ if (multi_range_mode == 0)
+ {
+ DBUG_PRINT("info",("vp call handler::multi_range_read_next"));
+ DBUG_RETURN(handler::multi_range_read_next(range_info));
+ }
+
+ table2 = part_tables[child_table_idx].table;
+ do {
+ if (vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_next",
+ child_table_idx));
+ error_num = table2->file->multi_range_read_next(
+ &m_range_info[child_table_idx]);
+ if (!error_num)
+ *range_info =
+ ((VP_KEY_MULTI_RANGE *) m_range_info[child_table_idx])->ptr;
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] multi_range_read_next directly",
+ child_table_idx));
+ error_num = table2->file->multi_range_read_next(range_info);
+ }
+ if (
+ error_num ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+#else
+int ha_vp::read_multi_range_first_init(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer
+) {
+ THD *thd = ha_thd();
+ KEY_MULTI_RANGE *multi_range, *tmp_multi_range;
+ uchar *keys;
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::read_multi_range_first_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(FALSE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ if (multi_range_mode == 0)
+ DBUG_RETURN(0);
+
+ multi_range_sorted = sorted;
+ multi_range_buffer = buffer;
+ if (vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+ if (child_multi_range_first)
+ vp_my_free(child_multi_range_first, MYF(0));
+ /* copy multi range for child */
+ if (!(child_multi_range_first =
+ (KEY_MULTI_RANGE *) my_multi_malloc(MYF(MY_WME),
+ &multi_range, sizeof(KEY_MULTI_RANGE) * range_count,
+ &keys, sizeof(uchar) * MAX_KEY_LENGTH * range_count * 2,
+ NullS)))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ memcpy(multi_range, ranges, sizeof(KEY_MULTI_RANGE) * range_count);
+ for (
+ tmp_multi_range = multi_range,
+ multi_range_curr = ranges,
+ multi_range_end = ranges + range_count;
+ multi_range_curr < multi_range_end;
+ tmp_multi_range++,
+ multi_range_curr++
+ ) {
+ DBUG_PRINT("info",("vp multi_range->start_key.key=%p",
+ multi_range->start_key.key));
+ tmp_multi_range->start_key.key = create_child_key(
+ multi_range_curr->start_key.key, keys,
+ multi_range_curr->start_key.keypart_map,
+ multi_range_curr->start_key.length,
+ &tmp_multi_range->start_key.length
+ );
+ keys += MAX_KEY_LENGTH;
+ DBUG_PRINT("info",("vp multi_range->end_key.key=%p",
+ multi_range->start_key.key));
+ tmp_multi_range->end_key.key = create_child_key(
+ multi_range_curr->end_key.key, keys,
+ multi_range_curr->end_key.keypart_map,
+ multi_range_curr->end_key.length,
+ &tmp_multi_range->end_key.length
+ );
+ keys += MAX_KEY_LENGTH;
+ }
+ } else
+ multi_range = ranges;
+
+ multi_range_curr = ranges;
+ multi_range_end = ranges + range_count;
+
+ child_found_range = multi_range;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::pre_read_multi_range_first(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer,
+ bool use_parallel
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::pre_read_multi_range_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ if ((error_num =
+ read_multi_range_first_init(found_range_p, ranges, range_count, sorted,
+ buffer)))
+ {
+ DBUG_RETURN(error_num);
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ if (multi_range_mode == 0)
+ DBUG_RETURN(handler::pre_read_multi_range_first(
+ found_range_p, ranges, range_count, sorted, buffer, use_parallel));
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_read_multi_range_first(&child_found_range,
+ child_found_range, range_count, sorted, buffer, use_parallel));
+}
+
+int ha_vp::read_multi_range_first(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ KEY_MULTI_RANGE *multi_range;
+ DBUG_ENTER("ha_vp::read_multi_range_first");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else if ((error_num =
+ read_multi_range_first_init(found_range_p, ranges, range_count, sorted,
+ buffer)))
+ {
+ DBUG_RETURN(error_num);
+ }
+
+ if (multi_range_mode == 0)
+ DBUG_RETURN(handler::read_multi_range_first(
+ found_range_p, ranges, range_count, sorted, buffer));
+ multi_range = child_found_range;
+ table2 = part_tables[child_table_idx].table;
+ if (
+ (error_num = table2->file->read_multi_range_first(
+ &child_found_range, multi_range, range_count, sorted, buffer)) ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+#ifndef DBUG_OFF
+ int roop_count, roop_count2;
+ uint store_length;
+ uchar tmp_key[MAX_KEY_LENGTH], *tmp_ptr;
+ KEY *key_info;
+ KEY_PART_INFO *key_part;
+ key_part_map tmp_key_part_map, tmp_key_part_map2 = 0;
+ key_info = &table2->key_info[child_key_idx];
+ key_part = key_info->key_part;
+ if (multi_range->start_key.key)
+ tmp_key_part_map2 |= multi_range->start_key.keypart_map;
+ if (multi_range->end_key.key)
+ tmp_key_part_map2 |= multi_range->end_key.keypart_map;
+ tmp_key_part_map = make_prev_keypart_map(key_info->key_parts);
+ tmp_key_part_map &= tmp_key_part_map2;
+ key_copy(
+ tmp_key,
+ table2->record[0],
+ key_info,
+ key_info->key_length);
+ for (
+ roop_count = 0, tmp_ptr = tmp_key,
+ store_length = key_part->store_length;
+ tmp_key_part_map > 0;
+ tmp_ptr += store_length, roop_count++, tmp_key_part_map >>= 1,
+ key_part++, store_length = key_part->store_length
+ ) {
+ for (roop_count2 = 0; roop_count2 < (int) store_length; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp tmp_key[%d][%d]=%x",
+ roop_count, roop_count2, tmp_ptr[roop_count2]));
+ }
+ }
+ /* primary key */
+ key_info = &table2->key_info[0];
+ key_part = key_info->key_part;
+ tmp_key_part_map = make_prev_keypart_map(key_info->key_parts);
+ key_copy(
+ tmp_key,
+ table2->record[0],
+ key_info,
+ key_info->key_length);
+ for (
+ roop_count = 0, tmp_ptr = tmp_key,
+ store_length = key_part->store_length;
+ tmp_key_part_map > 0;
+ tmp_ptr += store_length, roop_count++, tmp_key_part_map >>= 1,
+ key_part++, store_length = key_part->store_length
+ ) {
+ for (roop_count2 = 0; roop_count2 < (int) store_length; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp tmp_pk[%d][%d]=%x",
+ roop_count, roop_count2, tmp_ptr[roop_count2]));
+ }
+ }
+#endif
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0))
+ ) {
+ if (
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ )
+ DBUG_RETURN(error_num);
+ else {
+ DBUG_RETURN(read_multi_range_next(&child_found_range));
+ }
+ }
+ *found_range_p = child_found_range - multi_range + ranges;
+
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::read_multi_range_next(
+ KEY_MULTI_RANGE **found_range_p
+) {
+ int error_num;
+ TABLE *table2;
+ THD *thd = ha_thd();
+ KEY_MULTI_RANGE *tmp_multi_range;
+ int multi_range_mode =
+ vp_param_multi_range_mode(thd, share->multi_range_mode);
+ DBUG_ENTER("ha_vp::read_multi_range_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (cb_state != CB_SEL_KEY || is_clone)
+ {
+ prune_child();
+ cb_state = CB_SEL_KEY;
+ }
+ if (multi_range_mode == 0)
+ DBUG_RETURN(handler::read_multi_range_next(found_range_p));
+
+ table2 = part_tables[child_table_idx].table;
+ tmp_multi_range = child_found_range;
+ do {
+ if (
+ (error_num = table2->file->read_multi_range_next(&child_found_range)) ||
+ (error_num = get_child_record_by_idx(child_table_idx, 0))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(0)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ *found_range_p = child_found_range - tmp_multi_range + *found_range_p;
+
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+#endif
+
+int ha_vp::rnd_init(
+ bool scan
+) {
+ DBUG_ENTER("ha_vp::rnd_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ rnd_scan = scan;
+ DBUG_PRINT("info",("vp rnd_scan=%s", rnd_scan ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp init_rnd_bitmap=%s",
+ init_sel_rnd_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(0);
+
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (
+ !table->pos_in_table_list->parent_l &&
+ rnd_scan &&
+ lock_type_ext == F_WRLCK
+ ) {
+ check_and_set_bitmap_for_update(TRUE);
+ }
+#endif
+ init_select_column(TRUE);
+ memset(rnd_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ if (rnd_scan)
+ {
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ }
+ rnd_init_and_first = TRUE;
+ DBUG_RETURN(0);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_rnd_init(
+ bool scan
+) {
+ DBUG_ENTER("ha_vp::pre_rnd_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ rnd_scan = scan;
+ DBUG_PRINT("info",("vp rnd_scan=%s", rnd_scan ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp init_rnd_bitmap=%s",
+ init_sel_rnd_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(0);
+
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (
+ !table->pos_in_table_list->parent_l &&
+ rnd_scan &&
+ lock_type_ext == F_WRLCK
+ ) {
+ check_and_set_bitmap_for_update(TRUE);
+ }
+#endif
+ init_select_column(TRUE);
+ memset(rnd_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ if (rnd_scan)
+ {
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ }
+ rnd_init_and_first = TRUE;
+ bulk_access_pre_called = TRUE;
+ need_bulk_access_finish = FALSE;
+ DBUG_RETURN(0);
+}
+#endif
+
+int ha_vp::rnd_end()
+{
+ int error_num, error_num2, roop_count;
+ DBUG_ENTER("ha_vp::rnd_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ rnd_scan = FALSE;
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(0);
+
+ error_num = 0;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(rnd_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p", part_tables[roop_count].table));
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_index_or_rnd_end()))
+ error_num = error_num2;
+ }
+ }
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_rnd_end()
+{
+ int error_num;
+ DBUG_ENTER("ha_vp::pre_rnd_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ rnd_scan = FALSE;
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(0);
+
+ error_num = 0;
+ if (vp_bit_is_set(rnd_inited_tables, child_table_idx))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", child_table_idx));
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[child_table_idx].table));
+ error_num =
+ part_tables[child_table_idx].table->file->ha_pre_rnd_end();
+ }
+ bulk_access_pre_called = FALSE;
+ if (!error_num && need_bulk_access_finish)
+ DBUG_RETURN(ER_NOT_SUPPORTED_YET);
+ DBUG_RETURN(error_num);
+}
+#endif
+
+int ha_vp::rnd_next_init()
+{
+ int error_num;
+ DBUG_ENTER("ha_vp::rnd_next_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ check_select_column(TRUE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if (rnd_init_and_first)
+ {
+ if ((error_num = set_rnd_bitmap()))
+ DBUG_RETURN(error_num);
+ rnd_init_and_first = FALSE;
+ cb_state = CB_SEL_RND;
+ } else if (cb_state != CB_SEL_RND)
+ {
+ reset_rnd_bitmap();
+ cb_state = CB_SEL_RND;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::pre_rnd_next(
+ bool use_parallel
+) {
+ int error_num;
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_rnd_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ /* do not copy table data at alter table */
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(0);
+
+ use_pre_call = TRUE;
+ if ((error_num = rnd_next_init()))
+ DBUG_RETURN(error_num);
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (!rnd_scan || single_table)
+ need_bulk_access_finish = FALSE;
+ else
+ need_bulk_access_finish = TRUE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_rnd_next(use_parallel));
+}
+
+int ha_vp::rnd_next(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::rnd_next");
+ DBUG_PRINT("info",("vp this=%p", this));
+ /* do not copy table data at alter table */
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else if ((error_num = rnd_next_init()))
+ DBUG_RETURN(error_num);
+
+ table2 = part_tables[child_table_idx].table;
+ do {
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ if ((error_num = table2->file->ha_rnd_next(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])))
+#else
+ if ((error_num = table2->file->rnd_next(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])))
+#endif
+ {
+ if (error_num == HA_ERR_RECORD_DELETED)
+ continue;
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if ((error_num = get_child_record_by_idx(child_table_idx, ptr_diff)))
+ {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+void ha_vp::position(
+ const uchar *record
+) {
+ int roop_count;
+ uint roop_count2;
+ TABLE *table2;
+ handler *file2;
+ ha_vp *tmp_vp = this;
+ DBUG_ENTER("ha_vp::position");
+ DBUG_PRINT("info",("vp this=%p", this));
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp read_bitmap is %d-%u", roop_count,
+ ((uchar *) table->read_set->bitmap)[roop_count]));
+ DBUG_PRINT("info",("vp write_bitmap is %d-%u", roop_count,
+ ((uchar *) table->write_set->bitmap)[roop_count]));
+ }
+#endif
+ DBUG_PRINT("info",("vp ref=%p", ref));
+ DBUG_PRINT("info",("vp ref_length=%u", ref_length));
+ memcpy(ref + (child_ref_length * share->table_count), &tmp_vp,
+ sizeof(ha_vp *));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp roop_count=%d is set", roop_count));
+ table2 = part_tables[roop_count].table;
+#ifndef DBUG_OFF
+ int roop_count2;
+ for (roop_count2 = 0; roop_count2 < (int) table2->s->column_bitmap_size;
+ roop_count2++)
+ {
+ DBUG_PRINT("info",("vp child read_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->read_set->bitmap)[roop_count2]));
+ DBUG_PRINT("info",("vp child write_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->write_set->bitmap)[roop_count2]));
+ }
+#endif
+ file2 = table2->file;
+ file2->position(table2->record[0]);
+ memcpy(ref + (child_ref_length * roop_count), file2->ref,
+ file2->ref_length);
+ DBUG_PRINT("info",("vp ref copy=%d", roop_count));
+#ifndef DBUG_OFF
+/*
+ for (roop_count2 = 0; roop_count2 < (int) file2->ref_length;
+ roop_count2++)
+ DBUG_PRINT("info",("vp ref[roop_count2]=%x", file2->ref[roop_count2]));
+*/
+#endif
+ }
+ }
+ /* for cmp_ref */
+ KEY *key_info = &table->key_info[table_share->primary_key];
+ KEY_PART_INFO *key_part = key_info->key_part;
+ if (record != table->record[0])
+ {
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(record, table->record[0]);
+ for (roop_count2 = 0; roop_count2 < vp_user_defined_key_parts(key_info);
+ ++roop_count2)
+ {
+ key_part[roop_count2].field->move_field_offset(ptr_diff);
+ }
+ key_copy(
+ ref + (child_ref_length * share->table_count) + sizeof(ha_vp *),
+ (uchar *) record,
+ key_info,
+ key_info->key_length);
+ for (roop_count2 = 0; roop_count2 < vp_user_defined_key_parts(key_info);
+ ++roop_count2)
+ {
+ key_part[roop_count2].field->move_field_offset(-ptr_diff);
+ }
+ } else {
+ key_copy(
+ ref + (child_ref_length * share->table_count) + sizeof(ha_vp *),
+ (uchar *) record,
+ key_info,
+ key_info->key_length);
+ }
+ DBUG_PRINT("info",("vp ref=%p", ref));
+ DBUG_PRINT("info",("vp ref_length=%u", ref_length));
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::rnd_pos(
+ uchar *buf,
+ uchar *pos
+) {
+ int error_num = 0, error_num2, roop_count;
+ ha_vp *tmp_vp;
+ TABLE *table2 = NULL;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::rnd_pos");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+/*
+ if (rnd_init_and_first)
+ {
+ if ((error_num = set_rnd_bitmap()))
+ DBUG_RETURN(error_num);
+ rnd_init_and_first = FALSE;
+ cb_state = CB_SEL_RND;
+ } else if (cb_state != CB_SEL_RND)
+ {
+ reset_rnd_bitmap();
+ cb_state = CB_SEL_RND;
+ }
+*/
+ DBUG_PRINT("info",("vp pos=%p", pos));
+ DBUG_PRINT("info",("vp buf=%p", buf));
+ memcpy(&tmp_vp, pos + (child_ref_length * share->table_count),
+ sizeof(ha_vp *));
+ DBUG_PRINT("info",("vp tmp_vp=%p", tmp_vp));
+ if (tmp_vp == this)
+ {
+ if (rnd_init_and_first)
+ {
+ if ((error_num = set_rnd_bitmap()))
+ DBUG_RETURN(error_num);
+ rnd_init_and_first = FALSE;
+ cb_state = CB_SEL_RND;
+ } else if (cb_state != CB_SEL_RND)
+ {
+ reset_rnd_bitmap();
+ cb_state = CB_SEL_RND;
+ }
+ } else {
+ if ((error_num = set_rnd_bitmap_from_another(tmp_vp)))
+ DBUG_RETURN(error_num);
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp use_tables[%d]=%s", roop_count,
+ vp_bit_is_set(use_tables, roop_count) ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp pruned_tables[%d]=%s", roop_count,
+ vp_bit_is_set(pruned_tables, roop_count) ? "TRUE" : "FALSE"));
+ if (
+ vp_bit_is_set(use_tables, roop_count) &&
+ !vp_bit_is_set(pruned_tables, roop_count)
+ ) {
+ DBUG_PRINT("info",("vp roop_count=%d is set", roop_count));
+ table2 = part_tables[roop_count].table;
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_rnd_pos(table2->record[0],
+ pos + (child_ref_length * roop_count))) ||
+#else
+ (error_num = table2->file->rnd_pos(table2->record[0],
+ pos + (child_ref_length * roop_count))) ||
+#endif
+ (error_num = get_child_record_by_idx(roop_count, ptr_diff))
+ ) {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+
+ DBUG_PRINT("info",("vp pruned=%s", pruned ? "TRUE" : "FALSE"));
+ if (pruned)
+ {
+ uchar *use_tables_bak = use_tables;
+ use_tables = pruned_tables;
+ if ((error_num = get_child_record_by_pk(ptr_diff)))
+ {
+ use_tables = use_tables_bak;
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ use_tables = use_tables_bak;
+ }
+ table->status = table2->status;
+
+ if (tmp_vp != this && inited == NONE)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(rnd_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[roop_count].table));
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_rnd_end()))
+ error_num = error_num2;
+ }
+ }
+ }
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::cmp_ref(
+ const uchar *ref1,
+ const uchar *ref2
+) {
+ int ret;
+ KEY *key_info = &table->key_info[table_share->primary_key];
+ uint store_length, roop_count;
+ KEY_PART_INFO *key_part = key_info->key_part;
+ const uchar *key1 = ref1 + (child_ref_length * share->table_count) +
+ sizeof(ha_vp *);
+ const uchar *key2 = ref2 + (child_ref_length * share->table_count) +
+ sizeof(ha_vp *);
+ DBUG_ENTER("ha_vp::cmp_ref");
+ DBUG_PRINT("info",("vp ref1=%p", ref1));
+ DBUG_PRINT("info",("vp ref2=%p", ref2));
+ for (roop_count = 0; roop_count < vp_user_defined_key_parts(key_info);
+ ++roop_count)
+ {
+ store_length = key_part[roop_count].store_length;
+ /* columns of primary key have no null bit */
+ if ((ret = key_part[roop_count].field->key_cmp(key1, key2)))
+ {
+ DBUG_PRINT("info",("vp ret=%d", ret));
+ DBUG_RETURN(ret);
+ }
+ key1 += store_length;
+ key2 += store_length;
+ }
+/*
+ if (key_buf_cmp(
+ key_info,
+ vp_user_defined_key_parts(key_info),
+ ref1 + (child_ref_length * share->table_count) + sizeof(ha_vp *),
+ ref2 + (child_ref_length * share->table_count) + sizeof(ha_vp *)
+ ))
+ ret = 1;
+*/
+ DBUG_PRINT("info",("vp ret=0"));
+ DBUG_RETURN(0);
+}
+
+float vp_ft_find_relevance(
+ FT_INFO *handler,
+ uchar *record,
+ uint length
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ return info->file->ft_find_relevance(handler, record, length);
+}
+
+float ha_vp::ft_find_relevance(
+ FT_INFO *handler,
+ uchar *record,
+ uint length
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ TABLE *child_table = part_tables[info->target->table_idx].table;
+ DBUG_ENTER("ha_vp::ft_find_relevance");
+ if (
+ info->ft_handler &&
+ info->ft_handler->please &&
+ info->ft_handler->please->find_relevance
+ ) {
+ if (length)
+ DBUG_RETURN(info->ft_handler->please->find_relevance(
+ info->ft_handler, record, length));
+ else
+ DBUG_RETURN(info->ft_handler->please->find_relevance(
+ info->ft_handler, child_table->record[0], 0));
+ }
+ DBUG_RETURN((float) -1.0);
+}
+
+float vp_ft_get_relevance(
+ FT_INFO *handler
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ return info->file->ft_get_relevance(handler);
+}
+
+float ha_vp::ft_get_relevance(
+ FT_INFO *handler
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ DBUG_ENTER("ha_vp::ft_get_relevance");
+ if (
+ info->ft_handler &&
+ info->ft_handler->please &&
+ info->ft_handler->please->get_relevance
+ ) {
+ DBUG_RETURN(info->ft_handler->please->get_relevance(info->ft_handler));
+ }
+ DBUG_RETURN((float) -1.0);
+}
+
+void vp_ft_close_search(
+ FT_INFO *handler
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ info->file->ft_close_search(handler);
+}
+
+void ha_vp::ft_close_search(
+ FT_INFO *handler
+) {
+ st_vp_ft_info *info = (st_vp_ft_info*) handler;
+ DBUG_ENTER("ha_vp::ft_close_search");
+ if (
+ info->ft_handler &&
+ info->ft_handler->please &&
+ info->ft_handler->please->close_search
+ ) {
+ info->ft_handler->please->close_search(info->ft_handler);
+ }
+ DBUG_VOID_RETURN;
+}
+
+_ft_vft vp_ft_vft = {
+ NULL, // vp_ft_read_next
+ vp_ft_find_relevance,
+ vp_ft_close_search,
+ vp_ft_get_relevance,
+ NULL // vp_ft_reinit_search
+};
+
+FT_INFO *ha_vp::ft_init_ext(
+ uint flags,
+ uint inx,
+ String *key
+) {
+ VP_CORRESPOND_KEY *tmp_correspond_key;
+ uchar *tmp_select_ignore;
+ st_vp_ft_info *tmp_ft_info;
+ DBUG_ENTER("ha_vp::ft_init_ext");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp flags=%u", flags));
+ DBUG_PRINT("info",("vp inx=%u", inx));
+ DBUG_PRINT("info",("vp key=%s", key->c_ptr_safe()));
+ if (inx == NO_SUCH_KEY)
+ {
+ my_error(ER_FT_MATCHING_KEY_NOT_FOUND, MYF(0));
+ DBUG_RETURN(NULL);
+ }
+
+ tmp_ft_info = ft_current;
+ if (ft_current)
+ ft_current = ft_current->next;
+ else {
+ ft_current = ft_first;
+ memset(ft_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ }
+
+ if (!ft_current)
+ {
+ if (!(ft_current = (st_vp_ft_info *)
+ my_malloc(sizeof(st_vp_ft_info), MYF(MY_WME | MY_ZEROFILL))))
+ {
+ store_error_num = HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(NULL);
+ }
+ if (tmp_ft_info)
+ tmp_ft_info->next = ft_current;
+ else
+ ft_first = ft_current;
+ }
+
+ if (lock_mode > 0 || lock_type_ext == F_WRLCK)
+ {
+ tmp_select_ignore = select_ignore_with_lock;
+ } else {
+ tmp_select_ignore = select_ignore;
+ }
+
+ tmp_correspond_key = share->keys[inx].correspond_key;
+ while (vp_bit_is_set(tmp_select_ignore, tmp_correspond_key->table_idx))
+ {
+ if (!(tmp_correspond_key = tmp_correspond_key->next))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_KEY_NUM,
+ ER_VP_IGNORED_CORRESPOND_KEY_STR, MYF(0), inx);
+ store_error_num = ER_VP_IGNORED_CORRESPOND_KEY_NUM;
+ DBUG_RETURN(NULL);
+ }
+ }
+ ft_current->target = tmp_correspond_key;
+
+ ft_current->please = &vp_ft_vft;
+ ft_current->file = this;
+ ft_current->used_in_where = (flags & FT_SORTED);
+ ft_current->flags = flags;
+ ft_current->inx = inx;
+ ft_current->key = key;
+
+ ft_current->ft_handler =
+ part_tables[ft_current->target->table_idx].table->file->ft_init_ext(
+ flags, ft_current->target->key_idx, key);
+ part_tables[ft_current->target->table_idx].table->file->ft_handler =
+ ft_current->ft_handler;
+ vp_set_bit(ft_inited_tables, ft_current->target->table_idx);
+
+ ft_count++;
+
+ DBUG_RETURN((FT_INFO *) ft_current);
+}
+
+int ha_vp::ft_init()
+{
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::ft_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ ft_inited = TRUE;
+ if (store_error_num)
+ DBUG_RETURN(store_error_num);
+ if (active_index == MAX_KEY && inited == NONE)
+ {
+ rnd_scan = TRUE;
+ DBUG_PRINT("info",("vp init_rnd_bitmap=%s",
+ init_sel_rnd_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (!table->pos_in_table_list->parent_l && lock_type_ext == F_WRLCK)
+ {
+ check_and_set_bitmap_for_update(TRUE);
+ }
+#endif
+ init_select_column(TRUE);
+ memset(rnd_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ rnd_init_and_first = TRUE;
+ ft_init_without_index_init = TRUE;
+ } else {
+ ft_init_idx = active_index;
+ ft_init_without_index_init = FALSE;
+ check_select_column(FALSE);
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(ft_inited_tables, roop_count) &&
+ (error_num = part_tables[roop_count].table->file->ft_init())
+ )
+ goto error;
+ }
+ DBUG_RETURN(0);
+
+error:
+ for (roop_count--; roop_count >= 0; roop_count--)
+ {
+ if (vp_bit_is_set(ft_inited_tables, roop_count))
+ part_tables[roop_count].table->file->ft_end();
+ }
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_ft_init()
+{
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::pre_ft_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ ft_inited = TRUE;
+ if (store_error_num)
+ DBUG_RETURN(store_error_num);
+ if (active_index == MAX_KEY && inited == NONE)
+ {
+ rnd_scan = TRUE;
+ DBUG_PRINT("info",("vp init_rnd_bitmap=%s",
+ init_sel_rnd_bitmap ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ if (!table->pos_in_table_list->parent_l && lock_type_ext == F_WRLCK)
+ {
+ check_and_set_bitmap_for_update(TRUE);
+ }
+#endif
+ init_select_column(TRUE);
+ memset(rnd_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+ memset(pruned_tables, 0, sizeof(uchar) * share->use_tables_size);
+ pruned = FALSE;
+ rnd_init_and_first = TRUE;
+ ft_init_without_index_init = TRUE;
+ } else {
+ ft_init_idx = active_index;
+ ft_init_without_index_init = FALSE;
+ check_select_column(FALSE);
+ }
+ bulk_access_pre_called = TRUE;
+ need_bulk_access_finish = FALSE;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(ft_inited_tables, roop_count) &&
+ (error_num = part_tables[roop_count].table->file->pre_ft_init())
+ )
+ goto error;
+ }
+ DBUG_RETURN(0);
+
+error:
+ for (roop_count--; roop_count >= 0; roop_count--)
+ {
+ if (vp_bit_is_set(ft_inited_tables, roop_count))
+ part_tables[roop_count].table->file->pre_ft_end();
+ }
+ DBUG_RETURN(error_num);
+}
+#endif
+
+void ha_vp::ft_end()
+{
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::ft_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ rnd_scan = FALSE;
+ ft_inited = FALSE;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(ft_inited_tables, roop_count))
+ {
+ part_tables[roop_count].table->file->ft_end();
+ }
+ if (
+ ft_init_without_index_init &&
+ vp_bit_is_set(rnd_inited_tables, roop_count)
+ ) {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p", part_tables[roop_count].table));
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_index_or_rnd_end()))
+ store_error_num = error_num;
+ }
+ }
+ handler::ft_end();
+ DBUG_VOID_RETURN;
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_ft_end()
+{
+ int error_num;
+ DBUG_ENTER("ha_vp::pre_ft_end");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp table=%p", table));
+ DBUG_ASSERT(!vp_bit_is_set(rnd_inited_tables, child_table_idx));
+ rnd_scan = FALSE;
+ ft_inited = FALSE;
+ error_num = 0;
+ if (vp_bit_is_set(ft_inited_tables, child_table_idx))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", child_table_idx));
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[child_table_idx].table));
+ error_num =
+ part_tables[child_table_idx].table->file->pre_ft_end();
+ }
+ if (
+ !error_num &&
+ ft_init_without_index_init &&
+ vp_bit_is_set(rnd_inited_tables, child_table_idx)
+ ) {
+ error_num =
+ part_tables[child_table_idx].table->file->ha_pre_rnd_end();
+ }
+ bulk_access_pre_called = FALSE;
+ if (!error_num && need_bulk_access_finish)
+ DBUG_RETURN(ER_NOT_SUPPORTED_YET);
+ DBUG_RETURN(0);
+}
+#endif
+
+int ha_vp::ft_read_init()
+{
+ int error_num;
+ DBUG_ENTER("ha_vp::ft_read_init");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (ft_init_without_index_init && rnd_init_and_first)
+ {
+ check_select_column(TRUE);
+ DBUG_PRINT("info",("vp cb_state=%d", cb_state));
+ if ((error_num = set_rnd_bitmap()))
+ DBUG_RETURN(error_num);
+ cb_state = CB_SEL_RND;
+ rnd_init_and_first = FALSE;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::pre_ft_read(
+ bool use_parallel
+) {
+ int error_num;
+ TABLE *table2;
+ DBUG_ENTER("ha_vp::pre_ft_read");
+ DBUG_PRINT("info",("vp this=%p", this));
+ use_pre_call = TRUE;
+ if ((error_num = ft_read_init()))
+ DBUG_RETURN(error_num);
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (single_table)
+ need_bulk_access_finish = FALSE;
+ else
+ need_bulk_access_finish = TRUE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+#endif
+
+ table2 = part_tables[child_table_idx].table;
+ DBUG_RETURN(table2->file->pre_ft_read(use_parallel));
+}
+
+int ha_vp::ft_read(
+ uchar *buf
+) {
+ int error_num;
+ TABLE *table2;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ DBUG_ENTER("ha_vp::ft_read");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (use_pre_call)
+ use_pre_call = FALSE;
+ else if ((error_num = ft_read_init()))
+ DBUG_RETURN(error_num);
+
+ table2 = part_tables[child_table_idx].table;
+ do {
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ if ((error_num = table2->file->ha_ft_read(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])))
+#else
+ if ((error_num = table2->file->ft_read(
+ vp_bit_is_set(share->same_columns, child_table_idx) ?
+ buf : table2->record[0])))
+#endif
+ {
+ if (error_num == HA_ERR_RECORD_DELETED)
+ continue;
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if ((error_num = get_child_record_by_idx(child_table_idx, ptr_diff)))
+ {
+ table->status = table2->status;
+ DBUG_RETURN(error_num);
+ }
+ if (
+ !single_table &&
+ (error_num = get_child_record_by_pk(ptr_diff)) &&
+ error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ } while (error_num);
+ table->status = table2->status;
+ DBUG_RETURN(0);
+}
+
+int ha_vp::info(
+ uint flag
+) {
+ int error_num, roop_count, roop_count2, info_src_table, table_idx, key_idx;
+ handler *child_file;
+ ha_statistics *child_stats;
+ time_t create_time, check_time, update_time;
+ ha_rows records;
+ ulong mean_rec_length;
+ uint block_size;
+ ulonglong data_file_length, max_data_file_length, index_file_length,
+ auto_increment_value;
+ KEY *key_info, *key_info2;
+ DBUG_ENTER("ha_vp::info");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp flag=%x", flag));
+
+#if MYSQL_VERSION_ID < 50500
+ if (table->children_attached || is_clone)
+#else
+ DBUG_PRINT("info",("vp children_attached=%d", children_attached));
+ if (children_attached || is_clone)
+#endif
+ {
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ memset(use_tables3, 0, sizeof(uchar) * share->use_tables_size);
+ if (flag & HA_STATUS_ERRKEY)
+ {
+ DBUG_PRINT("info",("vp dup_table_idx=%d", dup_table_idx));
+ child_file = part_tables[dup_table_idx].table->file;
+ if ((error_num = child_file->info(flag)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(use_tables3, dup_table_idx);
+
+ errkey = child_file->errkey;
+ DBUG_PRINT("info",("vp errkey=%d", errkey));
+ }
+
+ if (flag & (HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE |
+ HA_STATUS_AUTO))
+ {
+ if (share->info_src_table)
+ info_src_table = share->info_src_table - 1;
+ else
+ info_src_table = 0;
+
+ child_file = part_tables[info_src_table].table->file;
+ if ((error_num = child_file->info(flag)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(use_tables3, info_src_table);
+
+ child_stats = &child_file->stats;
+ update_time = child_stats->update_time;
+ max_data_file_length = child_stats->max_data_file_length;
+ create_time = child_stats->create_time;
+ block_size = child_stats->block_size;
+ data_file_length = child_stats->data_file_length;
+ index_file_length = child_stats->index_file_length;
+ records = child_stats->records;
+ mean_rec_length = child_stats->mean_rec_length;
+ check_time = child_stats->check_time;
+
+ if (
+ (flag & HA_STATUS_AUTO) &&
+ info_src_table != share->auto_increment_table
+ ) {
+ child_file = part_tables[share->auto_increment_table].table->file;
+ if ((error_num = child_file->info(flag)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(use_tables3, share->auto_increment_table);
+ child_stats = &child_file->stats;
+ auto_increment_value = child_stats->auto_increment_value;
+ } else
+ auto_increment_value = child_stats->auto_increment_value;
+
+ if (!share->info_src_table)
+ {
+ for (roop_count = 1; roop_count < share->table_count; roop_count++)
+ {
+ child_file = part_tables[roop_count].table->file;
+ if ((error_num = child_file->info(flag)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(use_tables3, roop_count);
+
+ child_stats = &child_file->stats;
+ if (difftime(child_stats->update_time, update_time) > 0)
+ update_time = child_stats->update_time;
+ max_data_file_length += child_stats->max_data_file_length;
+ if (difftime(child_stats->create_time, create_time) > 0)
+ create_time = child_stats->create_time;
+ if (block_size < child_stats->block_size)
+ block_size = child_stats->block_size;
+ data_file_length += child_stats->data_file_length;
+ index_file_length += child_stats->index_file_length;
+ mean_rec_length += child_stats->mean_rec_length;
+ if (difftime(child_stats->check_time, check_time) > 0)
+ check_time = child_stats->check_time;
+ }
+ }
+ if (flag & HA_STATUS_CONST)
+ {
+ for (roop_count = 0; roop_count < (int) table_share->keys;
+ roop_count++)
+ {
+ table_idx = share->keys[roop_count].correspond_key->table_idx;
+ key_idx = share->keys[roop_count].correspond_key->key_idx;
+ if (vp_bit_is_set(use_tables3, table_idx))
+ {
+ child_file = part_tables[table_idx].table->file;
+ if ((error_num = child_file->info(flag)))
+ DBUG_RETURN(error_num);
+ vp_set_bit(use_tables3, table_idx);
+ }
+ key_info = &table->key_info[roop_count];
+ key_info2 = &part_tables[table_idx].table->key_info[key_idx];
+ for (roop_count2 = 0;
+ roop_count2 < (int) vp_user_defined_key_parts(key_info);
+ roop_count2++)
+ key_info->rec_per_key[roop_count2] =
+ key_info2->rec_per_key[roop_count2];
+ }
+ }
+
+ if (flag & HA_STATUS_TIME)
+ {
+#ifndef DBUG_OFF
+ {
+ struct tm *ts, tmp_ts;
+ char buf[80];
+ ts = localtime_r(&check_time, &tmp_ts);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
+ DBUG_PRINT("info",("vp update_time=%s", buf));
+ }
+#endif
+ stats.update_time = (ulong) update_time;
+ }
+ if (flag & HA_STATUS_CONST)
+ {
+ DBUG_PRINT("info",("vp max_data_file_length=%llu",
+ max_data_file_length));
+ stats.max_data_file_length = max_data_file_length;
+#ifndef DBUG_OFF
+ {
+ struct tm *ts, tmp_ts;
+ char buf[80];
+ ts = localtime_r(&check_time, &tmp_ts);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
+ DBUG_PRINT("info",("vp create_time=%s", buf));
+ }
+#endif
+ stats.create_time = (ulong) create_time;
+ DBUG_PRINT("info",("vp block_size=%u", block_size));
+ stats.block_size = block_size;
+ }
+ if (flag & HA_STATUS_VARIABLE)
+ {
+ DBUG_PRINT("info",("vp data_file_length=%llu", data_file_length));
+ stats.data_file_length = data_file_length;
+ DBUG_PRINT("info",("vp index_file_length=%llu", index_file_length));
+ stats.index_file_length = index_file_length;
+ DBUG_PRINT("info",("vp records=%llu", records));
+ stats.records = records;
+ DBUG_PRINT("info",("vp mean_rec_length=%lu", mean_rec_length));
+ stats.mean_rec_length = mean_rec_length;
+#ifndef DBUG_OFF
+ {
+ struct tm *ts, tmp_ts;
+ char buf[80];
+ ts = localtime_r(&check_time, &tmp_ts);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
+ DBUG_PRINT("info",("vp check_time=%s", buf));
+ }
+#endif
+ stats.check_time = (ulong) check_time;
+ }
+ if (flag & HA_STATUS_AUTO)
+ {
+ DBUG_PRINT("info",("vp block_size=%u", block_size));
+ stats.auto_increment_value = auto_increment_value;
+ }
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+ha_rows ha_vp::records()
+{
+ int info_src_table;
+ DBUG_ENTER("ha_vp::records");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (share->info_src_table)
+ info_src_table = share->info_src_table - 1;
+ else
+ info_src_table = 0;
+
+ if (part_tables[info_src_table].table->file->ha_table_flags() |
+ HA_HAS_RECORDS)
+ DBUG_RETURN(part_tables[info_src_table].table->file->records());
+ else {
+ int roop_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->ha_table_flags() |
+ HA_HAS_RECORDS)
+ DBUG_RETURN(part_tables[roop_count].table->file->records());
+ }
+ }
+ DBUG_RETURN(HA_POS_ERROR);
+}
+
+ha_rows ha_vp::records_in_range(
+ uint idx,
+ key_range *start_key,
+ key_range *end_key
+) {
+ int error_num, active_index_bak, roop_count;
+ ha_rows res_rows;
+ KEY *key_info, *key_info2;
+ DBUG_ENTER("ha_vp::records_in_range");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ DBUG_PRINT("info",("vp start_key=%p", start_key));
+ DBUG_PRINT("info",("vp end_key=%p", end_key));
+ child_keyread = FALSE;
+ single_table = FALSE;
+ memcpy(work_bitmap3, table->read_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, table->write_set->bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ if (
+ (error_num = choose_child_index(idx, work_bitmap3, work_bitmap4,
+ &child_table_idx, &child_key_idx))
+ )
+ DBUG_RETURN((ha_rows) 0);
+ set_child_pt_bitmap();
+
+ active_index_bak = active_index;
+ active_index = idx;
+ if (start_key)
+ {
+ child_start_key.keypart_map = start_key->keypart_map;
+ child_start_key.flag = start_key->flag;
+ child_start_key.key = create_child_key(
+ start_key->key, child_key_different, start_key->keypart_map,
+ start_key->length, &child_start_key.length);
+ }
+ if (end_key)
+ {
+ child_end_key.keypart_map = end_key->keypart_map;
+ child_end_key.flag = end_key->flag;
+ child_end_key.key = create_child_key(
+ end_key->key, child_end_key_different, end_key->keypart_map,
+ end_key->length, &child_end_key.length);
+ }
+ active_index = active_index_bak;
+ res_rows = part_tables[child_table_idx].table->file->records_in_range(
+ child_key_idx,
+ start_key ? &child_start_key : NULL,
+ end_key ? &child_end_key : NULL);
+
+ key_info = &table->key_info[idx];
+ key_info2 = &part_tables[child_table_idx].table->key_info[child_key_idx];
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info); roop_count++)
+ key_info->rec_per_key[roop_count] = key_info2->rec_per_key[roop_count];
+ DBUG_RETURN(res_rows);
+}
+
+const char *ha_vp::table_type() const
+{
+ DBUG_ENTER("ha_vp::table_type");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN("VP");
+}
+
+#if MYSQL_VERSION_ID < 50500
+static ulonglong vp_table_flags_msm = 0;
+#else
+#ifdef HA_CAN_MULTISTEP_MERGE
+static ulonglong vp_table_flags_msm = HA_CAN_MULTISTEP_MERGE;
+#else
+static ulonglong vp_table_flags_msm = 0;
+#endif
+#endif
+
+ulonglong ha_vp::table_flags() const
+{
+ DBUG_ENTER("ha_vp::table_flags");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(
+ HA_REC_NOT_IN_SEQ |
+ HA_CAN_GEOMETRY |
+ HA_NULL_IN_KEY |
+ HA_CAN_INDEX_BLOBS |
+ HA_AUTO_PART_KEY |
+ HA_REQUIRE_PRIMARY_KEY |
+ HA_CAN_RTREEKEYS |
+ HA_PRIMARY_KEY_REQUIRED_FOR_DELETE |
+ /* HA_NO_PREFIX_CHAR_KEYS | */
+ HA_CAN_FULLTEXT |
+ HA_CAN_SQL_HANDLER |
+ HA_FILE_BASED |
+ HA_CAN_INSERT_DELAYED |
+ HA_CAN_BIT_FIELD |
+ HA_NO_COPY_ON_ALTER |
+ vp_table_flags_msm |
+ additional_table_flags |
+ (share ? share->additional_table_flags : 0)
+ );
+}
+
+const char *ha_vp::index_type(
+ uint key_number
+) {
+ KEY *key_info;
+ DBUG_ENTER("ha_vp::index_type");
+ DBUG_PRINT("info",("vp this=%p", this));
+ key_info = &table_share->key_info[key_number];
+ DBUG_RETURN(
+ (key_info->flags & HA_FULLTEXT) ? "FULLTEXT" :
+ (key_info->flags & HA_SPATIAL) ? "SPATIAL" :
+ (key_info->algorithm == HA_KEY_ALG_HASH) ? "HASH" :
+ (key_info->algorithm == HA_KEY_ALG_RTREE) ? "RTREE" :
+ "BTREE"
+ );
+}
+
+ulong ha_vp::index_flags(
+ uint idx,
+ uint part,
+ bool all_parts
+) const {
+ KEY *key_info;
+ DBUG_ENTER("ha_vp::index_flags");
+ DBUG_PRINT("info",("vp this=%p", this));
+ key_info = &table_share->key_info[idx];
+ DBUG_RETURN(
+ (key_info->algorithm == HA_KEY_ALG_FULLTEXT) ?
+ 0 :
+ (key_info->algorithm == HA_KEY_ALG_HASH) ?
+ HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR :
+ HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE |
+ HA_KEYREAD_ONLY
+ );
+}
+
+uint ha_vp::max_supported_record_length() const
+{
+ DBUG_ENTER("ha_vp::max_supported_record_length");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(HA_MAX_REC_LENGTH);
+}
+
+uint ha_vp::max_supported_keys() const
+{
+ DBUG_ENTER("ha_vp::max_supported_keys");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(MAX_KEY);
+}
+
+uint ha_vp::max_supported_key_parts() const
+{
+ DBUG_ENTER("ha_vp::max_supported_key_parts");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(MAX_REF_PARTS);
+}
+
+uint ha_vp::max_supported_key_length() const
+{
+ DBUG_ENTER("ha_vp::max_supported_key_length");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(VP_MAX_KEY_LENGTH);
+}
+
+uint ha_vp::max_supported_key_part_length() const
+{
+ DBUG_ENTER("ha_vp::max_supported_key_part_length");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(VP_MAX_KEY_LENGTH);
+}
+
+uint8 ha_vp::table_cache_type()
+{
+ DBUG_ENTER("ha_vp::table_cache_type");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(share->support_table_cache);
+}
+
+#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
+bool ha_vp::need_info_for_auto_inc()
+{
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::need_info_for_auto_inc");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(file->need_info_for_auto_inc());
+}
+#endif
+
+int ha_vp::update_auto_increment()
+{
+ int error_num;
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::update_auto_increment");
+ DBUG_PRINT("info",("vp this=%p", this));
+ error_num = file->update_auto_increment();
+ insert_id_for_cur_row = file->insert_id_for_cur_row;
+ DBUG_PRINT("info",("vp insert_id_for_cur_row=%llu", insert_id_for_cur_row));
+ DBUG_RETURN(error_num);
+}
+
+void ha_vp::set_next_insert_id(
+ ulonglong id
+) {
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::set_next_insert_id");
+ DBUG_PRINT("info",("vp this=%p", this));
+ file->set_next_insert_id(id);
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::get_auto_increment(
+ ulonglong offset,
+ ulonglong increment,
+ ulonglong nb_desired_values,
+ ulonglong *first_value,
+ ulonglong *nb_reserved_values
+) {
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::get_auto_increment");
+ DBUG_PRINT("info",("vp this=%p", this));
+ file->get_auto_increment(
+ offset,
+ increment,
+ nb_desired_values,
+ first_value,
+ nb_reserved_values
+ );
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::restore_auto_increment(
+ ulonglong prev_insert_id
+) {
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::restore_auto_increment");
+ DBUG_PRINT("info",("vp this=%p", this));
+ file->restore_auto_increment(prev_insert_id);
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::release_auto_increment()
+{
+ int roop_count;
+/*
+ handler *file = part_tables[share->auto_increment_table].table->file;
+*/
+ DBUG_ENTER("ha_vp::release_auto_increment");
+ DBUG_PRINT("info",("vp this=%p", this));
+/*
+ file->ha_release_auto_increment();
+*/
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ part_tables[roop_count].table->file->ha_release_auto_increment();
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::reset_auto_increment(
+ ulonglong value
+) {
+ handler *file = part_tables[share->auto_increment_table].table->file;
+ DBUG_ENTER("ha_vp::reset_auto_increment");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(file->ha_reset_auto_increment(value));
+}
+
+#ifdef VP_HANDLER_START_BULK_INSERT_HAS_FLAGS
+void ha_vp::start_bulk_insert(
+ ha_rows rows,
+ uint flags
+)
+#else
+void ha_vp::start_bulk_insert(
+ ha_rows rows
+)
+#endif
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::start_bulk_insert");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (
+ !table->next_number_field ||
+ vp_param_allow_bulk_autoinc(ha_thd(), share->allow_bulk_autoinc)
+ ) {
+ bulk_insert = TRUE;
+ if (!init_ins_bitmap)
+ {
+ int child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ memcpy(ins_child_bitmaps[0][roop_count], table->read_set->bitmap,
+ part_tables[roop_count].table->s->column_bitmap_size);
+ memcpy(ins_child_bitmaps[1][roop_count], table->write_set->bitmap,
+ part_tables[roop_count].table->s->column_bitmap_size);
+ }
+ }
+ child_table_idx = child_table_idx_bak;
+ init_ins_bitmap = TRUE;
+ cb_state = CB_INSERT;
+ } else if (cb_state != CB_INSERT)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ memcpy(table->read_set->bitmap, ins_child_bitmaps[0][roop_count],
+ part_tables[roop_count].table->s->column_bitmap_size);
+ memcpy(table->write_set->bitmap, ins_child_bitmaps[1][roop_count],
+ part_tables[roop_count].table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_INSERT;
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+#ifdef VP_HANDLER_START_BULK_INSERT_HAS_FLAGS
+ part_tables[roop_count].table->file->ha_start_bulk_insert(rows, flags);
+#else
+ part_tables[roop_count].table->file->ha_start_bulk_insert(rows);
+#endif
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::end_bulk_insert()
+{
+ DBUG_ENTER("ha_vp::end_bulk_insert");
+ DBUG_RETURN(end_bulk_insert(FALSE));
+}
+
+int ha_vp::end_bulk_insert(
+ bool abort
+) {
+ int error_num = 0, error_num2, roop_count;
+ DBUG_ENTER("ha_vp::end_bulk_insert");
+ DBUG_PRINT("info",("vp this=%p", this));
+ bulk_insert = FALSE;
+ if (
+ !table->next_number_field ||
+ vp_param_allow_bulk_autoinc(ha_thd(), share->allow_bulk_autoinc)
+ ) {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ if ((error_num2 =
+ part_tables[roop_count].table->file->ha_end_bulk_insert()))
+ error_num = error_num2;
+ }
+ }
+ }
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::write_row(
+ uchar *buf
+) {
+ int error_num = 0, roop_count, roop_count2, first_insert = -1;
+ uint16 field_index;
+ THD *thd = table->in_use;
+ TABLE *child_table;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ int child_binlog = vp_param_child_binlog(thd, share->child_binlog);
+ ulonglong option_backup = 0;
+ longlong auto_inc_val;
+#ifndef WITHOUT_VP_BG_ACCESS
+ int bgi_mode = vp_param_bgi_mode(thd, share->bgi_mode);
+ VP_BG_BASE *base;
+#endif
+ DBUG_ENTER("ha_vp::write_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+ dup_table_idx = share->table_count;
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ {
+ bgi_mode = 0;
+ if (cb_state != CB_INSERT)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info_exec_tgt->ins_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info_exec_tgt->ins_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_INSERT;
+ }
+ } else {
+#endif
+#ifndef VP_WITHOUT_HA_STATISTIC_INCREMENT
+ ha_statistic_increment(&SSV::ha_write_count);
+#endif
+#ifdef VP_TABLE_HAS_TIMESTAMP_FIELD_TYPE
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
+ table->timestamp_field->set_time();
+#endif
+ if (!bulk_insert && !init_ins_bitmap)
+ {
+ int child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ child_table = part_tables[roop_count].table;
+ memcpy(ins_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(ins_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ child_table_idx = child_table_idx_bak;
+ init_ins_bitmap = TRUE;
+ cb_state = CB_INSERT;
+ } else if (cb_state != CB_INSERT)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ ins_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ ins_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_INSERT;
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+
+ memset(use_tables, ~((uchar) 0), sizeof(uchar) * share->use_tables_size);
+ memset(use_tables2, ~((uchar) 0), sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table %d has same columns", roop_count));
+ continue;
+ }
+ restore_record(part_tables[roop_count].table, s->default_values);
+ }
+ set_child_pt_bitmap();
+ set_child_record_for_update(ptr_diff, 0, TRUE, FALSE);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ set_child_record_for_insert(ptr_diff, roop_count);
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ option_backup = thd->options;
+ thd->options &= ~OPTION_BIN_LOG;
+#else
+ option_backup = thd->variables.option_bits;
+ thd->variables.option_bits &= ~OPTION_BIN_LOG;
+#endif
+ }
+
+ if (
+ table->next_number_field &&
+ !(vp_bit_is_set(update_ignore, share->auto_increment_table))
+ ) {
+ first_insert = share->auto_increment_table;
+ } else {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ first_insert = roop_count;
+ break;
+ }
+ }
+ }
+
+ child_table = part_tables[first_insert].table;
+ if (!suppress_autoinc)
+ {
+ child_table->next_number_field = child_table->found_next_number_field;
+ if (table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ table->auto_increment_field_not_null;
+ else if (child_table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ !child_table->next_number_field->is_null();
+ }
+ DBUG_PRINT("info",("vp child_table[%d]->record[0]=%p",
+ first_insert, child_table->record[0]));
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map =
+ dbug_tmp_use_all_columns(table, child_table->read_set);
+#endif
+ error_num = child_table->file->ha_write_row(child_table->record[0]);
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(child_table->read_set, tmp_map);
+#endif
+ if (error_num)
+ {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = first_insert;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ if (
+ table->next_number_field &&
+ child_table->next_number_field &&
+ (
+ !child_table->auto_increment_field_not_null ||
+ (
+ !table->next_number_field->val_int() &&
+ !(thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
+ )
+ )
+ ) {
+ table->next_number_field->set_notnull();
+ auto_inc_val = child_table->next_number_field->val_int();
+ table->file->insert_id_for_cur_row = auto_inc_val;
+ DBUG_PRINT("info",("vp auto_inc_val=%llu", auto_inc_val));
+ if ((error_num = table->next_number_field->store(
+ auto_inc_val, TRUE)))
+ {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = first_insert;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ for (roop_count2 = 0; roop_count2 < share->table_count; roop_count2++)
+ {
+ if (first_insert == roop_count2)
+ continue;
+ field_index = share->correspond_columns_p[table_share->fields *
+ roop_count2 + table->next_number_field->field_index];
+ if (
+ field_index < MAX_FIELDS &&
+ (error_num = part_tables[roop_count2].table->field[field_index]->
+ store(auto_inc_val, TRUE))
+ ) {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = roop_count2;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ }
+ }
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (roop_count == first_insert)
+ continue;
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (
+ bgi_mode &&
+ (child_table->file->ha_table_flags() & VP_CAN_BG_INSERT)
+ ) {
+ base = &bg_base[roop_count];
+ if ((error_num = create_bg_thread(base)))
+ {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ base->bg_command = VP_BG_COMMAND_INSERT;
+ if (!suppress_autoinc)
+ {
+ child_table->next_number_field =
+ child_table->found_next_number_field;
+ if (table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ table->auto_increment_field_not_null;
+ else if (child_table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ !child_table->next_number_field->is_null();
+ }
+ bg_kick(base);
+ } else {
+#endif
+ if (!suppress_autoinc)
+ {
+ child_table->next_number_field =
+ child_table->found_next_number_field;
+ if (table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ table->auto_increment_field_not_null;
+ else if (child_table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ !child_table->next_number_field->is_null();
+ }
+ DBUG_PRINT("info",("vp child_table[%d]->record[0]=%p",
+ roop_count, child_table->record[0]));
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map =
+ dbug_tmp_use_all_columns(table, child_table->read_set);
+#endif
+ VP_DBUG_PRINT_FIELD_VALUES(child_table, 0);
+ error_num =
+ child_table->file->ha_write_row(child_table->record[0]);
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(child_table->read_set, tmp_map);
+#endif
+ if (error_num)
+ {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ }
+ }
+
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ child_table = part_tables[roop_count].table;
+ if (
+ bgi_mode &&
+ (child_table->file->ha_table_flags() & VP_CAN_BG_INSERT)
+ ) {
+ base = &bg_base[roop_count];
+ bg_wait(base);
+ if (base->bg_error)
+ {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ error_num = base->bg_error;
+ goto error;
+ }
+ }
+ }
+#endif
+
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_RETURN(error_num);
+
+error:
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ base = &bg_base[roop_count];
+ if (base->bg_init)
+ bg_wait(base);
+ }
+#endif
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+int ha_vp::pre_write_row(
+ uchar *buf
+) {
+ int error_num = 0, roop_count, first_insert = -1;
+ THD *thd = table->in_use;
+ TABLE *child_table;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ int child_binlog = vp_param_child_binlog(thd, share->child_binlog);
+ ulonglong option_backup = 0;
+ DBUG_ENTER("ha_vp::pre_write_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+ dup_table_idx = share->table_count;
+#ifndef VP_WITHOUT_HA_STATISTIC_INCREMENT
+ ha_statistic_increment(&SSV::ha_write_count);
+#endif
+#ifdef VP_TABLE_HAS_TIMESTAMP_FIELD_TYPE
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
+ table->timestamp_field->set_time();
+#endif
+
+ if (!bulk_insert && !bulk_access_info_current->init_ins_bitmap)
+ {
+ int child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ child_table = part_tables[roop_count].table;
+ memcpy(bulk_access_info_current->ins_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(bulk_access_info_current->ins_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ child_table_idx = child_table_idx_bak;
+ bulk_access_info_current->init_ins_bitmap = TRUE;
+ cb_state = CB_INSERT;
+ } else if (cb_state != CB_INSERT)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info_current->ins_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info_current->ins_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_INSERT;
+ }
+
+ memset(use_tables2, ~((uchar) 0), sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table %d has same columns", roop_count));
+ continue;
+ }
+ restore_record(part_tables[roop_count].table, s->default_values);
+ }
+ set_child_pt_bitmap();
+ set_child_record_for_update(ptr_diff, 0, TRUE, FALSE);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ set_child_record_for_insert(ptr_diff, roop_count);
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ option_backup = thd->options;
+ thd->options &= ~OPTION_BIN_LOG;
+#else
+ option_backup = thd->variables.option_bits;
+ thd->variables.option_bits &= ~OPTION_BIN_LOG;
+#endif
+ }
+
+ if (
+ table->next_number_field &&
+ !(vp_bit_is_set(update_ignore, share->auto_increment_table))
+ ) {
+ first_insert = share->auto_increment_table;
+ } else {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ first_insert = roop_count;
+ break;
+ }
+ }
+ }
+
+ child_table = part_tables[first_insert].table;
+ if (!suppress_autoinc)
+ {
+ child_table->next_number_field = child_table->found_next_number_field;
+ if (table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ table->auto_increment_field_not_null;
+ else if (child_table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ !child_table->next_number_field->is_null();
+ }
+ if ((error_num =
+ child_table->file->ha_pre_write_row(child_table->record[0])))
+ {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = first_insert;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ need_bulk_access_finish = FALSE;
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (roop_count == first_insert)
+ continue;
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ if (!suppress_autoinc)
+ {
+ child_table->next_number_field =
+ child_table->found_next_number_field;
+ if (table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ table->auto_increment_field_not_null;
+ else if (child_table->next_number_field)
+ child_table->auto_increment_field_not_null =
+ !child_table->next_number_field->is_null();
+ }
+ if ((error_num =
+ child_table->file->ha_pre_write_row(child_table->record[0])))
+ {
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ child_table->next_number_field = NULL;
+ child_table->auto_increment_field_not_null = FALSE;
+ }
+ }
+
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_RETURN(error_num);
+
+error:
+ DBUG_RETURN(error_num);
+}
+#endif
+
+bool ha_vp::start_bulk_update()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::start_bulk_update");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->start_bulk_update())
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+
+int ha_vp::exec_bulk_update(
+ ha_rows *dup_key_found
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::exec_bulk_update");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->exec_bulk_update(
+ dup_key_found)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+#ifdef VP_END_BULK_UPDATE_RETURNS_INT
+int ha_vp::end_bulk_update()
+{
+ int roop_count, error_num;
+ DBUG_ENTER("ha_vp::end_bulk_update");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->end_bulk_update()))
+ {
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#else
+void ha_vp::end_bulk_update()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::end_bulk_update");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ part_tables[roop_count].table->file->end_bulk_update();
+ DBUG_VOID_RETURN;
+}
+#endif
+
+
+#ifdef VP_UPDATE_ROW_HAS_CONST_NEW_DATA
+int ha_vp::bulk_update_row(
+ const uchar *old_data,
+ const uchar *new_data,
+ ha_rows *dup_key_found
+)
+#else
+int ha_vp::bulk_update_row(
+ const uchar *old_data,
+ uchar *new_data,
+ ha_rows *dup_key_found
+)
+#endif
+{
+ int error_num, error_num2 = 0, roop_count;
+ THD *thd = table->in_use;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(new_data, table->record[0]);
+ my_ptrdiff_t ptr_diff2 = PTR_BYTE_DIFF(old_data, table->record[0]);
+ int child_binlog = vp_param_child_binlog(thd, share->child_binlog);
+ ulonglong option_backup = 0;
+ VP_KEY_COPY vp_key_copy;
+ TABLE *table2, *child_table;
+ int bgu_mode;
+ int bgi_mode;
+ uchar *insert_table;
+ bool rnd_state = (rnd_scan || cb_state == CB_SEL_RND);
+ DBUG_ENTER("ha_vp::bulk_update_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp old_data=%p", old_data));
+ DBUG_PRINT("info",("vp new_data=%p", new_data));
+ dup_table_idx = share->table_count;
+ if (!(insert_table =
+ (uchar *) my_alloca(sizeof(uchar) * share->use_tables_size)))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ memset(insert_table, 0, sizeof(uchar) * share->use_tables_size);
+#ifndef WITHOUT_VP_BG_ACCESS
+ bgu_mode = vp_param_bgu_mode(thd, share->bgu_mode);
+ bgi_mode = vp_param_bgi_mode(thd, share->bgi_mode);
+ VP_BG_BASE *base;
+#endif
+#ifndef VP_WITHOUT_HA_STATISTIC_INCREMENT
+ ha_statistic_increment(&SSV::ha_update_count);
+#endif
+#ifdef VP_TABLE_HAS_TIMESTAMP_FIELD_TYPE
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
+ table->timestamp_field->set_time();
+#endif
+ if (!init_upd_bitmap)
+ {
+ memset(use_tables2, 0, sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ if (set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE))
+ vp_set_bit(use_tables2, roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ child_table = part_tables[roop_count].table;
+ memcpy(upd_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(upd_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ init_upd_bitmap = TRUE;
+ cb_state = CB_UPDATE;
+ } else if (cb_state != CB_UPDATE)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ upd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ upd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_UPDATE;
+ }
+
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ option_backup = thd->options;
+ thd->options &= ~OPTION_BIN_LOG;
+#else
+ option_backup = thd->variables.option_bits;
+ thd->variables.option_bits &= ~OPTION_BIN_LOG;
+#endif
+ }
+ vp_key_copy.init = FALSE;
+ vp_key_copy.mem_root_init = FALSE;
+ vp_key_copy.ptr = NULL;
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ table2 = part_tables[roop_count].table;
+/*
+ DBUG_PRINT("info",("vp rnd_scan=%s", rnd_scan ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp use_tables[%d]=%s",
+ roop_count,
+ vp_bit_is_set(use_tables, roop_count) ? "TRUE" : "FALSE"));
+ DBUG_ASSERT(init_sel_key_bitmap || rnd_scan);
+ DBUG_PRINT("info",("vp sel_key_use_tables[%d]=%s",
+ roop_count,
+ vp_bit_is_set(sel_key_use_tables, roop_count) ? "TRUE" : "FALSE"));
+ if (
+ (rnd_scan && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_scan && !vp_bit_is_set(sel_key_use_tables, roop_count))
+ )
+*/
+ DBUG_PRINT("info",("vp rnd_state=%s",
+ rnd_state ? "TRUE" : "FALSE"));
+ DBUG_ASSERT(init_sel_key_bitmap || rnd_state);
+ if (
+ (rnd_state && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_state && !vp_bit_is_set(sel_key_use_tables, roop_count))
+ ) {
+ DBUG_PRINT("info",("vp call search_by_pk"));
+ if ((error_num = search_by_pk_for_update(roop_count, 1, &vp_key_copy,
+ ptr_diff2, bgu_mode)))
+ {
+ if (
+ !share->zero_record_update_mode ||
+ !vp_bit_is_set(select_ignore_with_lock, roop_count) ||
+ (error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE)
+ ) {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ vp_set_bit(insert_table, roop_count);
+ error_num = 0;
+ }
+ } else {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table %d has same columns",
+ roop_count));
+ } else
+ store_record(table2, record[1]);
+ }
+ }
+ }
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ (
+/*
+ (rnd_scan && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_scan && !vp_bit_is_set(sel_key_use_tables, roop_count))
+*/
+ (rnd_state && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_state && !vp_bit_is_set(sel_key_use_tables, roop_count))
+ ) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ table2 = part_tables[roop_count].table;
+ if (
+ (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) ||
+ (
+ bgi_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_INSERT)
+ )
+ ) {
+ base = &bg_base[roop_count];
+ bg_wait(base);
+ if (base->bg_error)
+ {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ error_num = base->bg_error;
+ goto error;
+ }
+ }
+ }
+ }
+#endif
+
+ error_num2 = HA_ERR_RECORD_IS_THE_SAME;
+ set_child_pt_bitmap();
+ set_child_record_for_update(ptr_diff, 0, TRUE, FALSE);
+ set_child_record_for_update(ptr_diff2, 1, FALSE, FALSE);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ DBUG_PRINT("info",("vp call ha_update_row"));
+ if (vp_bit_is_set(insert_table, roop_count))
+ {
+ if (!dup_key_found)
+ {
+ set_child_record_for_insert(ptr_diff, roop_count);
+#ifndef WITHOUT_VP_BG_ACCESS
+ table2 = part_tables[roop_count].table;
+ if (
+ bgi_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_INSERT)
+ ) {
+ base = &bg_base[roop_count];
+ if ((error_num = create_bg_thread(base)))
+ {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ goto error;
+ }
+ base->bg_command = VP_BG_COMMAND_INSERT;
+ bg_kick(base);
+ error_num2 = 0;
+ } else {
+#endif
+ if (
+ (error_num =
+ part_tables[roop_count].table->file->ha_write_row(
+ part_tables[roop_count].table->record[0]))
+ ) {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ goto error;
+ }
+ error_num2 = 0;
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ }
+ } else {
+#ifndef WITHOUT_VP_BG_ACCESS
+ table2 = part_tables[roop_count].table;
+ if (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) {
+ base = &bg_base[roop_count];
+ if ((error_num = create_bg_thread(base)))
+ {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ goto error;
+ }
+ base->bg_command = VP_BG_COMMAND_UPDATE;
+ bg_kick(base);
+ error_num2 = 0;
+ } else {
+#endif
+ if (
+ (
+ (
+ !dup_key_found &&
+ (error_num =
+ part_tables[roop_count].table->file->ha_update_row(
+ part_tables[roop_count].table->record[1],
+ part_tables[roop_count].table->record[0]))
+ ) ||
+ (
+ dup_key_found &&
+ (error_num =
+ part_tables[roop_count].table->file->ha_bulk_update_row(
+ part_tables[roop_count].table->record[1],
+ part_tables[roop_count].table->record[0],
+ dup_key_found))
+ )
+ ) &&
+ error_num != HA_ERR_RECORD_IS_THE_SAME
+ ) {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ goto error;
+ }
+ if (
+ error_num2 == HA_ERR_RECORD_IS_THE_SAME &&
+ error_num != HA_ERR_RECORD_IS_THE_SAME
+ )
+ error_num2 = 0;
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ }
+ }
+ }
+ my_afree(insert_table);
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ table2 = part_tables[roop_count].table;
+ if (
+ (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) ||
+ (
+ bgi_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_INSERT)
+ )
+ ) {
+ base = &bg_base[roop_count];
+ bg_wait(base);
+ if (
+ base->bg_error &&
+ base->bg_error != HA_ERR_RECORD_IS_THE_SAME
+ ) {
+ dup_table_idx = roop_count;
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ error_num = base->bg_error;
+ goto error;
+ }
+ if (
+ error_num2 == HA_ERR_RECORD_IS_THE_SAME &&
+ base->bg_error != HA_ERR_RECORD_IS_THE_SAME
+ )
+ error_num2 = 0;
+ }
+ }
+ }
+#endif
+
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+ DBUG_RETURN(error_num2);
+
+error:
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ base = &bg_base[roop_count];
+ if (base->bg_init)
+ bg_wait(base);
+ }
+ }
+#endif
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+#ifdef _MSC_VER
+ vp_my_free(insert_table, MYF(MY_WME));
+#endif
+ DBUG_RETURN(error_num);
+}
+
+#ifdef VP_UPDATE_ROW_HAS_CONST_NEW_DATA
+int ha_vp::update_row(
+ const uchar *old_data,
+ const uchar *new_data
+)
+#else
+int ha_vp::update_row(
+ const uchar *old_data,
+ uchar *new_data
+)
+#endif
+{
+ DBUG_ENTER("ha_vp::update_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(bulk_update_row(old_data, new_data, NULL));
+}
+
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+#ifdef VP_MDEV_16246
+int ha_vp::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_vp::direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+)
+#endif
+{
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+#endif
+ DBUG_ENTER("ha_vp::direct_update_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+/*
+ if (
+ !set_top_table_fields &&
+ (error_num = set_top_table_and_fields(table, table->field,
+ table_share->fields, TRUE))
+ )
+ DBUG_RETURN(error_num);
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->
+ set_top_table_and_fields(
+ top_table,
+ top_table_field_for_childs[roop_count],
+ top_table_fields)))
+ DBUG_RETURN(error_num);
+ }
+*/
+ if (inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ memset(use_tables2, 0, sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ if (set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE))
+ vp_set_bit(use_tables2, roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+
+ set_child_pt_bitmap();
+ set_child_record_for_update(PTR_BYTE_DIFF(new_data, table->record[0]), 0,
+ TRUE, FALSE);
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (!correspond_key || correspond_key->table_idx > roop_count)
+ {
+ DBUG_PRINT("info",("vp correspond key is not found"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ child_multi_range[roop_count] = *ranges;
+ child_multi_range[roop_count].start_key.key = create_child_key(
+ ranges->start_key.key, &child_key_buff[MAX_KEY_LENGTH * roop_count],
+ ranges->start_key.keypart_map, ranges->start_key.length,
+ &child_multi_range[roop_count].start_key.length
+ );
+ child_ranges = &child_multi_range[roop_count];
+ }
+#endif
+#ifdef VP_MDEV_16246
+ if ((error_num = part_tables[roop_count].table->file->
+ ha_direct_update_rows_init(update_fields, mode, child_ranges,
+ range_count, sorted,
+ part_tables[roop_count].table->record[0])))
+#else
+ if ((error_num = part_tables[roop_count].table->file->
+ ha_direct_update_rows_init(mode, child_ranges, range_count, sorted,
+ part_tables[roop_count].table->record[0])))
+#endif
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+#endif
+}
+#else
+#ifdef VP_MDEV_16246
+int ha_vp::direct_update_rows_init(
+ List<Item> *update_fields
+)
+#else
+int ha_vp::direct_update_rows_init()
+#endif
+{
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+#endif
+ DBUG_ENTER("ha_vp::direct_update_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ memset(use_tables2, 0, sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ if (set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE))
+ vp_set_bit(use_tables2, roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+#ifdef VP_MDEV_16246
+ if ((error_num = part_tables[roop_count].table->file->
+ direct_update_rows_init(update_fields)))
+#else
+ if ((error_num = part_tables[roop_count].table->file->
+ direct_update_rows_init()))
+#endif
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+#endif
+}
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::pre_direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+) {
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+#endif
+ DBUG_ENTER("ha_vp::pre_direct_update_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (pre_inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ memset(use_tables2, 0, sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ if (set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE))
+ vp_set_bit(use_tables2, roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (pre_inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+
+ set_child_pt_bitmap();
+ set_child_record_for_update(PTR_BYTE_DIFF(new_data, table->record[0]), 0,
+ TRUE, FALSE);
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ handler *file;
+ file = part_tables[roop_count].table->file;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (!correspond_key || correspond_key->table_idx > roop_count)
+ {
+ DBUG_PRINT("info",("vp correspond key is not found"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ child_multi_range[roop_count] = *ranges;
+ child_multi_range[roop_count].start_key.key = create_child_key(
+ ranges->start_key.key, &child_key_buff[MAX_KEY_LENGTH * roop_count],
+ ranges->start_key.keypart_map, ranges->start_key.length,
+ &child_multi_range[roop_count].start_key.length
+ );
+ child_ranges = &child_multi_range[roop_count];
+ }
+#endif
+ if ((error_num = file->
+ pre_direct_update_rows_init(mode, child_ranges, range_count, sorted,
+ part_tables[roop_count].table->record[0])))
+ {
+ if (error_num == HA_ERR_WRONG_COMMAND)
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ need_bulk_access_finish = FALSE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+ DBUG_RETURN(0);
+#endif
+}
+#else
+int ha_vp::pre_direct_update_rows_init()
+{
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+#endif
+ DBUG_ENTER("ha_vp::pre_direct_update_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_update"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (pre_inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ memset(use_tables2, 0, sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ if (set_child_bitmap(
+ (uchar *) table->write_set->bitmap,
+ roop_count, TRUE))
+ vp_set_bit(use_tables2, roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (pre_inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ handler *file;
+ file = part_tables[roop_count].table->file;
+ if ((error_num = file->
+ pre_direct_update_rows_init()))
+ {
+ if (error_num == HA_ERR_WRONG_COMMAND)
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ need_bulk_access_finish = FALSE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+ DBUG_RETURN(0);
+#endif
+}
+#endif
+#endif
+
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::direct_update_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data,
+ ha_rows *update_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::direct_update_rows");
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ file = part_tables[roop_count].table->file;
+ if (file->inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (do_init)
+ {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ if (
+ (error_num = file->ha_index_init(correspond_key->key_idx, FALSE))
+ )
+ DBUG_RETURN(error_num);
+ }
+
+ child_ranges = &child_multi_range[roop_count];
+ } else {
+#endif
+ if (do_init && (error_num = file->ha_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ error_num = file->
+ ha_direct_update_rows(child_ranges, range_count, sorted,
+ part_tables[roop_count].table->record[0], update_rows);
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ if (do_init)
+ error_num2 = file->ha_index_end();
+ } else {
+#endif
+ if (do_init)
+ error_num2 = file->ha_rnd_end();
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ if (!error_num)
+ error_num = error_num2;
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#else
+int ha_vp::direct_update_rows(
+ ha_rows *update_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::direct_update_rows");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ file = part_tables[roop_count].table->file;
+ if (file->inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+ if (do_init && (error_num = file->ha_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+ error_num = file->
+ ha_direct_update_rows(update_rows);
+ if (do_init)
+ error_num2 = file->ha_rnd_end();
+ if (!error_num)
+ error_num = error_num2;
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::pre_direct_update_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data,
+ uint *update_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::pre_direct_update_rows");
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ file = part_tables[roop_count].table->file;
+ if (file->pre_inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (
+ do_init &&
+ (error_num = file->ha_pre_index_init(correspond_key->key_idx, FALSE))
+ )
+ DBUG_RETURN(error_num);
+
+ child_ranges = &child_multi_range[roop_count];
+ } else {
+#endif
+ if (do_init && (error_num = file->ha_pre_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ error_num = file->
+ ha_pre_direct_update_rows(child_ranges, range_count, sorted,
+ part_tables[roop_count].table->record[0], update_rows);
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ if (do_init)
+ error_num2 = file->ha_pre_index_end();
+ } else {
+#endif
+ if (do_init)
+ error_num2 = file->ha_pre_rnd_end();
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ if (!error_num)
+ {
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ error_num = error_num2;
+ }
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#else
+int ha_vp::pre_direct_update_rows()
+{
+ int error_num, error_num2 = 0, roop_count;
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::pre_direct_update_rows");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ vp_bit_is_set(use_tables2, roop_count) &&
+ !(vp_bit_is_set(update_ignore, roop_count))
+ ) {
+ file = part_tables[roop_count].table->file;
+ if (file->pre_inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+ if (do_init && (error_num = file->ha_pre_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+ error_num = file->ha_pre_direct_update_rows();
+ if (do_init)
+ error_num2 = file->ha_pre_rnd_end();
+ if (!error_num)
+ {
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ error_num = error_num2;
+ }
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#endif
+#endif
+#endif
+
+bool ha_vp::start_bulk_delete()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::start_bulk_delete");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->start_bulk_delete())
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+
+int ha_vp::end_bulk_delete()
+{
+ int error_num = 0, tmp, roop_count;
+ DBUG_ENTER("ha_vp::end_bulk_delete");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((tmp = part_tables[roop_count].table->file->end_bulk_delete()))
+ error_num = tmp;
+ }
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::delete_row(
+ const uchar *buf
+) {
+ int error_num, roop_count;
+ THD *thd = table->in_use;
+ my_ptrdiff_t ptr_diff = PTR_BYTE_DIFF(buf, table->record[0]);
+ int child_binlog = vp_param_child_binlog(thd, share->child_binlog);
+ ulonglong option_backup = 0;
+ VP_KEY_COPY vp_key_copy;
+ TABLE *table2, *child_table;
+ int bgu_mode;
+ bool do_delete;
+ bool rnd_state = (rnd_scan || cb_state == CB_SEL_RND);
+ DBUG_ENTER("ha_vp::delete_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+#ifndef WITHOUT_VP_BG_ACCESS
+ bgu_mode = vp_param_bgu_mode(thd, share->bgu_mode);
+ VP_BG_BASE *base;
+#endif
+#ifndef VP_WITHOUT_HA_STATISTIC_INCREMENT
+ ha_statistic_increment(&SSV::ha_delete_count);
+#endif
+ if (!init_del_bitmap)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ child_table = part_tables[roop_count].table;
+ memcpy(del_child_bitmaps[0][roop_count], child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ init_del_bitmap = TRUE;
+ cb_state = CB_DELETE;
+ } else if (cb_state != CB_DELETE)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ del_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ del_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ cb_state = CB_DELETE;
+ }
+
+ memset(use_tables2, ~((uchar) 0), sizeof(uchar) * share->use_tables_size);
+ set_child_pt_bitmap();
+ set_child_record_for_update(ptr_diff, 0, FALSE, FALSE);
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ option_backup = thd->options;
+ thd->options &= ~OPTION_BIN_LOG;
+#else
+ option_backup = thd->variables.option_bits;
+ thd->variables.option_bits &= ~OPTION_BIN_LOG;
+#endif
+ }
+ vp_key_copy.init = FALSE;
+ vp_key_copy.mem_root_init = FALSE;
+ vp_key_copy.ptr = NULL;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ do_delete = TRUE;
+ if (
+/*
+ (rnd_scan && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_scan && !vp_bit_is_set(sel_key_use_tables, roop_count))
+*/
+ (rnd_state && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_state && !vp_bit_is_set(sel_key_use_tables, roop_count))
+ ) {
+ if ((error_num = search_by_pk_for_update(roop_count, 0, &vp_key_copy,
+ ptr_diff, bgu_mode)))
+ {
+ if (
+ !share->zero_record_update_mode ||
+ !vp_bit_is_set(select_ignore_with_lock, roop_count) ||
+ (error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE)
+ ) {
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ do_delete = FALSE;
+ }
+ }
+ if (do_delete)
+ {
+ table2 = part_tables[roop_count].table;
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) {
+ if (
+/*
+ (rnd_scan && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_scan && !vp_bit_is_set(sel_key_use_tables, roop_count))
+*/
+ (rnd_state && !vp_bit_is_set(use_tables, roop_count)) ||
+ (!rnd_state && !vp_bit_is_set(sel_key_use_tables, roop_count))
+ ) {
+ base = &bg_base[roop_count];
+ if ((error_num = create_bg_thread(base)))
+ {
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+ base->bg_command = VP_BG_COMMAND_DELETE;
+ bg_kick(base);
+ }
+ } else {
+#endif
+ if ((error_num = table2->file->ha_delete_row(table2->record[0])))
+ {
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ goto error;
+ }
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ }
+ }
+ }
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ table2 = part_tables[roop_count].table;
+ if (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) {
+ base = &bg_base[roop_count];
+ bg_wait(base);
+ if (base->bg_error)
+ {
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ error_num = base->bg_error;
+ goto error;
+ }
+ }
+ }
+ }
+#endif
+
+ if (!child_binlog)
+ {
+#if MYSQL_VERSION_ID < 50500
+ thd->options = option_backup;
+#else
+ thd->variables.option_bits = option_backup;
+#endif
+ }
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+ DBUG_RETURN(0);
+
+error:
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ base = &bg_base[roop_count];
+ if (base->bg_init)
+ bg_wait(base);
+ }
+ }
+#endif
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::direct_delete_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted
+) {
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+#endif
+ DBUG_ENTER("ha_vp::direct_delete_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+/*
+ if (
+ !set_top_table_fields &&
+ (error_num = set_top_table_and_fields(table, table->field,
+ table_share->fields, TRUE))
+ )
+ DBUG_RETURN(error_num);
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->
+ set_top_table_and_fields(
+ top_table,
+ top_table_field_for_childs[roop_count],
+ top_table_fields)))
+ DBUG_RETURN(error_num);
+ }
+*/
+ if (inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (!correspond_key || correspond_key->table_idx > roop_count)
+ {
+ DBUG_PRINT("info",("vp correspond key is not found"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ child_multi_range[roop_count] = *ranges;
+ child_multi_range[roop_count].start_key.key = create_child_key(
+ ranges->start_key.key, &child_key_buff[MAX_KEY_LENGTH * roop_count],
+ ranges->start_key.keypart_map, ranges->start_key.length,
+ &child_multi_range[roop_count].start_key.length);
+ child_ranges = &child_multi_range[roop_count];
+ }
+#endif
+ if ((error_num = part_tables[roop_count].table->file->
+ ha_direct_delete_rows_init(mode, child_ranges, range_count, sorted)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+#endif
+}
+#else
+int ha_vp::direct_delete_rows_init()
+{
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+#endif
+ DBUG_ENTER("ha_vp::direct_delete_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ if ((error_num = part_tables[roop_count].table->file->
+ direct_delete_rows_init()))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+#endif
+}
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::pre_direct_delete_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted
+) {
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+#endif
+ DBUG_ENTER("ha_vp::pre_direct_delete_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (pre_inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (pre_inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ handler *file;
+ file = part_tables[roop_count].table->file;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (!correspond_key || correspond_key->table_idx > roop_count)
+ {
+ DBUG_PRINT("info",("vp correspond key is not found"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ child_multi_range[roop_count] = *ranges;
+ child_multi_range[roop_count].start_key.key = create_child_key(
+ ranges->start_key.key, &child_key_buff[MAX_KEY_LENGTH * roop_count],
+ ranges->start_key.keypart_map, ranges->start_key.length,
+ &child_multi_range[roop_count].start_key.length);
+ child_ranges = &child_multi_range[roop_count];
+ }
+#endif
+ if ((error_num = file->
+ ha_pre_direct_delete_rows_init(mode, child_ranges, range_count,
+ sorted)))
+ {
+ if (error_num == HA_ERR_WRONG_COMMAND)
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ need_bulk_access_finish = FALSE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+ DBUG_RETURN(0);
+#endif
+}
+#else
+int ha_vp::pre_direct_delete_rows_init()
+{
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int error_num, roop_count, child_table_idx_bak = 0;
+#endif
+ DBUG_ENTER("ha_vp::pre_direct_delete_rows_init");
+#ifndef HANDLER_HAS_TOP_TABLE_FIELDS
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+#else
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *explain_update = get_explain_upd_del();
+ if (explain_update)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", explain_update->jtype));
+ if (
+ explain_update->jtype == JT_CONST ||
+ (explain_update->jtype == JT_RANGE && explain_update->rows == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+#else
+/*
+ JOIN *join = get_join();
+ if (join && vp_join_table_count(join) == 1 && join->join_tab)
+ {
+ DBUG_PRINT("info",("vp join_type=%d", join->join_tab->type));
+ if (
+ join->join_tab->type == JT_CONST ||
+ (join->join_tab->type == JT_RANGE && join->best_positions && join->best_positions[0].records_read == 1)
+ ) {
+ DBUG_PRINT("info",("vp const does not need direct_delete"));
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
+ }
+*/
+#endif
+ if (pre_inited != NONE)
+ child_table_idx_bak = child_table_idx;
+ child_table_idx = share->table_count;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ clear_child_bitmap(roop_count);
+ set_child_bitmap(
+ (uchar *) table->read_set->bitmap,
+ roop_count, FALSE);
+ }
+ }
+ if (pre_inited != NONE)
+ child_table_idx = child_table_idx_bak;
+ else {
+ if (share->info_src_table)
+ child_table_idx = share->info_src_table - 1;
+ else
+ child_table_idx = 0;
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ handler *file;
+ file = part_tables[roop_count].table->file;
+ if ((error_num = file->ha_pre_direct_delete_rows_init()))
+ {
+ if (error_num == HA_ERR_WRONG_COMMAND)
+ need_bulk_access_finish = TRUE;
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ need_bulk_access_finish = FALSE;
+ if (bulk_access_started)
+ bulk_access_info_current->called = TRUE;
+ DBUG_RETURN(0);
+#endif
+}
+#endif
+#endif
+
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::direct_delete_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ ha_rows *delete_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::direct_delete_rows");
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ file = part_tables[roop_count].table->file;
+ if (file->inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (do_init)
+ {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ if (
+ (error_num = file->ha_index_init(correspond_key->key_idx, FALSE))
+ )
+ DBUG_RETURN(error_num);
+ }
+
+ child_ranges = &child_multi_range[roop_count];
+ } else {
+#endif
+ if (do_init && (error_num = file->ha_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ error_num = file->
+ ha_direct_delete_rows(child_ranges, range_count, sorted, delete_rows);
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ if (do_init)
+ error_num2 = file->ha_index_end();
+ } else {
+#endif
+ if (do_init)
+ error_num2 = file->ha_rnd_end();
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ if (!error_num)
+ error_num = error_num2;
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#else
+int ha_vp::direct_delete_rows(
+ ha_rows *delete_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::direct_delete_rows");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ file = part_tables[roop_count].table->file;
+ if (file->inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+ if (do_init && (error_num = file->ha_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+ error_num = file->
+ ha_direct_delete_rows(delete_rows);
+ if (do_init)
+ error_num2 = file->ha_rnd_end();
+ if (!error_num)
+ error_num = error_num2;
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+int ha_vp::pre_direct_delete_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uint *delete_rows
+) {
+ int error_num, error_num2 = 0, roop_count;
+ KEY_MULTI_RANGE *child_ranges = NULL;
+#if defined(HAVE_HANDLERSOCKET)
+ VP_CORRESPOND_KEY *correspond_key = NULL;
+#endif
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::pre_direct_delete_rows");
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ correspond_key = share->keys[active_index].correspond_key;
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ file = part_tables[roop_count].table->file;
+ if (file->pre_inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ while (correspond_key)
+ {
+ if (correspond_key->table_idx >= roop_count)
+ break;
+ correspond_key = correspond_key->next;
+ }
+ if (
+ do_init &&
+ (error_num = file->ha_pre_index_init(correspond_key->key_idx, FALSE))
+ )
+ DBUG_RETURN(error_num);
+
+ child_ranges = &child_multi_range[roop_count];
+ } else {
+#endif
+ if (do_init && (error_num = file->ha_pre_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ error_num = file->
+ ha_pre_direct_delete_rows(child_ranges, range_count, sorted,
+ delete_rows);
+#if defined(HAVE_HANDLERSOCKET)
+ if (ranges)
+ {
+ /* handlersocket */
+ if (do_init)
+ error_num2 = file->ha_pre_index_end();
+ } else {
+#endif
+ if (do_init)
+ error_num2 = file->ha_pre_rnd_end();
+#if defined(HAVE_HANDLERSOCKET)
+ }
+#endif
+ if (!error_num)
+ {
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ error_num = error_num2;
+ }
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#else
+int ha_vp::pre_direct_delete_rows()
+{
+ int error_num, error_num2 = 0, roop_count;
+ handler *file;
+ bool do_init;
+ DBUG_ENTER("ha_vp::pre_direct_delete_rows");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ file = part_tables[roop_count].table->file;
+ if (file->pre_inited == NONE)
+ do_init = TRUE;
+ else
+ do_init = FALSE;
+ if (do_init && (error_num = file->ha_pre_rnd_init(TRUE)))
+ DBUG_RETURN(error_num);
+ error_num = file->
+ ha_pre_direct_delete_rows();
+ if (do_init)
+ error_num2 = file->ha_pre_rnd_end();
+ if (!error_num)
+ {
+ vp_set_bit(bulk_access_exec_bitmap, roop_count);
+ error_num = error_num2;
+ }
+ if (error_num)
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+#endif
+#endif
+#endif
+
+int ha_vp::delete_all_rows()
+{
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::delete_all_rows");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_delete_all_rows()))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::truncate()
+{
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::truncate");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!(vp_bit_is_set(update_ignore, roop_count)))
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_truncate()))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+double ha_vp::scan_time()
+{
+ DBUG_ENTER("ha_vp::scan_time");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ DBUG_RETURN(part_tables[child_table_idx].table->file->scan_time());
+}
+
+double ha_vp::read_time(
+ uint index,
+ uint ranges,
+ ha_rows rows
+) {
+ VP_CORRESPOND_KEY *tgt_correspond_key;
+ int tgt_table_idx, tgt_key_idx;
+ DBUG_ENTER("ha_vp::read_time");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables[0].table=%p", part_tables[0].table));
+ if (index < MAX_KEY)
+ {
+ tgt_correspond_key = share->keys[index].shortest_correspond_key;
+ tgt_table_idx = tgt_correspond_key->table_idx;
+ tgt_key_idx = tgt_correspond_key->key_idx;
+ DBUG_RETURN(part_tables[tgt_table_idx].table->file->read_time(
+ tgt_key_idx, ranges, rows));
+ } else {
+ DBUG_RETURN(part_tables[child_table_idx].table->file->read_time(
+ index, ranges, rows));
+ }
+}
+
+const key_map *ha_vp::keys_to_use_for_scanning()
+{
+ DBUG_ENTER("ha_vp::keys_to_use_for_scanning");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(&key_map_full);
+}
+
+ha_rows ha_vp::estimate_rows_upper_bound()
+{
+ DBUG_ENTER("ha_vp::estimate_rows_upper_bound");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(
+ part_tables[child_table_idx].table->file->estimate_rows_upper_bound());
+}
+
+bool ha_vp::get_error_message(
+ int error,
+ String *buf
+) {
+ DBUG_ENTER("ha_vp::get_error_message");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (buf->reserve(ER_VP_UNKNOWN_LEN))
+ DBUG_RETURN(TRUE);
+ buf->q_append(ER_VP_UNKNOWN_STR, ER_VP_UNKNOWN_LEN);
+ DBUG_RETURN(FALSE);
+}
+
+int ha_vp::create(
+ const char *name,
+ TABLE *form,
+ HA_CREATE_INFO *info
+) {
+ int error_num;
+ VP_SHARE tmp_share;
+ DBUG_ENTER("ha_vp::create");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp name=%s", name));
+ DBUG_PRINT("info",
+ ("vp form->s->connect_string=%s", form->s->connect_string.str));
+ DBUG_PRINT("info",
+ ("vp info->connect_string=%s", info->connect_string.str));
+ memset(&tmp_share, 0, sizeof(VP_SHARE));
+ tmp_share.table_name = (char*) name;
+ tmp_share.table_name_length = strlen(name);
+ if ((error_num = vp_parse_table_info(&tmp_share, form, 1)))
+ goto error;
+
+ vp_free_share_alloc(&tmp_share);
+ DBUG_RETURN(0);
+
+error:
+ vp_free_share_alloc(&tmp_share);
+ DBUG_RETURN(error_num);
+}
+
+void ha_vp::update_create_info(
+ HA_CREATE_INFO* create_info
+) {
+ DBUG_ENTER("ha_vp::update_create_info");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (!create_info->connect_string.str)
+ {
+ create_info->connect_string.str = table->s->connect_string.str;
+ create_info->connect_string.length = table->s->connect_string.length;
+ }
+ DBUG_PRINT("info",
+ ("vp create_info->connect_string=%s",
+ create_info->connect_string.str));
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::rename_table(
+ const char *from,
+ const char *to
+) {
+ DBUG_ENTER("ha_vp::rename_table");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp from=%s", from));
+ DBUG_PRINT("info",("vp to=%s", to));
+ DBUG_RETURN(0);
+}
+
+int ha_vp::delete_table(
+ const char *name
+) {
+ DBUG_ENTER("ha_vp::delete_table");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp name=%s", name));
+ DBUG_RETURN(0);
+}
+
+bool ha_vp::is_crashed() const
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::is_crashed");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->is_crashed())
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+
+#ifdef VP_HANDLER_AUTO_REPAIR_HAS_ERROR
+bool ha_vp::auto_repair(int error) const
+#else
+bool ha_vp::auto_repair() const
+#endif
+{
+ DBUG_ENTER("ha_vp::auto_repair");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(FALSE);
+}
+
+int ha_vp::disable_indexes(
+ uint mode
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::disable_indexes");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_disable_indexes(mode)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::enable_indexes(
+ uint mode
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::enable_indexes");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_enable_indexes(mode)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+
+int ha_vp::check(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+) {
+ int error_num = 0, roop_count;
+ DBUG_ENTER("ha_vp::check");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ (error_num =
+ part_tables[roop_count].table->file->ha_check(thd, check_opt)) &&
+ error_num != HA_ADMIN_ALREADY_DONE
+ )
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::repair(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+) {
+ int error_num = 0, roop_count;
+ DBUG_ENTER("ha_vp::repair");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ (error_num =
+ part_tables[roop_count].table->file->ha_repair(thd, check_opt)) &&
+ error_num != HA_ADMIN_ALREADY_DONE
+ )
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(error_num);
+}
+
+bool ha_vp::check_and_repair(
+ THD *thd
+) {
+ int roop_count;
+ DBUG_ENTER("ha_vp::check_and_repair");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->ha_check_and_repair(thd))
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+
+int ha_vp::analyze(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+) {
+ int error_num = 0, roop_count;
+ DBUG_ENTER("ha_vp::analyze");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ (error_num =
+ part_tables[roop_count].table->file->ha_analyze(thd, check_opt)) &&
+ error_num != HA_ADMIN_ALREADY_DONE
+ )
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::optimize(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+) {
+ int error_num = 0, roop_count;
+ DBUG_ENTER("ha_vp::optimize");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ (error_num =
+ part_tables[roop_count].table->file->ha_optimize(thd, check_opt)) &&
+ error_num != HA_ADMIN_ALREADY_DONE
+ )
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+int ha_vp::set_top_table_and_fields(
+ TABLE *top_table,
+ Field **top_table_field,
+ uint top_table_fields,
+ bool self
+) {
+ int roop_count, roop_count2;
+ uint field_index, field_index2;
+ DBUG_ENTER("ha_vp::set_top_table_fields");
+ DBUG_PRINT("info",("vp this=%p", this));
+ if (!set_top_table_fields || self != top_table_self)
+ {
+ if (top_table_fields > allocated_top_table_fields)
+ {
+ if (allocated_top_table_fields)
+ vp_my_free(top_table_field_for_childs[0], MYF(0));
+
+ if (!(top_table_field_for_childs[0] =
+ (Field **) my_malloc(sizeof(Field *) * (top_table_fields + 1) *
+ share->table_count, MYF(MY_WME))))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+
+ for (roop_count = 0; roop_count < share->table_count - 1; roop_count++)
+ top_table_field_for_childs[roop_count + 1] =
+ top_table_field_for_childs[roop_count] + top_table_fields + 1;
+
+ allocated_top_table_fields = top_table_fields;
+ }
+
+ for (roop_count = 0; roop_count < (int) top_table_fields + 1; roop_count++)
+ {
+ if (top_table_field[roop_count])
+ {
+ field_index = top_table_field[roop_count]->field_index;
+ for (roop_count2 = 0; roop_count2 < share->table_count; roop_count2++)
+ {
+ field_index2 = share->correspond_columns_p[table_share->fields *
+ roop_count2 + field_index];
+ if (field_index2 < MAX_FIELDS)
+ (top_table_field_for_childs[roop_count2])[roop_count] =
+ part_tables[roop_count2].table->field[field_index2];
+ else
+ (top_table_field_for_childs[roop_count2])[roop_count] = NULL;
+ }
+ } else {
+ for (roop_count2 = 0; roop_count2 < share->table_count; roop_count2++)
+ (top_table_field_for_childs[roop_count2])[roop_count] = NULL;
+ }
+ }
+
+ set_top_table_fields = TRUE;
+ this->top_table = top_table;
+ this->top_table_field = top_table_field;
+ this->top_table_fields = top_table_fields;
+ top_table_self = self;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::set_top_table_and_fields(
+ TABLE *top_table,
+ Field **top_table_field,
+ uint top_table_fields
+) {
+ DBUG_ENTER("ha_vp::set_top_table_fields");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(set_top_table_and_fields(top_table, top_table_field,
+ top_table_fields, FALSE));
+}
+
+#ifdef HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
+bool ha_vp::prune_partitions_for_child(
+ THD *thd,
+ Item *pprune_cond
+) {
+ bool res = TRUE;
+ int roop_count;
+ DBUG_ENTER("ha_vp::prune_partitions_for_child");
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!prune_partitions(thd, part_tables[roop_count].table, pprune_cond))
+ res = FALSE;
+ }
+ DBUG_RETURN(res);
+}
+#endif
+
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+TABLE_LIST *ha_vp::get_next_global_for_child()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::get_next_global_for_child");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_PRINT("info",("vp part_tables=%p", part_tables));
+ handler_close = TRUE;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].parent_l = table->pos_in_table_list;
+ }
+ DBUG_RETURN(part_tables);
+}
+#endif
+
+const COND *ha_vp::cond_push(const COND *cond)
+{
+ int roop_count;
+ COND *res_cond = NULL;
+ DBUG_ENTER("ha_vp::cond_push");
+ DBUG_PRINT("info",("vp this=%p", this));
+
+ if (cond)
+ {
+ if (
+ !set_top_table_fields &&
+ set_top_table_and_fields(table, table->field, table_share->fields, TRUE)
+ )
+ DBUG_RETURN(cond);
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->set_top_table_and_fields(
+ top_table,
+ top_table_field_for_childs[roop_count],
+ top_table_fields))
+ DBUG_RETURN(cond);
+ }
+
+ VP_CONDITION *tmp_cond;
+ if (!(tmp_cond = (VP_CONDITION *)
+ my_malloc(sizeof(*tmp_cond), MYF(MY_WME | MY_ZEROFILL)))
+ )
+ DBUG_RETURN(cond);
+ tmp_cond->cond = (COND *) cond;
+ tmp_cond->next = condition;
+ condition = tmp_cond;
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->pushed_cond != cond)
+ {
+ if (part_tables[roop_count].table->file->cond_push(cond))
+ res_cond = (COND *) cond;
+ else
+ part_tables[roop_count].table->file->pushed_cond = cond;
+ }
+ }
+ }
+ DBUG_RETURN(res_cond);
+}
+
+void ha_vp::cond_pop()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::cond_pop");
+ if (condition)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ part_tables[roop_count].table->file->cond_pop();
+ VP_CONDITION *tmp_cond = condition->next;
+ vp_my_free(condition, MYF(0));
+ condition = tmp_cond;
+ }
+ DBUG_VOID_RETURN;
+}
+#endif
+
+int ha_vp::info_push(
+ uint info_type,
+ void *info
+) {
+ int error_num = 0, tmp, roop_count;
+ DBUG_ENTER("ha_vp::info_push");
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ if (
+ info_type == 1 /* INFO_KIND_HS_RET_FIELDS */
+/*
+ info_type == INFO_KIND_HS_APPEND_STRING_REF ||
+ info_type == INFO_KIND_UPDATE_FIELDS
+*/
+ ) {
+ if (
+ !set_top_table_fields &&
+ (error_num = set_top_table_and_fields(table, table->field,
+ table_share->fields, TRUE))
+ )
+ DBUG_RETURN(error_num);
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = part_tables[roop_count].table->file->
+ set_top_table_and_fields(
+ top_table,
+ top_table_field_for_childs[roop_count],
+ top_table_fields)))
+ DBUG_RETURN(error_num);
+ }
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ switch (info_type)
+ {
+ case INFO_KIND_BULK_ACCESS_BEGIN:
+ DBUG_PRINT("info",("vp INFO_KIND_BULK_ACCESS_BEGIN"));
+ if (bulk_access_started)
+ {
+ if (!bulk_access_info_current->next)
+ {
+ if (!(bulk_access_info_current->next = create_bulk_access_info()))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ bulk_access_info_current->next->sequence_num =
+ bulk_access_info_current->sequence_num + 1;
+ }
+ bulk_access_info_current = bulk_access_info_current->next;
+ } else {
+ if (!bulk_access_info_first)
+ {
+ if (!(bulk_access_info_first = create_bulk_access_info()))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ bulk_access_info_first->sequence_num = 0;
+ }
+ bulk_access_info_current = bulk_access_info_first;
+ bulk_access_started = TRUE;
+ bulk_access_executing = FALSE;
+ }
+ bulk_access_info_current->used = TRUE;
+ bulk_access_info_current->called = FALSE;
+ *((void **) info) = bulk_access_info_current;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((tmp = part_tables[roop_count].table->file->info_push(info_type,
+ &bulk_access_info_current->info[roop_count])))
+ error_num = tmp;
+ }
+ DBUG_RETURN(error_num);
+ case INFO_KIND_BULK_ACCESS_CURRENT:
+ DBUG_PRINT("info",("vp INFO_KIND_BULK_ACCESS_CURRENT"));
+ bulk_access_executing = TRUE;
+ bulk_access_info_exec_tgt = (VP_BULK_ACCESS_INFO *) info;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((tmp = part_tables[roop_count].table->file->info_push(info_type,
+ bulk_access_info_exec_tgt->info[roop_count])))
+ error_num = tmp;
+ }
+ DBUG_RETURN(error_num);
+ case INFO_KIND_BULK_ACCESS_END:
+ DBUG_PRINT("info",("vp INFO_KIND_BULK_ACCESS_END"));
+ bulk_access_started = FALSE;
+ break;
+ }
+#endif
+#else
+ switch (info_type)
+ {
+ case INFO_KIND_HS_RET_FIELDS:
+ case INFO_KIND_HS_APPEND_STRING_REF:
+ case INFO_KIND_HS_CLEAR_STRING_REF:
+ case INFO_KIND_HS_INCREMENT_BEGIN:
+ case INFO_KIND_HS_INCREMENT_END:
+ case INFO_KIND_HS_DECREMENT_BEGIN:
+ case INFO_KIND_HS_DECREMENT_END:
+ case INFO_KIND_UPDATE_FIELDS:
+ case INFO_KIND_UPDATE_VALUES:
+#ifdef HA_CAN_BULK_ACCESS
+ case INFO_KIND_BULK_ACCESS_BEGIN:
+ case INFO_KIND_BULK_ACCESS_CURRENT:
+ case INFO_KIND_BULK_ACCESS_END:
+#endif
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ default:
+ break;
+ }
+#endif
+#endif
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((tmp = part_tables[roop_count].table->file->info_push(info_type,
+ info)))
+ error_num = tmp;
+ }
+ DBUG_RETURN(error_num);
+}
+
+#ifdef HANDLER_HAS_DIRECT_AGGREGATE
+void ha_vp::return_record_by_parent()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::return_record_by_parent");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (part_tables[roop_count].table->file->inited != NONE)
+ part_tables[roop_count].table->file->return_record_by_parent();
+ }
+ DBUG_VOID_RETURN;
+}
+#endif
+
+int ha_vp::start_stmt(
+ THD *thd,
+ thr_lock_type lock_type
+) {
+ int error_num, roop_count;
+ DBUG_ENTER("ha_vp::start_stmt");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->start_stmt(thd, lock_type)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+bool ha_vp::is_fatal_error(
+ int error_num,
+ uint flags
+) {
+ bool res;
+ DBUG_ENTER("ha_vp::is_fatal_error");
+ if (dup_table_idx < share->table_count)
+ {
+ res = part_tables[dup_table_idx].table->file->is_fatal_error(error_num,
+ flags);
+ } else {
+ res = handler::is_fatal_error(error_num, flags);
+ }
+ DBUG_RETURN(res);
+}
+
+bool ha_vp::check_if_incompatible_data(
+ HA_CREATE_INFO *create_info,
+ uint table_changes
+) {
+ DBUG_ENTER("ha_vp::check_if_incompatible_data");
+ DBUG_RETURN(handler::check_if_incompatible_data(create_info, table_changes));
+}
+
+bool ha_vp::primary_key_is_clustered()
+{
+ DBUG_ENTER("ha_vp::primary_key_is_clustered");
+ DBUG_RETURN(handler::primary_key_is_clustered());
+}
+
+bool ha_vp::can_switch_engines()
+{
+ DBUG_ENTER("ha_vp::can_switch_engines");
+ DBUG_RETURN(handler::can_switch_engines());
+}
+
+VP_alter_table_operations ha_vp::alter_table_flags(
+ VP_alter_table_operations flags
+) {
+ DBUG_ENTER("ha_vp::alter_table_flags");
+ DBUG_RETURN(handler::alter_table_flags(flags));
+}
+
+#ifdef VP_HANDLER_HAS_ADD_INDEX
+#if MYSQL_VERSION_ID < 50500
+int ha_vp::add_index(
+ TABLE *table_arg,
+ KEY *key_info,
+ uint num_of_keys
+) {
+ DBUG_ENTER("ha_vp::add_index");
+ DBUG_RETURN(handler::add_index(table_arg, key_info, num_of_keys));
+}
+#else
+int ha_vp::add_index(
+ TABLE *table_arg,
+ KEY *key_info,
+ uint num_of_keys,
+ handler_add_index **add
+) {
+ DBUG_ENTER("ha_vp::add_index");
+ DBUG_RETURN(handler::add_index(table_arg, key_info, num_of_keys, add));
+}
+
+int ha_vp::final_add_index(
+ handler_add_index *add,
+ bool commit
+) {
+ DBUG_ENTER("ha_vp::final_add_index");
+ DBUG_RETURN(handler::final_add_index(add, commit));
+}
+#endif
+#endif
+
+#ifdef VP_HANDLER_HAS_DROP_INDEX
+int ha_vp::prepare_drop_index(
+ TABLE *table_arg,
+ uint *key_num,
+ uint num_of_keys
+) {
+ DBUG_ENTER("ha_vp::prepare_drop_index");
+ DBUG_RETURN(handler::prepare_drop_index(table_arg, key_num, num_of_keys));
+}
+
+int ha_vp::final_drop_index(
+ TABLE *table_arg
+) {
+ DBUG_ENTER("ha_vp::final_drop_index");
+ DBUG_RETURN(handler::final_drop_index(table_arg));
+}
+#endif
+
+/*
+int ha_vp::check_for_upgrade(
+ HA_CHECK_OPT *check_opt
+) {
+ DBUG_ENTER("ha_vp::check_for_upgrade");
+ DBUG_RETURN(handler::check_for_upgrade(check_opt));
+}
+*/
+
+bool ha_vp::was_semi_consistent_read()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::was_semi_consistent_read");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!part_tables[roop_count].table->file->was_semi_consistent_read())
+ DBUG_RETURN(FALSE);
+ }
+ DBUG_RETURN(TRUE);
+}
+
+void ha_vp::try_semi_consistent_read(
+ bool yes
+) {
+ int roop_count;
+ DBUG_ENTER("ha_vp::try_semi_consistent_read");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].table->file->try_semi_consistent_read(yes);
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::unlock_row()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::unlock_row");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].table->file->unlock_row();
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::init_table_handle_for_HANDLER()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::init_table_handle_for_HANDLER");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_tables[roop_count].table->file->init_table_handle_for_HANDLER();
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::change_table_ptr(
+ TABLE *table_arg,
+ TABLE_SHARE *share_arg
+) {
+ DBUG_ENTER("ha_vp::change_table_ptr");
+ handler::change_table_ptr(table_arg, share_arg);
+ DBUG_VOID_RETURN;
+}
+
+#if MYSQL_VERSION_ID < 50600
+char *ha_vp::get_tablespace_name(
+ THD *thd,
+ char *name,
+ uint name_len
+) {
+ DBUG_ENTER("ha_vp::get_tablespace_name");
+ DBUG_RETURN(handler::get_tablespace_name(thd, name, name_len));
+}
+#endif
+
+bool ha_vp::is_fk_defined_on_table_or_index(
+ uint index
+) {
+ DBUG_ENTER("ha_vp::is_fk_defined_on_table_or_index");
+ DBUG_RETURN(handler::is_fk_defined_on_table_or_index(index));
+}
+
+char *ha_vp::get_foreign_key_create_info()
+{
+ DBUG_ENTER("ha_vp::get_foreign_key_create_info");
+ DBUG_RETURN(handler::get_foreign_key_create_info());
+}
+
+int ha_vp::get_foreign_key_list(
+ THD *thd,
+ List<FOREIGN_KEY_INFO> *f_key_list
+) {
+ DBUG_ENTER("ha_vp::get_foreign_key_list");
+ DBUG_RETURN(handler::get_foreign_key_list(thd, f_key_list));
+}
+
+#if MYSQL_VERSION_ID < 50500
+#else
+int ha_vp::get_parent_foreign_key_list(
+ THD *thd,
+ List<FOREIGN_KEY_INFO> *f_key_list
+) {
+ DBUG_ENTER("ha_vp::get_parent_foreign_key_list");
+ DBUG_RETURN(handler::get_parent_foreign_key_list(thd, f_key_list));
+}
+#endif
+
+uint ha_vp::referenced_by_foreign_key()
+{
+ DBUG_ENTER("ha_vp::referenced_by_foreign_key");
+ DBUG_RETURN(handler::referenced_by_foreign_key());
+}
+
+void ha_vp::free_foreign_key_create_info(
+ char* str
+) {
+ DBUG_ENTER("ha_vp::free_foreign_key_create_info");
+ handler::free_foreign_key_create_info(str);
+ DBUG_VOID_RETURN;
+}
+
+#ifdef VP_HANDLER_HAS_COUNT_QUERY_CACHE_DEPENDANT_TABLES
+#ifdef VP_REGISTER_QUERY_CACHE_TABLE_HAS_CONST_TABLE_KEY
+my_bool ha_vp::register_query_cache_table(
+ THD *thd,
+ const char *table_key,
+ uint key_length,
+ qc_engine_callback *engine_callback,
+ ulonglong *engine_data
+)
+#else
+my_bool ha_vp::register_query_cache_table(
+ THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback *engine_callback,
+ ulonglong *engine_data
+)
+#endif
+{
+ DBUG_ENTER("ha_vp::register_query_cache_table");
+ DBUG_PRINT("info",("vp this=%p", this));
+ DBUG_RETURN(handler::register_query_cache_table(
+ thd,
+ table_key,
+ key_length,
+ engine_callback,
+ engine_data
+ ));
+}
+
+uint ha_vp::count_query_cache_dependant_tables(
+ uint8 *tables_type
+) {
+ int roop_count;
+ uint table_count = 0;
+ DBUG_ENTER("ha_vp::register_query_cache_table");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ table_count += part_tables[roop_count].table->file->
+ count_query_cache_dependant_tables(tables_type);
+ }
+ DBUG_RETURN(table_count);
+}
+
+my_bool ha_vp::register_query_cache_dependant_tables(
+ THD *thd,
+ Query_cache *cache,
+ Query_cache_block_table **block,
+ uint *n
+) {
+ int roop_count;
+ DBUG_ENTER("ha_vp::register_query_cache_dependant_tables");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ TABLE *table2 = part_tables[roop_count].table;
+ (++(*block))->n = ++(*n);
+#ifdef VP_QCACHE_INSERT_TABLE_REQUIRES_THDPTR
+ if (!cache->insert_table(
+ thd,
+ table2->s->table_cache_key.length,
+ table2->s->table_cache_key.str,
+ (*block),
+ table2->s->db.length,
+ 0,
+ table_cache_type(),
+ 0,
+ 0,
+ TRUE
+ ))
+ DBUG_RETURN(TRUE);
+#else
+ if (!cache->insert_table(
+ table2->s->table_cache_key.length,
+ table2->s->table_cache_key.str,
+ (*block),
+ table2->s->db.length,
+ 0,
+ table_cache_type(),
+ 0,
+ 0,
+ TRUE
+ ))
+ DBUG_RETURN(TRUE);
+#endif
+
+ if (table2->file->register_query_cache_dependant_tables(
+ thd,
+ cache,
+ block,
+ n
+ ))
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+#else
+#ifdef HTON_CAN_MERGE
+int ha_vp::qcache_insert(
+ Query_cache *qcache,
+ Query_cache_block_table *block_table,
+ TABLE_COUNTER_TYPE &n
+) {
+ int roop_count;
+ DBUG_ENTER("ha_vp::qcache_insert");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (!part_tables[roop_count].table->file->qcache_insert(qcache,
+ block_table, n))
+ DBUG_RETURN(0);
+ }
+ DBUG_RETURN(1);
+}
+
+TABLE_COUNTER_TYPE ha_vp::qcache_table_count()
+{
+ int roop_count;
+ TABLE_COUNTER_TYPE table_count = 1;
+ DBUG_ENTER("ha_vp::qcache_table_count");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ table_count += part_tables[roop_count].table->file->qcache_table_count();
+ }
+ DBUG_RETURN(table_count);
+}
+#endif
+#endif
+
+int ha_vp::choose_child_index(
+ uint idx,
+ uchar *read_set,
+ uchar *write_set,
+ int *table_idx,
+ int *key_idx
+) {
+ int error_num, roop_count, correspond_count, correspond_count2,
+ choose_table_mode;
+ uint field_count, correspond_cond_count;
+ uchar *tmp_columns_bit, *pk_columns_bit, *tmp_select_ignore;
+ VP_CORRESPOND_KEY *tmp_correspond_key, *tmp_correspond_key2;
+ bool correspond_flag, correspond_flag2;
+ DBUG_ENTER("ha_vp::choose_child_index");
+
+ if (lock_mode > 0 || lock_type_ext == F_WRLCK)
+ {
+ choose_table_mode =
+ vp_param_choose_table_mode_for_lock(ha_thd(),
+ share->choose_table_mode_for_lock);
+ DBUG_PRINT("info",("vp choose_table_mode_for_lock=%d",
+ choose_table_mode));
+ tmp_select_ignore = select_ignore_with_lock;
+ } else {
+ choose_table_mode =
+ vp_param_choose_table_mode(ha_thd(), share->choose_table_mode);
+ DBUG_PRINT("info",("vp choose_table_mode=%d",
+ choose_table_mode));
+ tmp_select_ignore = select_ignore;
+ }
+
+ /* choose a index phase 1 */
+ correspond_flag = TRUE;
+ tmp_columns_bit = share->keys[idx].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if (
+ (read_set[roop_count] & tmp_columns_bit[roop_count]) !=
+ read_set[roop_count] ||
+ (write_set[roop_count] & tmp_columns_bit[roop_count]) !=
+ write_set[roop_count]
+ ) {
+ correspond_flag = FALSE;
+ break;
+ }
+ }
+ if (correspond_flag)
+ {
+ if (choose_table_mode == 0)
+ {
+ tmp_correspond_key = share->keys[idx].shortest_correspond_key;
+ while (vp_bit_is_set(tmp_select_ignore, tmp_correspond_key->table_idx))
+ {
+ if (!(tmp_correspond_key = tmp_correspond_key->next_shortest))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_KEY_NUM,
+ ER_VP_IGNORED_CORRESPOND_KEY_STR, MYF(0), idx);
+ DBUG_RETURN(ER_VP_IGNORED_CORRESPOND_KEY_NUM);
+ }
+ }
+ } else {
+ tmp_correspond_key = share->keys[idx].correspond_key;
+ while (vp_bit_is_set(tmp_select_ignore, tmp_correspond_key->table_idx))
+ {
+ if (!(tmp_correspond_key = tmp_correspond_key->next))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_KEY_NUM,
+ ER_VP_IGNORED_CORRESPOND_KEY_STR, MYF(0), idx);
+ DBUG_RETURN(ER_VP_IGNORED_CORRESPOND_KEY_NUM);
+ }
+ }
+ }
+ *table_idx = tmp_correspond_key->table_idx;
+ *key_idx = tmp_correspond_key->key_idx;
+ child_keyread = TRUE;
+ single_table = TRUE;
+ set_used_table = TRUE;
+ clear_child_bitmap(*table_idx);
+ set_child_bitmap(read_set, *table_idx, FALSE);
+ set_child_bitmap(write_set, *table_idx, TRUE);
+ vp_set_bit(use_tables, *table_idx);
+ memset(read_set, 0, sizeof(uchar) * share->bitmap_size);
+ memset(write_set, 0, sizeof(uchar) * share->bitmap_size);
+ DBUG_RETURN(0);
+ }
+
+ /* choose a index phase 2 */
+ if (choose_table_mode == 0)
+ {
+ memset(child_cond_count, 0, sizeof(uint) * share->table_count);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = count_condition(roop_count)))
+ DBUG_RETURN(error_num);
+ }
+
+ bool first = TRUE;
+ correspond_cond_count = 0;
+ correspond_count = 0;
+ field_count = 0;
+ tmp_correspond_key = NULL;
+ tmp_correspond_key2 = share->keys[idx].correspond_key;
+ while (vp_bit_is_set(tmp_select_ignore, tmp_correspond_key2->table_idx))
+ {
+ if (!(tmp_correspond_key2 = tmp_correspond_key2->next))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_KEY_NUM,
+ ER_VP_IGNORED_CORRESPOND_KEY_STR, MYF(0), idx);
+ DBUG_RETURN(ER_VP_IGNORED_CORRESPOND_KEY_NUM);
+ }
+ }
+ while (tmp_correspond_key2)
+ {
+ correspond_count2 = 0;
+ tmp_columns_bit = tmp_correspond_key2->columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ correspond_count2 += vp_bit_count(
+ (read_set[roop_count] | write_set[roop_count]) &
+ tmp_columns_bit[roop_count]);
+ if (
+ first ||
+ correspond_cond_count <
+ child_cond_count[tmp_correspond_key2->table_idx]
+ ) {
+ first = FALSE;
+ tmp_correspond_key = tmp_correspond_key2;
+ correspond_count = correspond_count2;
+ field_count =
+ part_tables[tmp_correspond_key->table_idx].table->s->fields;
+ correspond_cond_count =
+ child_cond_count[tmp_correspond_key->table_idx];
+ } else if (correspond_cond_count ==
+ child_cond_count[tmp_correspond_key2->table_idx])
+ {
+ if (correspond_count < correspond_count2)
+ {
+ tmp_correspond_key = tmp_correspond_key2;
+ correspond_count = correspond_count2;
+ field_count =
+ part_tables[tmp_correspond_key->table_idx].table->s->fields;
+ } else if (
+ correspond_count == correspond_count2 &&
+ field_count >
+ part_tables[tmp_correspond_key2->table_idx].table->s->fields
+ ) {
+ tmp_correspond_key = tmp_correspond_key2;
+ field_count =
+ part_tables[tmp_correspond_key->table_idx].table->s->fields;
+ }
+ }
+ tmp_correspond_key2 = tmp_correspond_key2->next;
+ if (tmp_correspond_key2)
+ {
+ while (vp_bit_is_set(tmp_select_ignore,
+ tmp_correspond_key2->table_idx))
+ {
+ if (!(tmp_correspond_key2 = tmp_correspond_key2->next))
+ break;
+ }
+ }
+ }
+ } else {
+ tmp_correspond_key = share->keys[idx].correspond_key;
+ while (vp_bit_is_set(tmp_select_ignore, tmp_correspond_key->table_idx))
+ {
+ if (!(tmp_correspond_key = tmp_correspond_key->next))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_KEY_NUM,
+ ER_VP_IGNORED_CORRESPOND_KEY_STR, MYF(0), idx);
+ DBUG_RETURN(ER_VP_IGNORED_CORRESPOND_KEY_NUM);
+ }
+ }
+ }
+
+ /* choose a index phase 3 */
+ correspond_flag = TRUE;
+ tmp_columns_bit = tmp_correspond_key->columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ work_bitmap[roop_count] =
+ read_set[roop_count] & tmp_columns_bit[roop_count];
+ DBUG_PRINT("info",("vp work_bitmap[%d]=%d",
+ roop_count, work_bitmap[roop_count]));
+ read_set[roop_count] &= ~work_bitmap[roop_count];
+ DBUG_PRINT("info",("vp read_set[%d]=%d",
+ roop_count, read_set[roop_count]));
+
+ work_bitmap2[roop_count] =
+ write_set[roop_count] & tmp_columns_bit[roop_count];
+ DBUG_PRINT("info",("vp work_bitmap2[%d]=%d",
+ roop_count, work_bitmap2[roop_count]));
+ write_set[roop_count] &= ~work_bitmap2[roop_count];
+ DBUG_PRINT("info",("vp write_set[%d]=%d",
+ roop_count, write_set[roop_count]));
+
+ if (read_set[roop_count] || write_set[roop_count])
+ correspond_flag = FALSE;
+ }
+ *table_idx = tmp_correspond_key->table_idx;
+ *key_idx = tmp_correspond_key->key_idx;
+ if (correspond_flag)
+ {
+ child_keyread = TRUE;
+ single_table = TRUE;
+ } else {
+ /* with table scanning */
+ correspond_flag = TRUE;
+ correspond_flag2 = TRUE;
+ tmp_columns_bit =
+ &share->correspond_columns_bit[*table_idx * share->bitmap_size];
+ pk_columns_bit =
+ share->keys[table_share->primary_key].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if (
+ correspond_flag2 &&
+ (
+ ((read_set[roop_count] | write_set[roop_count]) &
+ tmp_columns_bit[roop_count]) ||
+ ((work_bitmap[roop_count] | work_bitmap2[roop_count]) &
+ pk_columns_bit[roop_count]) != pk_columns_bit[roop_count]
+ )
+ ) {
+ correspond_flag2 = FALSE;
+ }
+ work_bitmap[roop_count] |=
+ read_set[roop_count] & tmp_columns_bit[roop_count];
+ DBUG_PRINT("info",("vp work_bitmap[%d]=%d",
+ roop_count, work_bitmap[roop_count]));
+ read_set[roop_count] &= ~work_bitmap[roop_count];
+ DBUG_PRINT("info",("vp read_set[%d]=%d",
+ roop_count, read_set[roop_count]));
+
+ work_bitmap2[roop_count] |=
+ write_set[roop_count] & tmp_columns_bit[roop_count];
+ DBUG_PRINT("info",("vp work_bitmap2[%d]=%d",
+ roop_count, work_bitmap2[roop_count]));
+ write_set[roop_count] &= ~work_bitmap2[roop_count];
+ DBUG_PRINT("info",("vp write_set[%d]=%d",
+ roop_count, write_set[roop_count]));
+
+ if (read_set[roop_count] || write_set[roop_count])
+ correspond_flag = FALSE;
+ }
+ if (correspond_flag)
+ single_table = TRUE;
+ else if (correspond_flag2)
+ child_keyread = TRUE;
+ }
+ set_used_table = TRUE;
+ clear_child_bitmap(*table_idx);
+ set_child_bitmap(work_bitmap, *table_idx, FALSE);
+ set_child_bitmap(work_bitmap2, *table_idx, TRUE);
+ vp_set_bit(use_tables, *table_idx);
+
+ DBUG_RETURN(0);
+}
+
+int ha_vp::choose_child_ft_tables(
+ uchar *read_set,
+ uchar *write_set
+) {
+ int roop_count, table_idx;
+ uchar *tmp_columns_bit, *tmp_columns_bit2;
+ bool correspond_flag;
+ DBUG_ENTER("ha_vp::choose_child_ft_tables");
+ ft_correspond_flag = FALSE;
+ if (ft_current)
+ {
+ st_vp_ft_info *ft_info = ft_first;
+ while (TRUE)
+ {
+ table_idx = ft_info->target->table_idx;
+ if (!(vp_bit_is_set(use_tables, table_idx)))
+ {
+ correspond_flag = TRUE;
+ tmp_columns_bit =
+ &share->correspond_columns_bit[table_idx * share->bitmap_size];
+ tmp_columns_bit2 = share->keys[ft_info->inx].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ work_bitmap[roop_count] =
+ read_set[roop_count] & tmp_columns_bit[roop_count];
+ read_set[roop_count] &= ~work_bitmap[roop_count];
+ work_bitmap[roop_count] |= tmp_columns_bit2[roop_count];
+
+ work_bitmap2[roop_count] =
+ write_set[roop_count] & tmp_columns_bit[roop_count];
+ write_set[roop_count] &= ~work_bitmap2[roop_count];
+
+ if (read_set[roop_count] || write_set[roop_count])
+ correspond_flag = FALSE;
+ }
+ if (!set_used_table)
+ {
+ child_table_idx = table_idx;
+ if (correspond_flag)
+ {
+ single_table = TRUE;
+ }
+ } else if (single_table && child_table_idx != table_idx)
+ single_table = FALSE;
+ set_used_table = TRUE;
+ clear_child_bitmap(table_idx);
+ set_child_bitmap(work_bitmap, table_idx, FALSE);
+ set_child_bitmap(work_bitmap2, table_idx, TRUE);
+ vp_set_bit(use_tables, table_idx);
+ if (correspond_flag)
+ ft_correspond_flag = TRUE;
+ }
+
+ if (ft_info == ft_current)
+ break;
+ ft_info = ft_info->next;
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::choose_child_tables(
+ uchar *read_set,
+ uchar *write_set
+) {
+ int error_num, roop_count, roop_count2, correspond_count, correspond_count2,
+ table_idx, table_idx2, choose_table_mode;
+ uint field_count, correspond_cond_count;
+ uchar *tmp_columns_bit, *tmp_select_ignore, *pk_bitmap = NULL;
+ bool correspond_flag, has_non_pk_columns = FALSE;
+ DBUG_ENTER("ha_vp::choose_child_tables");
+
+ if (lock_mode > 0 || lock_type_ext == F_WRLCK)
+ {
+ choose_table_mode =
+ vp_param_choose_table_mode_for_lock(ha_thd(),
+ share->choose_table_mode_for_lock);
+ DBUG_PRINT("info",("vp choose_table_mode_for_lock=%d",
+ choose_table_mode));
+ tmp_select_ignore = select_ignore_with_lock;
+ } else {
+ choose_table_mode =
+ vp_param_choose_table_mode(ha_thd(), share->choose_table_mode);
+ DBUG_PRINT("info",("vp choose_table_mode=%d",
+ choose_table_mode));
+ tmp_select_ignore = select_ignore;
+ }
+ if (choose_table_mode == 0)
+ {
+ memset(child_cond_count, 0, sizeof(uint) * share->table_count);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if ((error_num = count_condition(roop_count)))
+ DBUG_RETURN(error_num);
+ }
+ } else {
+ has_non_pk_columns = FALSE;
+ pk_bitmap = share->keys[table_share->primary_key].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if ((read_set[roop_count] | write_set[roop_count] |
+ pk_bitmap[roop_count]) != pk_bitmap[roop_count])
+ {
+ DBUG_PRINT("info",("vp bitmap has non pk columns"));
+ has_non_pk_columns = TRUE;
+ break;
+ }
+ }
+ }
+ table_idx2 = 0;
+ do {
+ table_idx = share->table_count;
+ if (choose_table_mode == 0)
+ {
+ correspond_count = 0;
+ field_count = 0;
+ correspond_cond_count = 0;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ !(vp_bit_is_set(use_tables, roop_count)) &&
+ !(vp_bit_is_set(tmp_select_ignore, roop_count))
+ ) {
+ correspond_count2 = 0;
+ tmp_columns_bit =
+ &share->correspond_columns_bit[roop_count * share->bitmap_size];
+ for (roop_count2 = 0; roop_count2 < share->bitmap_size;
+ roop_count2++)
+ correspond_count2 += vp_bit_count(
+ (read_set[roop_count2] | write_set[roop_count2]) &
+ tmp_columns_bit[roop_count2]);
+ if (correspond_cond_count < child_cond_count[roop_count])
+ {
+ table_idx = roop_count;
+ correspond_count = correspond_count2;
+ field_count =
+ part_tables[roop_count].table->s->fields;
+ correspond_cond_count = child_cond_count[roop_count];
+ } else if (correspond_cond_count == child_cond_count[roop_count])
+ {
+ if (correspond_count < correspond_count2)
+ {
+ table_idx = roop_count;
+ correspond_count = correspond_count2;
+ field_count =
+ part_tables[roop_count].table->s->fields;
+ } else if (
+ correspond_count == correspond_count2 &&
+ field_count >
+ part_tables[roop_count].table->s->fields
+ ) {
+ table_idx = roop_count;
+ field_count =
+ part_tables[roop_count].table->s->fields;
+ }
+ }
+ }
+ }
+ } else {
+ for (roop_count = table_idx2; roop_count < share->table_count;
+ roop_count++)
+ {
+ if (
+ !(vp_bit_is_set(use_tables, roop_count)) &&
+ !(vp_bit_is_set(tmp_select_ignore, roop_count))
+ ) {
+ tmp_columns_bit =
+ &share->correspond_columns_bit[roop_count * share->bitmap_size];
+ if (has_non_pk_columns)
+ {
+ for (roop_count2 = 0; roop_count2 < share->bitmap_size;
+ roop_count2++)
+ {
+ if (vp_bit_count(
+ (read_set[roop_count2] | write_set[roop_count2]) &
+ tmp_columns_bit[roop_count2] & (~pk_bitmap[roop_count2])))
+ break;
+ }
+ } else {
+ for (roop_count2 = 0; roop_count2 < share->bitmap_size;
+ roop_count2++)
+ {
+ if (vp_bit_count(
+ (read_set[roop_count2] | write_set[roop_count2]) &
+ tmp_columns_bit[roop_count2]))
+ break;
+ }
+ }
+ if (roop_count2 < share->bitmap_size)
+ {
+ table_idx2 = table_idx = roop_count;
+ break;
+ }
+ }
+ }
+ }
+
+ if (table_idx < share->table_count)
+ {
+ correspond_flag = TRUE;
+ tmp_columns_bit =
+ &share->correspond_columns_bit[table_idx * share->bitmap_size];
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ work_bitmap[roop_count] =
+ read_set[roop_count] & tmp_columns_bit[roop_count];
+ read_set[roop_count] &= ~work_bitmap[roop_count];
+
+ work_bitmap2[roop_count] =
+ write_set[roop_count] & tmp_columns_bit[roop_count];
+ write_set[roop_count] &= ~work_bitmap2[roop_count];
+
+ if (read_set[roop_count] || write_set[roop_count])
+ correspond_flag = FALSE;
+ }
+ if (!set_used_table)
+ {
+ child_table_idx = table_idx;
+ if (correspond_flag)
+ {
+ single_table = TRUE;
+ }
+ }
+ set_used_table = TRUE;
+ clear_child_bitmap(table_idx);
+ set_child_bitmap(work_bitmap, table_idx, FALSE);
+ set_child_bitmap(work_bitmap2, table_idx, TRUE);
+ vp_set_bit(use_tables, table_idx);
+ if (correspond_flag)
+ break;
+ }
+ } while (table_idx < share->table_count);
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if (vp_bit_count((read_set[roop_count] | write_set[roop_count]) &
+ share->all_columns_bit[roop_count]))
+ {
+ my_printf_error(ER_VP_IGNORED_CORRESPOND_COLUMN_NUM,
+ ER_VP_IGNORED_CORRESPOND_COLUMN_STR, MYF(0));
+ DBUG_RETURN(ER_VP_IGNORED_CORRESPOND_COLUMN_NUM);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+void ha_vp::clear_child_bitmap(
+ int table_idx
+) {
+ TABLE *child_table = part_tables[table_idx].table;
+ int bitmap_size = (child_table->s->fields + 7) / 8;
+ DBUG_ENTER("ha_vp::clear_child_bitmap");
+ memset((uchar *) child_table->write_set->bitmap, 0,
+ sizeof(uchar) * bitmap_size);
+ memset((uchar *) child_table->read_set->bitmap, 0,
+ sizeof(uchar) * bitmap_size);
+ DBUG_VOID_RETURN;
+}
+
+uchar *ha_vp::create_child_key(
+ const uchar *key_same,
+ uchar *key_different,
+ key_part_map keypart_map,
+ uint key_length_same,
+ uint *key_length
+) {
+ int roop_count, length;
+ uint store_length;
+ uchar *ptr;
+ TABLE *table2;
+ Field *field, *field2;
+ KEY *key_info, *key_info2;
+ KEY_PART_INFO *key_part, *key_part2;
+ char buff[MAX_FIELD_WIDTH];
+ String str(buff, sizeof(buff), &my_charset_bin), str2;
+ key_part_map tmp_key_part_map;
+ DBUG_ENTER("ha_vp::create_child_key");
+ if (vp_bit_is_set(share->need_converting, child_table_idx))
+ {
+#ifndef DBUG_OFF
+ int roop_count2;
+ key_info = &table->key_info[active_index];
+ key_part = key_info->key_part;
+ tmp_key_part_map =
+ make_prev_keypart_map(vp_user_defined_key_parts(key_info));
+ tmp_key_part_map &= keypart_map;
+ for (
+ roop_count = 0, ptr = (uchar *) key_same;
+ tmp_key_part_map > 0;
+ ptr += store_length, roop_count++, tmp_key_part_map >>= 1, key_part++
+ ) {
+ store_length = key_part->store_length;
+ for (roop_count2 = 0; roop_count2 < (int) store_length; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp key[%d][%d]=%x",
+ roop_count, roop_count2, ptr[roop_count2]));
+ }
+ }
+#endif
+ table2 = part_tables[child_table_idx].table;
+ key_info = &table->key_info[active_index];
+ key_part = key_info->key_part;
+ key_info2 = &table2->key_info[child_key_idx];
+ key_part2 = key_info2->key_part;
+ tmp_key_part_map =
+ make_prev_keypart_map(vp_user_defined_key_parts(key_info));
+ tmp_key_part_map &= keypart_map;
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_r = dbug_tmp_use_all_columns(table,
+ table->read_set);
+ my_bitmap_map *tmp_map_w2 = dbug_tmp_use_all_columns(table2,
+ table2->write_set);
+#endif
+ *key_length = 0;
+ for (
+ roop_count = 0, ptr = (uchar *) key_same,
+ store_length = key_part->store_length;
+ tmp_key_part_map > 0;
+ ptr += store_length, roop_count++, tmp_key_part_map >>= 1,
+ store_length = key_part->store_length
+ ) {
+ field = key_part[roop_count].field;
+ field2 = key_part2[roop_count].field;
+ if (key_part[roop_count].null_bit && *ptr++)
+ {
+ field2->set_null();
+ field2->reset();
+ } else {
+ if (
+ field->type() == MYSQL_TYPE_BLOB ||
+ field->real_type() == MYSQL_TYPE_VARCHAR ||
+ field->type() == MYSQL_TYPE_GEOMETRY
+ ) {
+ length = uint2korr(ptr);
+ str2.set_quick((char *) ptr + HA_KEY_BLOB_LENGTH, length,
+ &my_charset_bin);
+ field2->set_notnull();
+ field2->store(
+ length ? str2.ptr() : NullS, length,
+ field->charset());
+ } else {
+ field->val_str(&str, ptr);
+ length = str.length();
+ field2->set_notnull();
+ field2->store(
+ length ? str.ptr() : NullS, length,
+ field->charset());
+ }
+ }
+ *key_length += store_length;
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+ dbug_tmp_restore_column_map(table2->write_set, tmp_map_w2);
+#endif
+ key_copy(
+ key_different,
+ table2->record[0],
+ key_info2,
+ *key_length);
+ DBUG_PRINT("info",("vp use key_different"));
+ DBUG_RETURN(key_different);
+ } else {
+ *key_length = key_length_same;
+ }
+ DBUG_PRINT("info",("vp use key_same"));
+ DBUG_RETURN((uchar *) key_same);
+}
+
+int ha_vp::get_child_record_by_idx(
+ int table_idx,
+ my_ptrdiff_t ptr_diff
+) {
+ int roop_count, length;
+ TABLE *table2;
+ uchar *tmp_bitmap, *tmp_bitmap2, *pk_bitmap;
+ Field **field_ptr, **field_ptr2, *field, *field2;
+ int *correspond_columns_c, column_idx;
+ char buff[MAX_FIELD_WIDTH];
+ String str(buff, sizeof(buff), &my_charset_bin);
+ DBUG_ENTER("ha_vp::get_child_record_by_idx");
+ if (vp_bit_is_set(share->same_columns, table_idx))
+ {
+ DBUG_PRINT("info",("vp table_idx %d has same columns", table_idx));
+ DBUG_RETURN(0);
+ }
+
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ DBUG_PRINT("info",("vp child_table_idx=%d", child_table_idx));
+ if (table_idx == child_table_idx)
+ pk_bitmap = NULL;
+ else
+ pk_bitmap = share->keys[table_share->primary_key].columns_bit;
+ table2 = part_tables[table_idx].table;
+ tmp_bitmap = (uchar *) table2->read_set->bitmap;
+ tmp_bitmap2 = (uchar *) table2->write_set->bitmap;
+ field_ptr = table->field;
+ field_ptr2 = table2->field;
+ correspond_columns_c = share->correspond_columns_c_ptr[table_idx];
+ DBUG_PRINT("info",("vp child[%d] fields=%u", table_idx, table2->s->fields));
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_w = dbug_tmp_use_all_columns(table, table->write_set);
+#endif
+ for (roop_count = 0; roop_count < (int) table2->s->fields; roop_count++)
+ {
+ if (
+ vp_bit_is_set(tmp_bitmap, roop_count) ||
+ vp_bit_is_set(tmp_bitmap2, roop_count)
+ ) {
+ DBUG_PRINT("info",("vp check field %d-%d",
+ child_table_idx, roop_count));
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_r2 = dbug_tmp_use_all_columns(table2,
+ table2->read_set);
+#endif
+ column_idx = correspond_columns_c[roop_count];
+ DBUG_PRINT("info",("vp column_idx=%d", column_idx));
+ if (!pk_bitmap || !(vp_bit_is_set(pk_bitmap, column_idx)))
+ {
+ DBUG_PRINT("info",("vp set field %d-%d to %d",
+ child_table_idx, roop_count, column_idx));
+ field2 = field_ptr2[roop_count];
+ field = field_ptr[column_idx];
+ field->move_field_offset(ptr_diff);
+ if (field2->is_null())
+ {
+ DBUG_PRINT("info", ("vp null"));
+ field->set_null();
+ field->reset();
+ } else {
+ DBUG_PRINT("info", ("vp not null"));
+ field->set_notnull();
+ if (field->flags & BLOB_FLAG)
+ {
+ DBUG_PRINT("info", ("vp blob field"));
+ if (
+ (field2->flags & BLOB_FLAG) &&
+ (
+ field->charset() == &my_charset_bin ||
+ field->charset()->cset == field2->charset()->cset
+ )
+ ) {
+ uchar *tmp_char;
+#ifdef VP_FIELD_BLOB_GET_PTR_RETURNS_UCHAR_PTR
+ tmp_char = ((Field_blob *)field2)->get_ptr();
+#else
+ ((Field_blob *)field2)->get_ptr(&tmp_char);
+#endif
+ ((Field_blob *)field)->set_ptr(
+ ((Field_blob *)field2)->get_length(), tmp_char);
+ DBUG_PRINT("info", ("vp ((Field_blob *)field2)->get_length()=%u",
+ ((Field_blob *)field2)->get_length()));
+#ifndef DBUG_OFF
+ if (field2->type() == MYSQL_TYPE_GEOMETRY)
+ {
+ Field_geom *g1 = (Field_geom *) field;
+ Field_geom *g2 = (Field_geom *) field2;
+ DBUG_PRINT("info", ("vp geometry_type is g1:%u g2:%u",
+ g1->geom_type, g2->geom_type));
+ DBUG_PRINT("info", ("vp srid is g1:%u g2:%u",
+ g1->srid, g2->srid));
+ DBUG_PRINT("info", ("vp precision is g1:%u g2:%u",
+ g1->precision, g2->precision));
+ DBUG_PRINT("info", ("vp storage_type is g1:%u g2:%u",
+ g1->storage, g2->storage));
+
+ Geometry_buffer buffer;
+ Geometry *geom;
+ if ((geom = Geometry::construct(&buffer, (char *) tmp_char,
+ g2->get_length())))
+ {
+ str.length(0);
+ str.set_charset(&my_charset_latin1);
+ const char *dummy;
+ if (!(geom->as_wkt(&str, &dummy)))
+ {
+ DBUG_PRINT("info", ("vp geom child is %s",
+ str.c_ptr_safe()));
+ }
+ }
+#ifdef VP_FIELD_BLOB_GET_PTR_RETURNS_UCHAR_PTR
+ tmp_char = g1->get_ptr();
+#else
+ g1->get_ptr(&tmp_char);
+#endif
+ if ((geom = Geometry::construct(&buffer, (char *) tmp_char,
+ g1->get_length())))
+ {
+ str.length(0);
+ str.set_charset(&my_charset_latin1);
+ const char *dummy;
+ if (!(geom->as_wkt(&str, &dummy)))
+ {
+ DBUG_PRINT("info", ("vp geom parent is %s",
+ str.c_ptr_safe()));
+ }
+ }
+ }
+#endif
+ } else {
+ DBUG_PRINT("info", ("vp blob convert"));
+ String *str2 = &blob_buff[field->field_index];
+ str2->length(0);
+ field2->val_str(&str);
+ if (str2->append(str.ptr(), str.length(), field2->charset()))
+ {
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->write_set, tmp_map_w);
+ dbug_tmp_restore_column_map(table2->read_set, tmp_map_r2);
+#endif
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ ((Field_blob *)field)->set_ptr(str2->length(),
+ (uchar *) str2->ptr());
+ }
+ } else {
+ field2->val_str(&str);
+ length = str.length();
+ field->store(
+ length ? str.ptr() : NullS, length,
+ field2->charset());
+ DBUG_PRINT("info", ("vp length = %d", length));
+ }
+ }
+ field->move_field_offset(-ptr_diff);
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table2->read_set, tmp_map_r2);
+#endif
+ }
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->write_set, tmp_map_w);
+#endif
+ DBUG_RETURN(0);
+}
+
+int ha_vp::get_child_record_by_pk(
+ my_ptrdiff_t ptr_diff
+) {
+ int error_num = 0, roop_count;
+ uchar *table_key;
+ uchar table_key_different[MAX_KEY_LENGTH];
+ TABLE *table2;
+ VP_KEY_COPY vp_key_copy;
+#ifndef WITHOUT_VP_BG_ACCESS
+ int bgs_mode = vp_param_bgs_mode(table->in_use, share->bgs_mode);
+ VP_BG_BASE *base;
+#endif
+ DBUG_ENTER("ha_vp::get_child_record_by_pk");
+ vp_key_copy.init = FALSE;
+ vp_key_copy.mem_root_init = FALSE;
+ vp_key_copy.ptr = NULL;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ child_table_idx != roop_count &&
+ vp_bit_is_set(use_tables, roop_count)
+ ) {
+ table2 = part_tables[roop_count].table;
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (
+ bgs_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_SEARCH)
+ ) {
+ base = &bg_base[roop_count];
+ vp_key_copy.table_key_different = base->table_key_different;
+ if (
+ (error_num = create_bg_thread(base)) ||
+ (error_num = search_by_pk(roop_count, 0, &vp_key_copy, 0,
+ (uchar **) &base->table_key))
+ )
+ goto error;
+ base->tgt_key_part_map = vp_key_copy.tgt_key_part_map;
+ base->bg_command = VP_BG_COMMAND_SELECT;
+ bg_kick(base);
+ } else {
+#endif
+ vp_key_copy.table_key_different = table_key_different;
+ if (
+ (error_num = search_by_pk(roop_count, 0, &vp_key_copy, ptr_diff,
+ &table_key)) ||
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ (error_num = table2->file->ha_index_read_map(
+ table2->record[0], table_key, vp_key_copy.tgt_key_part_map,
+ HA_READ_KEY_EXACT))
+#else
+ (error_num = table2->file->index_read_map(
+ table2->record[0], table_key, vp_key_copy.tgt_key_part_map,
+ HA_READ_KEY_EXACT))
+#endif
+ ) {
+ table->status = table2->status;
+ goto error;
+ }
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ }
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ child_table_idx != roop_count &&
+ vp_bit_is_set(use_tables, roop_count)
+ ) {
+#ifndef WITHOUT_VP_BG_ACCESS
+ table2 = part_tables[roop_count].table;
+ if (
+ bgs_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_SEARCH)
+ ) {
+ base = &bg_base[roop_count];
+ bg_wait(base);
+ if (base->bg_error)
+ {
+ error_num = base->bg_error;
+ table->status = table2->status;
+ goto error;
+ }
+ }
+#endif
+ if ((error_num = get_child_record_by_idx(roop_count, ptr_diff)))
+ {
+ table->status = table2->status;
+ goto error;
+ }
+ }
+ }
+
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+ DBUG_RETURN(error_num);
+
+error:
+#ifndef WITHOUT_VP_BG_ACCESS
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ base = &bg_base[roop_count];
+ if (base->bg_init)
+ bg_wait(base);
+ }
+#endif
+ if (vp_key_copy.mem_root_init)
+ free_root(&vp_key_copy.mem_root, MYF(0));
+ if (vp_key_copy.ptr)
+ vp_my_free(vp_key_copy.ptr, MYF(0));
+ DBUG_RETURN(error_num);
+}
+
+bool ha_vp::set_child_bitmap(
+ uchar *bitmap,
+ int table_idx,
+ bool write_flg
+) {
+ bool ret_flag = FALSE;
+ int roop_count, field_idx;
+ uchar *tmp_bitmap, *pk_bitmap;
+ int *correspond_columns_p =
+ &share->correspond_columns_p[table_idx * table_share->fields];
+ TABLE *child_table = part_tables[table_idx].table;
+ bool use_full_column = FALSE;
+ DBUG_ENTER("ha_vp::set_child_bitmap");
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ DBUG_PRINT("info",("vp write_flg=%d", write_flg));
+ DBUG_PRINT("info",("vp update_request=%s",
+ update_request ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp need_full_col_for_update=%s",
+ vp_bit_is_set(share->need_full_col_for_update, table_idx) ? "TRUE" : "FALSE"));
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ DBUG_PRINT("info",("vp source bitmap is %d-%u", roop_count,
+ bitmap[roop_count]));
+#endif
+
+ if (write_flg)
+ tmp_bitmap = (uchar *) child_table->write_set->bitmap;
+ else
+ tmp_bitmap = (uchar *) child_table->read_set->bitmap;
+
+ if (
+ !write_flg &&
+ update_request &&
+ vp_bit_is_set(share->need_full_col_for_update, table_idx)
+ ) {
+ use_full_column = TRUE;
+ child_keyread = FALSE;
+ }
+
+ if (
+ !use_full_column &&
+ !write_flg &&
+ table_idx == child_table_idx &&
+ (!single_table || update_request || extra_use_cmp_ref)
+ ) {
+ pk_bitmap = share->keys[table_share->primary_key].columns_bit;
+ if (child_keyread)
+ {
+ VP_CORRESPOND_KEY *correspond_key =
+ share->correspond_keys_p_ptr[child_table_idx];
+ uchar *key_bitmap = correspond_key[child_key_idx].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if ((key_bitmap[roop_count] & pk_bitmap[roop_count]) !=
+ pk_bitmap[roop_count])
+ {
+ DBUG_PRINT("info",("vp cancel keyread"));
+ child_keyread = FALSE;
+ break;
+ }
+ }
+ }
+ } else
+ pk_bitmap = NULL;
+
+ for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++)
+ {
+ if (
+ use_full_column ||
+ vp_bit_is_set(bitmap, roop_count) ||
+ (pk_bitmap && vp_bit_is_set(pk_bitmap, roop_count))
+ ) {
+ if ((field_idx = correspond_columns_p[roop_count]) < MAX_FIELDS)
+ {
+ vp_set_bit(tmp_bitmap, field_idx);
+ ret_flag = TRUE;
+ }
+ }
+ }
+#ifndef DBUG_OFF
+ int bitmap_size = (child_table->s->fields + 7) / 8;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ DBUG_PRINT("info",("vp bitmap is %d-%u", roop_count,
+ tmp_bitmap[roop_count]));
+#endif
+ DBUG_RETURN(ret_flag);
+}
+
+bool ha_vp::add_pk_bitmap_to_child()
+{
+ bool ret_flag = FALSE;
+ int roop_count, field_idx;
+ uchar *tmp_bitmap, *pk_bitmap;
+ int *correspond_columns_p =
+ &share->correspond_columns_p[child_table_idx * table_share->fields];
+ TABLE *child_table = part_tables[child_table_idx].table;
+ DBUG_ENTER("ha_vp::add_pk_bitmap_to_child");
+ DBUG_PRINT("info",("vp update_request=%s",
+ update_request ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp need_full_col_for_update=%s",
+ vp_bit_is_set(share->need_full_col_for_update, child_table_idx) ? "TRUE" : "FALSE"));
+
+ tmp_bitmap = (uchar *) child_table->read_set->bitmap;
+
+ if (
+ update_request &&
+ vp_bit_is_set(share->need_full_col_for_update, child_table_idx)
+ ) {
+ DBUG_RETURN(FALSE);
+ }
+
+ if (extra_use_cmp_ref || !single_table || update_request)
+ {
+ pk_bitmap = share->keys[table_share->primary_key].columns_bit;
+ if (child_keyread)
+ {
+ VP_CORRESPOND_KEY *correspond_key =
+ share->correspond_keys_p_ptr[child_table_idx];
+ uchar *key_bitmap = correspond_key[child_key_idx].columns_bit;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ if ((key_bitmap[roop_count] & pk_bitmap[roop_count]) !=
+ pk_bitmap[roop_count])
+ {
+ DBUG_PRINT("info",("vp cancel keyread"));
+ child_keyread = FALSE;
+ break;
+ }
+ }
+ }
+ } else
+ DBUG_RETURN(FALSE);
+
+ for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++)
+ {
+ if (vp_bit_is_set(pk_bitmap, roop_count))
+ {
+ if ((field_idx = correspond_columns_p[roop_count]) < MAX_FIELDS)
+ {
+ vp_set_bit(tmp_bitmap, field_idx);
+ ret_flag = TRUE;
+ }
+ }
+ }
+#ifndef DBUG_OFF
+ int bitmap_size = (child_table->s->fields + 7) / 8;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ DBUG_PRINT("info",("vp bitmap is %d-%u", roop_count,
+ tmp_bitmap[roop_count]));
+#endif
+ DBUG_RETURN(ret_flag);
+}
+
+void ha_vp::set_child_pt_bitmap()
+{
+ int roop_count, roop_count2, roop_count3;
+ int *correspond_pt_columns_p;
+ int *uncorrespond_pt_columns_c;
+ int field_idx;
+ TABLE *child_table;
+ DBUG_ENTER("ha_vp::set_child_pt_bitmap");
+
+ for (roop_count = 0; roop_count < share->table_count; ++roop_count)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ correspond_pt_columns_p =
+ &share->correspond_pt_columns_p[roop_count * table_share->fields];
+ for (roop_count2 = 0;
+ correspond_pt_columns_p[roop_count2] < MAX_FIELDS; ++roop_count2)
+ {
+ field_idx = correspond_pt_columns_p[roop_count2];
+ int *correspond_columns_p =
+ &share->correspond_columns_p[child_table_idx * table_share->fields];
+ if (correspond_columns_p[field_idx] < MAX_FIELDS)
+ {
+ child_table = part_tables[child_table_idx].table;
+ vp_set_bit(child_table->read_set->bitmap,
+ correspond_columns_p[field_idx]);
+ DBUG_PRINT("info",("vp child bitmap %d-%d is set",
+ child_table_idx, correspond_columns_p[field_idx]));
+ continue;
+ }
+
+ for (roop_count3 = 0; roop_count3 < share->table_count; ++roop_count3)
+ {
+ if (
+ child_table_idx != roop_count3 &&
+ vp_bit_is_set(use_tables, roop_count3)
+ ) {
+ correspond_columns_p =
+ &share->correspond_columns_p[roop_count3 * table_share->fields];
+ if (correspond_columns_p[field_idx] < MAX_FIELDS)
+ {
+ child_table = part_tables[roop_count3].table;
+ vp_set_bit(child_table->read_set->bitmap,
+ correspond_columns_p[field_idx]);
+ DBUG_PRINT("info",("vp child bitmap %d-%d is set",
+ roop_count3, correspond_columns_p[field_idx]));
+ break;
+ }
+ }
+ }
+ }
+
+ uncorrespond_pt_columns_c =
+ share->uncorrespond_pt_columns_c_ptr[roop_count];
+ for (roop_count2 = 0; uncorrespond_pt_columns_c[roop_count2] < MAX_FIELDS;
+ ++roop_count2)
+ {
+ child_table = part_tables[roop_count2].table;
+ vp_set_bit(child_table->read_set->bitmap,
+ uncorrespond_pt_columns_c[roop_count2]);
+ DBUG_PRINT("info",("vp child bitmap %d-%d for uncorrespond is set",
+ roop_count, uncorrespond_pt_columns_c[roop_count2]));
+ }
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::set_child_record_for_update(
+ my_ptrdiff_t ptr_diff,
+ int record_idx,
+ bool write_flg,
+ bool use_table_chk
+) {
+ int roop_count, roop_count2, length,
+ *correspond_columns_c, column_idx;
+ my_ptrdiff_t ptr_diff2;
+ TABLE *table2;
+ Field **field_ptr, **field_ptr2, *field, *field2;
+ MY_BITMAP *my_bitmap;
+ char buff[MAX_FIELD_WIDTH];
+ String str(buff, sizeof(buff), &my_charset_bin);
+ DBUG_ENTER("ha_vp::set_child_record_for_update");
+ field_ptr = table->field;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->same_columns, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table %d has same columns", roop_count));
+ continue;
+ }
+ if (
+ use_table_chk ||
+ vp_bit_is_set(use_tables2, roop_count)
+ ) {
+ table2 = part_tables[roop_count].table;
+ field_ptr2 = table2->field;
+ correspond_columns_c = share->correspond_columns_c_ptr[roop_count];
+ if (write_flg)
+ my_bitmap = table2->write_set;
+ else
+ my_bitmap = table2->read_set;
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_r = dbug_tmp_use_all_columns(table,
+ table->read_set);
+ my_bitmap_map *tmp_map_w2 = NULL;
+ if (!write_flg)
+ tmp_map_w2 = dbug_tmp_use_all_columns(table2,
+ table2->write_set);
+#endif
+ ptr_diff2 = PTR_BYTE_DIFF(table2->record[record_idx], table2->record[0]);
+ for (roop_count2 = 0; roop_count2 < (int) table2->s->fields;
+ roop_count2++)
+ {
+ column_idx = correspond_columns_c[roop_count2];
+ field2 = field_ptr2[roop_count2];
+ if (
+ bitmap_is_set(my_bitmap, roop_count2)
+ ) {
+ DBUG_PRINT("info",("vp set field %d to %d-%d",
+ column_idx, roop_count, roop_count2));
+ field = field_ptr[column_idx];
+ field->move_field_offset(ptr_diff);
+ field2->move_field_offset(ptr_diff2);
+ if (field->is_null())
+ {
+ field2->set_null();
+ field2->reset();
+ } else {
+ field->val_str(&str);
+ length = str.length();
+ field2->set_notnull();
+ field2->store(
+ length ? str.ptr() : NullS, length,
+ field->charset());
+ }
+ field2->move_field_offset(-ptr_diff2);
+ field->move_field_offset(-ptr_diff);
+ if (use_table_chk)
+ vp_set_bit(use_tables2, roop_count);
+ }
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+ if (!write_flg)
+ dbug_tmp_restore_column_map(table2->write_set, tmp_map_w2);
+#endif
+ }
+ }
+
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::set_child_record_for_insert(
+ my_ptrdiff_t ptr_diff,
+ int table_idx
+) {
+ int roop_count2, length,
+ *correspond_columns_c, column_idx;
+ TABLE *table2;
+ Field **field_ptr, **field_ptr2, *field, *field2;
+ MY_BITMAP *my_bitmap;
+ char buff[MAX_FIELD_WIDTH];
+ String str(buff, sizeof(buff), &my_charset_bin);
+ DBUG_ENTER("ha_vp::set_child_record_for_insert");
+ if (vp_bit_is_set(share->same_columns, table_idx))
+ {
+ DBUG_PRINT("info",("vp child_table %d has same columns", table_idx));
+ DBUG_VOID_RETURN;
+ }
+ field_ptr = table->field;
+ if (
+ vp_bit_is_set(use_tables2, table_idx)
+ ) {
+ table2 = part_tables[table_idx].table;
+ field_ptr2 = table2->field;
+ correspond_columns_c = share->correspond_columns_c_ptr[table_idx];
+ my_bitmap = table2->write_set;
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_r = dbug_tmp_use_all_columns(table,
+ table->read_set);
+#endif
+ for (roop_count2 = 0; roop_count2 < (int) table2->s->fields; roop_count2++)
+ {
+ column_idx = correspond_columns_c[roop_count2];
+ field2 = field_ptr2[roop_count2];
+ if (!bitmap_is_set(my_bitmap, roop_count2))
+ {
+ vp_set_bit(my_bitmap->bitmap, roop_count2);
+ if (column_idx < MAX_FIELDS)
+ {
+ DBUG_PRINT("info",("vp set field %d to %d-%d",
+ column_idx, table_idx, roop_count2));
+ field = field_ptr[column_idx];
+ field->move_field_offset(ptr_diff);
+ if (field->is_null())
+ {
+ field2->set_null();
+ field2->reset();
+ } else {
+ field->val_str(&str);
+ length = str.length();
+ field2->set_notnull();
+ field2->store(
+ length ? str.ptr() : NullS, length,
+ field->charset());
+ }
+ field->move_field_offset(-ptr_diff);
+ } else {
+ DBUG_PRINT("info",("vp set field DEFAULT to %d-%d",
+ table_idx, roop_count2));
+ field2->set_default();
+ }
+ }
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+#endif
+ }
+
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::search_by_pk(
+ int table_idx,
+ int record_idx,
+ VP_KEY_COPY *vp_key_copy,
+ my_ptrdiff_t ptr_diff,
+ uchar **table_key
+) {
+ int roop_count, key_idx, error_num;
+ TABLE *table2;
+ KEY *key_info, *key_info2;
+ Field *field, *field2;
+ KEY_PART_INFO *key_part, *key_part2;
+ char buff[MAX_FIELD_WIDTH];
+ String str(buff, sizeof(buff), &my_charset_bin);
+ DBUG_ENTER("ha_vp::search_by_pk");
+ table2 = part_tables[table_idx].table;
+ key_idx = share->correspond_pk[table_idx]->key_idx;
+/*
+ my_ptrdiff_t ptr_diff2 =
+ PTR_BYTE_DIFF(table2->record[record_idx], table2->record[0]);
+*/
+ key_info = &table->key_info[table_share->primary_key];
+ key_part = key_info->key_part;
+
+ if (!vp_key_copy->init)
+ {
+ vp_key_copy->init = TRUE;
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info); roop_count++)
+ {
+ field = key_part[roop_count].field;
+ field->move_field_offset(ptr_diff);
+ }
+ key_copy(
+ vp_key_copy->table_key_same,
+ table->record[record_idx],
+ key_info,
+ key_info->key_length);
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info); roop_count++)
+ {
+ field = key_part[roop_count].field;
+ field->move_field_offset(-ptr_diff);
+ }
+ vp_key_copy->tgt_key_part_map =
+ make_prev_keypart_map(vp_user_defined_key_parts(key_info));
+ }
+
+ if (vp_bit_is_set(share->need_converting, table_idx))
+ {
+#ifndef DBUG_OFF
+ my_bitmap_map *tmp_map_r = dbug_tmp_use_all_columns(table,
+ table->read_set);
+ my_bitmap_map *tmp_map_w2 = dbug_tmp_use_all_columns(table2,
+ table2->write_set);
+#endif
+ if (!vp_key_copy->mem_root_init)
+ {
+ vp_key_copy->mem_root_init = TRUE;
+ VP_INIT_ALLOC_ROOT(&vp_key_copy->mem_root, 1024, 0, MYF(MY_WME));
+ if (
+ !(vp_key_copy->ptr = (char **) my_multi_malloc(MYF(MY_WME),
+ &vp_key_copy->ptr,
+ sizeof(char *) * vp_user_defined_key_parts(key_info),
+ &vp_key_copy->len, sizeof(int) * vp_user_defined_key_parts(key_info),
+ &vp_key_copy->null_flg,
+ sizeof(uchar) * ((vp_user_defined_key_parts(key_info) + 7) / 8),
+ NullS))
+ ) {
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+ dbug_tmp_restore_column_map(table2->write_set, tmp_map_w2);
+#endif
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ memset((uchar *) vp_key_copy->null_flg, 0,
+ sizeof(uchar) * ((vp_user_defined_key_parts(key_info) + 7) / 8));
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info);
+ roop_count++)
+ {
+ field = key_part[roop_count].field;
+ field->move_field_offset(ptr_diff);
+ if (field->is_null())
+ {
+ vp_set_bit(vp_key_copy->null_flg, roop_count);
+ } else {
+ field->val_str(&str);
+ vp_key_copy->len[roop_count] = str.length();
+ if (!vp_key_copy->len[roop_count])
+ vp_key_copy->ptr[roop_count] = NullS;
+ else if ((vp_key_copy->ptr[roop_count] =
+ (char *) alloc_root(&vp_key_copy->mem_root,
+ vp_key_copy->len[roop_count])))
+ {
+ memcpy(vp_key_copy->ptr[roop_count], str.ptr(),
+ vp_key_copy->len[roop_count]);
+ } else {
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+ dbug_tmp_restore_column_map(table2->write_set, tmp_map_w2);
+#endif
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+ field->move_field_offset(-ptr_diff);
+ }
+ }
+
+ key_info2 = &table2->key_info[key_idx];
+ key_part2 = key_info2->key_part;
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info); roop_count++)
+ {
+ field2 = key_part2[roop_count].field;
+/*
+ field2->move_field_offset(ptr_diff2);
+*/
+ if (vp_bit_is_set(vp_key_copy->null_flg, roop_count))
+ {
+ field2->set_null();
+ field2->reset();
+ } else {
+ field2->set_notnull();
+ field2->store(
+ vp_key_copy->ptr[roop_count], vp_key_copy->len[roop_count],
+ key_part[roop_count].field->charset());
+ }
+ }
+#ifndef DBUG_OFF
+ dbug_tmp_restore_column_map(table->read_set, tmp_map_r);
+ dbug_tmp_restore_column_map(table2->write_set, tmp_map_w2);
+#endif
+
+ *table_key = vp_key_copy->table_key_different;
+ key_copy(
+ vp_key_copy->table_key_different,
+ table2->record[0],
+ key_info2,
+ key_info2->key_length);
+
+/*
+ for (roop_count = 0; roop_count < key_info->key_parts; roop_count++)
+ {
+ field2 = key_part2[roop_count].field;
+ field2->move_field_offset(-ptr_diff2);
+ }
+*/
+ } else
+ *table_key = vp_key_copy->table_key_same;
+
+ /* check part column is available for partition pruning */
+ bool part_column_available = TRUE;
+ int *correspond_columns_p;
+ int *correspond_pt_columns_p;
+ int field_idx;
+ TABLE *child_table;
+ correspond_columns_p =
+ &share->correspond_columns_p[child_table_idx * table_share->fields];
+ correspond_pt_columns_p =
+ &share->correspond_pt_columns_p[table_idx * table_share->fields];
+ child_table = part_tables[child_table_idx].table;
+ for (roop_count = 0;
+ correspond_pt_columns_p[roop_count] < MAX_FIELDS; ++roop_count)
+ {
+ field_idx = correspond_columns_p[correspond_pt_columns_p[roop_count]];
+ DBUG_PRINT("info",("vp field_idx=%d", field_idx));
+ if (
+ field_idx == MAX_FIELDS ||
+ (
+ !vp_bit_is_set(child_table->read_set->bitmap, field_idx) &&
+ !(
+ update_request &&
+ vp_bit_is_set(share->need_full_col_for_update, child_table_idx)
+ )
+ )
+ ) {
+ DBUG_PRINT("info",("vp did not get this column by child_table_idx"));
+ part_column_available = FALSE;
+ break;
+ }
+ }
+ DBUG_PRINT("info",("vp part_column_available=%s",
+ part_column_available ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("vp ptr_diff %s",
+ ptr_diff ? "is not 0" : "is 0"));
+ if (part_column_available)
+ {
+ if (!vp_bit_is_set(share->same_columns, table_idx))
+ {
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ /* set partition key value to child table */
+ correspond_columns_p =
+ &share->correspond_columns_p[table_idx * table_share->fields];
+ for (roop_count = 0;
+ correspond_pt_columns_p[roop_count] < MAX_FIELDS; ++roop_count)
+ {
+ int parent_field_idx = correspond_pt_columns_p[roop_count];
+ DBUG_PRINT("info",("vp parent_field_idx=%d", parent_field_idx));
+ int child_field_idx = correspond_columns_p[parent_field_idx];
+ DBUG_PRINT("info",("vp child_field_idx=%d", child_field_idx));
+ field = table->field[parent_field_idx];
+ field2 = table2->field[child_field_idx];
+ field->move_field_offset(ptr_diff);
+ if (field->is_null())
+ {
+ DBUG_PRINT("info", ("vp null"));
+ field2->set_null();
+ field2->reset();
+ } else {
+ DBUG_PRINT("info", ("vp not null"));
+ field2->set_notnull();
+ field->val_str(&str);
+ uint length = str.length();
+ field2->store(
+ length ? str.ptr() : NullS, length,
+ field->charset());
+ DBUG_PRINT("info", ("vp length = %d", length));
+#ifndef DBUG_OFF
+ char *value = (char *) my_alloca(length + 1);
+ memcpy(value, str.ptr(), length);
+ value[length] = '\0';
+ DBUG_PRINT("info", ("vp value = %s", value));
+ my_afree(value);
+#endif
+ }
+ field->move_field_offset(-ptr_diff);
+ vp_set_bit(table2->read_set->bitmap, child_field_idx);
+ }
+ if ((error_num =
+ table2->file->choose_partition_from_column_value(table2->record[0])))
+ DBUG_RETURN(error_num);
+ } else {
+ DBUG_PRINT("info",("vp same column"));
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ DBUG_PRINT("info",("vp record[0]=%p", table->record[0]));
+/*
+ if ((error_num =
+ table2->file->choose_partition_from_column_value(ADD_TO_PTR(table2->record[0], ptr_diff, uchar *))))
+ DBUG_RETURN(error_num);
+*/
+ if ((error_num =
+ table2->file->choose_partition_from_column_value(ADD_TO_PTR(table->record[0], ptr_diff, uchar *))))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::search_by_pk_for_update(
+ int table_idx,
+ int record_idx,
+ VP_KEY_COPY *vp_key_copy,
+ my_ptrdiff_t ptr_diff,
+ int bgu_mode
+) {
+ int error_num, error_num2, key_idx;
+ TABLE *table2;
+ uchar *table_key;
+ uchar table_key_different[MAX_KEY_LENGTH];
+#ifndef WITHOUT_VP_BG_ACCESS
+ VP_BG_BASE *base;
+#endif
+ DBUG_ENTER("ha_vp::search_by_pk_for_update");
+ table2 = part_tables[table_idx].table;
+ key_idx = share->correspond_pk[table_idx]->key_idx;
+
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (
+ bgu_mode &&
+ (table2->file->ha_table_flags() & VP_CAN_BG_UPDATE)
+ ) {
+ base = &bg_base[table_idx];
+ vp_key_copy->table_key_different = base->table_key_different;
+ if (
+ (error_num = create_bg_thread(base)) ||
+ (error_num = search_by_pk(table_idx, record_idx, vp_key_copy, ptr_diff,
+ (uchar **) &base->table_key))
+ )
+ DBUG_RETURN(error_num);
+ base->tgt_key_part_map = vp_key_copy->tgt_key_part_map;
+ base->key_idx = key_idx;
+ base->record_idx = record_idx;
+ base->bg_command = VP_BG_COMMAND_UPDATE_SELECT;
+ bg_kick(base);
+ } else {
+#endif
+ vp_key_copy->table_key_different = table_key_different;
+ if ((error_num = search_by_pk(table_idx, record_idx, vp_key_copy, ptr_diff,
+ &table_key)))
+ DBUG_RETURN(error_num);
+
+ if (inited == INDEX)
+ {
+ if (!vp_bit_is_set(key_inited_tables, table_idx))
+ {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ table_idx));
+ DBUG_PRINT("info",("vp INDEX child_table=%p", table2));
+ vp_set_bit(key_inited_tables, table_idx);
+ if ((error_num =
+ table2->file->ha_index_init(key_idx, TRUE)))
+ DBUG_RETURN(error_num);
+ }
+ } else if (inited == RND) {
+ if (!vp_bit_is_set(rnd_inited_tables, table_idx))
+ {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ table_idx));
+ DBUG_PRINT("info",("vp RND child_table=%p", table2));
+ vp_set_bit(rnd_inited_tables, table_idx);
+ if ((error_num =
+ table2->file->ha_index_init(key_idx, TRUE)))
+ DBUG_RETURN(error_num);
+ }
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ table_idx));
+ DBUG_PRINT("info",("vp NONE child_table=%p", table2));
+ if ((error_num =
+ table2->file->ha_index_init(key_idx, TRUE)))
+ DBUG_RETURN(error_num);
+ }
+ if (
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ !(error_num = table2->file->ha_index_read_map(
+ table2->record[0], table_key,
+ vp_key_copy->tgt_key_part_map, HA_READ_KEY_EXACT)) &&
+#else
+ !(error_num = table2->file->index_read_map(
+ table2->record[0], table_key,
+ vp_key_copy->tgt_key_part_map, HA_READ_KEY_EXACT)) &&
+#endif
+ record_idx
+ ) {
+ store_record(table2, record[1]);
+ }
+ if (inited == NONE)
+ {
+ DBUG_PRINT("info",("vp NONE ha_index_end"));
+ if ((error_num2 = table2->file->ha_index_end()))
+ DBUG_RETURN(error_num2);
+ }
+#ifndef WITHOUT_VP_BG_ACCESS
+ }
+#endif
+ DBUG_RETURN(error_num);
+}
+
+int ha_vp::create_child_bitmap_buff(
+) {
+ int roop_count;
+ uchar *child_column_bitmap;
+ TABLE_SHARE *part_table_share;
+ DBUG_ENTER("ha_vp::create_child_bitmap_buff");
+ child_column_bitmap_size = 0;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_table_share = part_tables[roop_count].table->s;
+ child_column_bitmap_size += part_table_share->column_bitmap_size;
+ }
+ if (!(ins_child_bitmaps[0] = (uchar **)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &ins_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &ins_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &upd_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &upd_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &del_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &del_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &add_from_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &add_from_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &sel_key_init_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &sel_key_init_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &sel_key_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &sel_key_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &sel_rnd_child_bitmaps[0],
+ sizeof(uchar *) * share->table_count,
+ &sel_rnd_child_bitmaps[1],
+ sizeof(uchar *) * share->table_count,
+ &child_column_bitmap,
+ sizeof(uchar) * child_column_bitmap_size * 14,
+ NullS))
+ )
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_table_share = part_tables[roop_count].table->s;
+ ins_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ ins_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ upd_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ upd_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ del_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ del_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ add_from_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ add_from_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_key_init_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_key_init_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_key_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_key_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_rnd_child_bitmaps[0][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ sel_rnd_child_bitmaps[1][roop_count] = child_column_bitmap;
+ child_column_bitmap += part_table_share->column_bitmap_size;
+ }
+ DBUG_RETURN(0);
+}
+
+void ha_vp::free_child_bitmap_buff(
+) {
+ DBUG_ENTER("ha_vp::free_child_bitmap_buff");
+ if (ins_child_bitmaps[0])
+ {
+ vp_my_free(ins_child_bitmaps[0], MYF(0));
+ ins_child_bitmaps[0] = NULL;
+ }
+ DBUG_VOID_RETURN;
+}
+
+bool ha_vp::get_added_bitmap(
+ uchar *added_bitmap,
+ const uchar *current_bitmap,
+ const uchar *pre_bitmap
+) {
+ int roop_count;
+ bool added = FALSE;
+ DBUG_ENTER("ha_vp::get_added_bitmap");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp current_bitmap[%d]=%u", roop_count,
+ current_bitmap[roop_count]));
+ DBUG_PRINT("info",("vp pre_bitmap[%d]=%u", roop_count,
+ pre_bitmap[roop_count]));
+ added_bitmap[roop_count] = current_bitmap[roop_count] &
+ (current_bitmap[roop_count] ^ pre_bitmap[roop_count]);
+ if (added_bitmap[roop_count])
+ added = TRUE;
+ DBUG_PRINT("info",("vp added_bitmap[%d]=%u", roop_count,
+ added_bitmap[roop_count]));
+ }
+ DBUG_RETURN(added);
+}
+
+void ha_vp::add_child_bitmap(
+ int table_idx,
+ uchar *bitmap
+) {
+ int roop_count, field_idx;
+ uchar *tmp_r_bitmap;
+ int *correspond_columns_p =
+ &share->correspond_columns_p[table_idx * table_share->fields];
+ TABLE *child_table = part_tables[table_idx].table;
+ DBUG_ENTER("ha_vp::prune_child_bitmap");
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ tmp_r_bitmap = (uchar *) child_table->read_set->bitmap;
+
+#ifndef DBUG_OFF
+ int bitmap_size = (child_table->s->fields + 7) / 8;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp r_bitmap is %d-%u", roop_count,
+ tmp_r_bitmap[roop_count]));
+ }
+#endif
+ for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++)
+ {
+ if (vp_bit_is_set(bitmap, roop_count))
+ {
+ if ((field_idx = correspond_columns_p[roop_count]) < MAX_FIELDS)
+ {
+ vp_set_bit(tmp_r_bitmap, field_idx);
+ vp_clear_bit(bitmap, roop_count);
+ }
+ }
+ }
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp r_bitmap is %d-%u", roop_count,
+ tmp_r_bitmap[roop_count]));
+ }
+#endif
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::prune_child_bitmap(
+ int table_idx
+) {
+ int roop_count, field_idx;
+ uchar *tmp_r_bitmap, *tmp_w_bitmap, *pk_bitmap, *r_bitmap, *w_bitmap,
+ *idx_bitmap;
+ int *correspond_columns_c =
+ share->correspond_columns_c_ptr[table_idx];
+ bool correspond_flag = FALSE;
+ TABLE *child_table = part_tables[table_idx].table;
+ DBUG_ENTER("ha_vp::prune_child_bitmap");
+ DBUG_PRINT("info",("vp table_idx=%d", table_idx));
+ w_bitmap = (uchar *) idx_write_bitmap;
+ tmp_w_bitmap = (uchar *) child_table->write_set->bitmap;
+ r_bitmap = (uchar *) idx_read_bitmap;
+ tmp_r_bitmap = (uchar *) child_table->read_set->bitmap;
+
+ if (
+ update_request &&
+ vp_bit_is_set(share->need_full_col_for_update, table_idx)
+ ) {
+ /* use_full_column = TRUE; */
+ DBUG_VOID_RETURN;
+ }
+
+ if (
+ table_idx == child_table_idx &&
+ (!single_table || update_request || extra_use_cmp_ref || is_clone)
+ )
+ pk_bitmap = share->keys[table_share->primary_key].columns_bit;
+ else
+ pk_bitmap = NULL;
+
+ if (active_index < MAX_KEY)
+ idx_bitmap = share->keys[active_index].columns_bit;
+ else
+ idx_bitmap = NULL;
+
+#ifndef DBUG_OFF
+ int bitmap_size = (child_table->s->fields + 7) / 8;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp w_bitmap is %d-%u", roop_count,
+ tmp_w_bitmap[roop_count]));
+ DBUG_PRINT("info",("vp r_bitmap is %d-%u", roop_count,
+ tmp_r_bitmap[roop_count]));
+ }
+#endif
+ for (roop_count = 0; roop_count < (int) child_table->s->fields; roop_count++)
+ {
+ if (vp_bit_is_set(tmp_w_bitmap, roop_count))
+ {
+ field_idx = correspond_columns_c[roop_count];
+ if (!vp_bit_is_set(w_bitmap, field_idx))
+ {
+ DBUG_PRINT("info",("vp clear tmp_w_bitmap %d-%d", table_idx, roop_count));
+ vp_clear_bit(tmp_w_bitmap, roop_count);
+ } else
+ correspond_flag = TRUE;
+ }
+ if (vp_bit_is_set(tmp_r_bitmap, roop_count))
+ {
+ field_idx = correspond_columns_c[roop_count];
+ if (!vp_bit_is_set(r_bitmap, field_idx))
+ {
+ if (
+ (!idx_bitmap || !vp_bit_is_set(idx_bitmap, field_idx)) &&
+ (!pk_bitmap || !vp_bit_is_set(pk_bitmap, field_idx))
+ ) {
+ DBUG_PRINT("info",("vp clear tmp_r_bitmap %d-%d", table_idx, roop_count));
+ vp_clear_bit(tmp_r_bitmap, roop_count);
+ }
+ } else
+ correspond_flag = TRUE;
+ }
+ }
+
+ if (!correspond_flag && table_idx != child_table_idx)
+ {
+ DBUG_PRINT("info",("vp clear use_tables flag for %d", table_idx));
+ vp_clear_bit(use_tables, table_idx);
+ vp_set_bit(pruned_tables, table_idx);
+ pruned = TRUE;
+ }
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp w_bitmap is %d-%u", roop_count,
+ tmp_w_bitmap[roop_count]));
+ DBUG_PRINT("info",("vp r_bitmap is %d-%u", roop_count,
+ tmp_r_bitmap[roop_count]));
+ }
+#endif
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::prune_child()
+{
+ int roop_count;
+ TABLE *child_table;
+ DBUG_ENTER("ha_vp::prune_child");
+ DBUG_PRINT("info",("vp init_sel_key_bitmap=%s",
+ init_sel_key_bitmap ? "TRUE" : "FALSE"));
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ VP_BULK_ACCESS_INFO *bulk_access_info;
+ if (bulk_access_pre_called)
+ bulk_access_info = bulk_access_info_current;
+ else
+ bulk_access_info = bulk_access_info_exec_tgt;
+
+ if (bulk_access_info->init_sel_key_bitmap)
+ {
+ memcpy(use_tables, bulk_access_info->sel_key_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info->sel_key_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info->sel_key_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ } else {
+ if (get_added_bitmap(work_bitmap3,
+ (const uchar *) table->read_set->bitmap,
+ (const uchar *) idx_init_read_bitmap))
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ add_child_bitmap(roop_count, work_bitmap3);
+ }
+ }
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp added_bitmap[%d]=%u", roop_count,
+ work_bitmap3[roop_count]));
+ }
+#endif
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ prune_child_bitmap(roop_count);
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(bulk_access_info->sel_key_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(bulk_access_info->sel_key_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ }
+ memcpy(bulk_access_info->sel_key_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ bulk_access_info->init_sel_key_bitmap = TRUE;
+ }
+ } else {
+#endif
+ if (init_sel_key_bitmap)
+ {
+ memcpy(use_tables, sel_key_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ sel_key_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ sel_key_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ } else {
+ if (get_added_bitmap(work_bitmap3,
+ (const uchar *) table->read_set->bitmap,
+ (const uchar *) idx_init_read_bitmap))
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ add_child_bitmap(roop_count, work_bitmap3);
+ }
+ }
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp added_bitmap[%d]=%u", roop_count,
+ work_bitmap3[roop_count]));
+ }
+#endif
+ }
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ prune_child_bitmap(roop_count);
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(sel_key_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(sel_key_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ }
+ }
+ }
+ memcpy(sel_key_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ init_sel_key_bitmap = TRUE;
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+ set_child_pt_bitmap();
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::set_rnd_bitmap()
+{
+ int error_num, roop_count;
+ TABLE *child_table;
+#ifdef HA_CAN_BULK_ACCESS
+ VP_BULK_ACCESS_INFO *bulk_access_info = NULL;
+#endif
+ DBUG_ENTER("ha_vp::set_rnd_bitmap");
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp read_bitmap is %d-%u", roop_count,
+ table->read_set->bitmap[roop_count]));
+ DBUG_PRINT("info",("vp write_bitmap is %d-%u", roop_count,
+ table->write_set->bitmap[roop_count]));
+ }
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ if (bulk_access_pre_called)
+ bulk_access_info = bulk_access_info_current;
+ else
+ bulk_access_info = bulk_access_info_exec_tgt;
+ }
+#endif
+
+ if (rnd_scan)
+ {
+ if (
+#ifdef HA_CAN_BULK_ACCESS
+ (
+ !bulk_access_started &&
+ !(bulk_access_executing && bulk_access_info_exec_tgt->called) &&
+#endif
+ !init_sel_rnd_bitmap
+#ifdef HA_CAN_BULK_ACCESS
+ ) ||
+ (
+ bulk_access_started && bulk_access_pre_called &&
+ !bulk_access_info->init_sel_rnd_bitmap
+ )
+#endif
+ ) {
+ memset(use_tables, 0, sizeof(uchar) * share->use_tables_size);
+ child_keyread = FALSE;
+ single_table = FALSE;
+ set_used_table = FALSE;
+ if (
+ share->zero_record_update_mode &&
+ (lock_mode > 0 || lock_type_ext == F_WRLCK) &&
+ (sql_command == SQLCOM_UPDATE || sql_command == SQLCOM_UPDATE_MULTI)
+ ) {
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ rnd_init_read_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ rnd_init_write_bitmap[roop_count] |=
+ share->cpy_clm_bitmap[roop_count];
+ }
+ }
+ if (
+ (sql_command == SQLCOM_DELETE || sql_command == SQLCOM_DELETE_MULTI) &&
+ memcmp(rnd_init_read_bitmap, rnd_read_bitmap,
+ sizeof(uchar) * share->bitmap_size) < 0
+ ) {
+ memcpy(work_bitmap3, rnd_read_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, rnd_write_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ } else {
+ memcpy(work_bitmap3, rnd_init_read_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy(work_bitmap4, rnd_init_write_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ }
+
+ if (
+ (error_num = choose_child_ft_tables(work_bitmap3, work_bitmap4)) ||
+ (
+ !ft_correspond_flag &&
+ (error_num = choose_child_tables(work_bitmap3, work_bitmap4))
+ )
+ ) {
+ DBUG_RETURN(error_num);
+ }
+ set_child_pt_bitmap();
+ }
+ }
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ if (
+ bulk_access_pre_called &&
+ !bulk_access_info->init_sel_rnd_bitmap
+ ) {
+ if (rnd_scan)
+ memcpy(bulk_access_info->sel_rnd_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ else {
+ memcpy(bulk_access_info->sel_rnd_use_tables,
+ bulk_access_info->sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ memcpy(use_tables, bulk_access_info->sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ }
+ } else if (cb_state != CB_SEL_RND)
+ memcpy(use_tables, bulk_access_info->sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ } else {
+#endif
+ if (!init_sel_rnd_bitmap)
+ {
+ if (rnd_scan)
+ memcpy(sel_rnd_use_tables, use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ else {
+ memcpy(sel_rnd_use_tables, sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ memcpy(use_tables, sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ }
+ } else if (cb_state != CB_SEL_RND)
+ memcpy(use_tables, sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (bulk_access_info->init_sel_rnd_bitmap)
+ {
+ if (cb_state != CB_SEL_RND)
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ } else {
+ child_table = part_tables[roop_count].table;
+ if (rnd_scan)
+ {
+ memcpy(bulk_access_info->sel_rnd_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(bulk_access_info->sel_rnd_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ } else {
+ memcpy(bulk_access_info->sel_rnd_child_bitmaps[0][roop_count],
+ bulk_access_info->sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(bulk_access_info->sel_rnd_child_bitmaps[1][roop_count],
+ bulk_access_info->sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ if (
+ (!rnd_scan && !vp_bit_is_set(pruned_tables, roop_count)) ||
+ roop_count == child_table_idx
+ ) {
+ if (!ft_inited || !vp_bit_is_set(ft_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[roop_count].table));
+ vp_set_bit(rnd_inited_tables, roop_count);
+ if (bulk_access_pre_called)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->
+ ha_pre_rnd_init(rnd_scan)))
+ DBUG_RETURN(error_num);
+ } else {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_rnd_init(rnd_scan)))
+ DBUG_RETURN(error_num);
+ }
+ } else {
+ DBUG_PRINT("info",("vp no rnd init"));
+ }
+ } else if (!bulk_access_pre_called || update_request) {
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[roop_count].table));
+ vp_set_bit(rnd_inited_tables, roop_count);
+ if (bulk_access_pre_called)
+ {
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_pre_index_init(
+ share->correspond_pk[roop_count]->key_idx, FALSE)))
+ DBUG_RETURN(error_num);
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_index_init(
+ share->correspond_pk[roop_count]->key_idx, FALSE)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ }
+ bulk_access_info->init_sel_rnd_bitmap = TRUE;
+ } else {
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ if (init_sel_rnd_bitmap)
+ {
+ if (cb_state != CB_SEL_RND)
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ } else {
+ child_table = part_tables[roop_count].table;
+ if (rnd_scan)
+ {
+ memcpy(sel_rnd_child_bitmaps[0][roop_count],
+ child_table->read_set->bitmap,
+ child_table->s->column_bitmap_size);
+ memcpy(sel_rnd_child_bitmaps[1][roop_count],
+ child_table->write_set->bitmap,
+ child_table->s->column_bitmap_size);
+ } else {
+ memcpy(sel_rnd_child_bitmaps[0][roop_count],
+ sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(sel_rnd_child_bitmaps[1][roop_count],
+ sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->read_set->bitmap,
+ sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ if (
+ (!rnd_scan && !vp_bit_is_set(pruned_tables, roop_count)) ||
+ roop_count == child_table_idx
+ ) {
+ if (!ft_inited || !vp_bit_is_set(ft_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[roop_count].table));
+ vp_set_bit(rnd_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_rnd_init(rnd_scan)))
+ DBUG_RETURN(error_num);
+ } else {
+ DBUG_PRINT("info",("vp no rnd init"));
+ }
+ } else {
+ DBUG_PRINT("info",("vp call child[%d] ha_index_init",
+ roop_count));
+ DBUG_PRINT("info",("vp child_table=%p",
+ part_tables[roop_count].table));
+ vp_set_bit(rnd_inited_tables, roop_count);
+ if ((error_num =
+ part_tables[roop_count].table->file->ha_index_init(
+ share->correspond_pk[roop_count]->key_idx, FALSE)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+ init_sel_rnd_bitmap = TRUE;
+ DBUG_RETURN(0);
+}
+
+void ha_vp::reset_rnd_bitmap()
+{
+ int roop_count;
+ TABLE *child_table;
+#ifdef HA_CAN_BULK_ACCESS
+ VP_BULK_ACCESS_INFO *bulk_access_info;
+#endif
+ DBUG_ENTER("ha_vp::reset_rnd_bitmap");
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ if (bulk_access_pre_called)
+ bulk_access_info = bulk_access_info_current;
+ else
+ bulk_access_info = bulk_access_info_exec_tgt;
+
+ memcpy(use_tables, bulk_access_info->sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ bulk_access_info->sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+ } else {
+#endif
+ memcpy(use_tables, sel_rnd_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ sel_rnd_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ sel_rnd_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ }
+ }
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+ DBUG_VOID_RETURN;
+}
+
+int ha_vp::set_rnd_bitmap_from_another(
+ ha_vp *another_vp
+) {
+ int error_num, roop_count;
+ TABLE *child_table;
+ DBUG_ENTER("ha_vp::set_rnd_bitmap_from_another");
+ if (inited == NONE)
+ memset(rnd_inited_tables, 0, sizeof(uchar) * share->use_tables_size);
+
+ memcpy(use_tables, another_vp->sel_key_init_use_tables,
+ sizeof(uchar) * share->use_tables_size);
+ child_table_idx = another_vp->child_table_idx;
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ child_table = part_tables[roop_count].table;
+ memcpy(child_table->read_set->bitmap,
+ another_vp->sel_key_init_child_bitmaps[0][roop_count],
+ child_table->s->column_bitmap_size);
+ memcpy(child_table->write_set->bitmap,
+ another_vp->sel_key_init_child_bitmaps[1][roop_count],
+ child_table->s->column_bitmap_size);
+ if (!vp_bit_is_set(rnd_inited_tables, roop_count))
+ {
+ DBUG_PRINT("info",("vp table_count=%d", roop_count));
+ DBUG_PRINT("info",("vp child_table=%p", child_table));
+ vp_set_bit(rnd_inited_tables, roop_count);
+ if ((error_num =
+ child_table->file->ha_rnd_init(rnd_scan)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::open_item_type(
+ Item *item,
+ int table_idx
+) {
+ DBUG_ENTER("ha_vp::open_item_type");
+ DBUG_PRINT("info",("vp COND type=%d", item->type()));
+ switch (item->type())
+ {
+ case Item::FUNC_ITEM:
+ DBUG_RETURN(open_item_func((Item_func *) item, table_idx));
+ case Item::COND_ITEM:
+ DBUG_RETURN(open_item_cond((Item_cond *) item, table_idx));
+ case Item::FIELD_ITEM:
+ DBUG_RETURN(open_item_field((Item_field *) item, table_idx));
+ case Item::REF_ITEM:
+ DBUG_RETURN(open_item_ref((Item_ref *) item, table_idx));
+ case Item::ROW_ITEM:
+ DBUG_RETURN(open_item_row((Item_row *) item, table_idx));
+ case Item::SUBSELECT_ITEM:
+ case Item::TRIGGER_FIELD_ITEM:
+ DBUG_PRINT("info",("vp return = %d", ER_VP_COND_SKIP_NUM));
+ DBUG_RETURN(ER_VP_COND_SKIP_NUM);
+ default:
+ break;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::open_item_cond(
+ Item_cond *item_cond,
+ int table_idx
+) {
+ int error_num = 0;
+ List_iterator_fast<Item> lif(*(item_cond->argument_list()));
+ Item *item;
+ uint restart_pos;
+ DBUG_ENTER("ha_vp::open_item_cond");
+
+restart_first:
+ if ((item = lif++))
+ {
+ restart_pos = child_cond_count[table_idx];
+ if ((error_num = open_item_type(item, table_idx)))
+ {
+ if (error_num == ER_VP_COND_SKIP_NUM)
+ {
+ DBUG_PRINT("info",("vp COND skip"));
+ child_cond_count[table_idx] = restart_pos;
+ goto restart_first;
+ }
+ DBUG_RETURN(error_num);
+ }
+ }
+ if (error_num)
+ DBUG_RETURN(error_num);
+ while ((item = lif++))
+ {
+ restart_pos = child_cond_count[table_idx];
+ if ((error_num = open_item_type(item, table_idx)))
+ {
+ if (error_num == ER_VP_COND_SKIP_NUM)
+ {
+ DBUG_PRINT("info",("vp COND skip"));
+ child_cond_count[table_idx] = restart_pos;
+ } else
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::open_item_func(
+ Item_func *item_func,
+ int table_idx
+) {
+ int error_num;
+ Item *item, **item_list = item_func->arguments();
+ uint roop_count, item_count = item_func->argument_count();
+ DBUG_ENTER("ha_vp::open_item_func");
+ DBUG_PRINT("info",("vp functype = %d", item_func->functype()));
+ switch (item_func->functype())
+ {
+#ifdef VP_ITEM_FUNC_HAS_XOR_FUNC
+#else
+ case Item_func::COND_XOR_FUNC:
+ DBUG_RETURN(
+ open_item_cond((Item_cond *) item_func, table_idx));
+#endif
+ case Item_func::TRIG_COND_FUNC:
+ DBUG_PRINT("info",("vp return = %d", ER_VP_COND_SKIP_NUM));
+ DBUG_RETURN(ER_VP_COND_SKIP_NUM);
+/* memo
+ case Item_func::ISNULL_FUNC:
+ case Item_func::ISNOTNULL_FUNC:
+ case Item_func::UNKNOWN_FUNC:
+ case Item_func::NOW_FUNC:
+ case Item_func::NOT_FUNC:
+ case Item_func::NEG_FUNC:
+ case Item_func::IN_FUNC:
+ case Item_func::BETWEEN:
+ case Item_func::UDF_FUNC:
+ case Item_func::EQ_FUNC:
+ case Item_func::EQUAL_FUNC:
+ case Item_func::NE_FUNC:
+ case Item_func::LT_FUNC:
+ case Item_func::LE_FUNC:
+ case Item_func::GE_FUNC:
+ case Item_func::GT_FUNC:
+#ifdef VP_ITEM_FUNC_HAS_XOR_FUNC
+ case Item_func::XOR_FUNC:
+#endif
+*/
+ default:
+ break;
+ }
+ if (item_count)
+ {
+ for (roop_count = 0; roop_count < item_count; roop_count++)
+ {
+ item = item_list[roop_count];
+ if ((error_num = open_item_type(item, table_idx)))
+ DBUG_RETURN(error_num);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::open_item_ident(
+ Item_ident *item_ident,
+ int table_idx
+) {
+ DBUG_ENTER("ha_vp::open_item_ident");
+ DBUG_RETURN(0);
+}
+
+int ha_vp::open_item_field(
+ Item_field *item_field,
+ int table_idx
+) {
+ Field *field = item_field->field;
+ TABLE *child_table = part_tables[table_idx].table;
+ handler *file = child_table->file;
+ DBUG_ENTER("ha_vp::open_item_field");
+ if (field)
+ {
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ if (file->set_top_table_fields)
+ {
+ if (field->table != file->top_table)
+ {
+ DBUG_PRINT("info",("vp return = %d", ER_VP_COND_SKIP_NUM));
+ DBUG_RETURN(ER_VP_COND_SKIP_NUM);
+ }
+ if (!(field = file->top_table_field[field->field_index]))
+ {
+ DBUG_PRINT("info",("vp return = %d", ER_VP_COND_SKIP_NUM));
+ DBUG_RETURN(ER_VP_COND_SKIP_NUM);
+ }
+ } else {
+#endif
+ if (field->table != child_table)
+ {
+ DBUG_PRINT("info",("vp return = %d", ER_VP_COND_SKIP_NUM));
+ DBUG_RETURN(ER_VP_COND_SKIP_NUM);
+ }
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ }
+#endif
+ child_cond_count[table_idx]++;
+ DBUG_PRINT("info",("vp child_cond_count[%d] = %u", table_idx,
+ child_cond_count[table_idx]));
+ DBUG_RETURN(0);
+ }
+ DBUG_RETURN(open_item_ident(
+ (Item_ident *) item_field, table_idx));
+}
+
+int ha_vp::open_item_ref(
+ Item_ref *item_ref,
+ int table_idx
+) {
+ DBUG_ENTER("ha_vp::open_item_ref");
+ if (item_ref->ref)
+ {
+ if (
+ (*(item_ref->ref))->type() != Item::CACHE_ITEM &&
+ item_ref->ref_type() != Item_ref::VIEW_REF &&
+ !item_ref->table_name &&
+ VP_item_name_str(item_ref) &&
+ item_ref->alias_name_used
+ )
+ DBUG_RETURN(0);
+ DBUG_RETURN(open_item_type(*(item_ref->ref), table_idx));
+ }
+ DBUG_RETURN(open_item_ident((Item_ident *) item_ref, table_idx));
+}
+
+int ha_vp::open_item_row(
+ Item_row *item_row,
+ int table_idx
+) {
+ int error_num;
+ uint roop_count, cols = item_row->cols();
+ Item *item;
+ DBUG_ENTER("ha_vp::open_item_row");
+ for (roop_count = 0; roop_count < cols; roop_count++)
+ {
+ item = item_row->element_index(roop_count);
+ if ((error_num = open_item_type(item, table_idx)))
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::count_condition(
+ int table_idx
+) {
+ int error_num;
+ uint restart_pos;
+ VP_CONDITION *tmp_cond = condition;
+ DBUG_ENTER("ha_vp::count_condition");
+ while (tmp_cond)
+ {
+ restart_pos = child_cond_count[table_idx];
+ if ((error_num = open_item_type((Item *) tmp_cond->cond, table_idx)))
+ {
+ if (error_num == ER_VP_COND_SKIP_NUM)
+ {
+ DBUG_PRINT("info",("vp COND skip"));
+ child_cond_count[table_idx] = restart_pos;
+ } else
+ DBUG_RETURN(error_num);
+ }
+ tmp_cond = tmp_cond->next;
+ }
+ DBUG_RETURN(0);
+}
+
+int ha_vp::create_bg_thread(
+ VP_BG_BASE *base
+) {
+ int error_num;
+ DBUG_ENTER("ha_vp::create_bg_thread");
+ if (!base->bg_init)
+ {
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&base->bg_sync_mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_bg_sync,
+ &base->bg_sync_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_sync_mutex_init;
+ }
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&base->bg_mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_bg,
+ &base->bg_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_mutex_init;
+ }
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_cond_init(&base->bg_sync_cond, NULL))
+#else
+ if (mysql_cond_init(vp_key_cond_bg_sync,
+ &base->bg_sync_cond, NULL))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_sync_cond_init;
+ }
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_cond_init(&base->bg_cond, NULL))
+#else
+ if (mysql_cond_init(vp_key_cond_bg,
+ &base->bg_cond, NULL))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_cond_init;
+ }
+ pthread_mutex_lock(&base->bg_mutex);
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_create(&base->bg_thread, &vp_pt_attr,
+ vp_bg_action, (void *) base)
+ )
+#else
+ if (mysql_thread_create(vp_key_thd_bg, &base->bg_thread,
+ &vp_pt_attr, vp_bg_action, (void *) base)
+ )
+#endif
+ {
+ pthread_mutex_unlock(&base->bg_mutex);
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_thread_create;
+ }
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_cond);
+ pthread_mutex_unlock(&base->bg_mutex);
+ pthread_cond_wait(&base->bg_sync_cond, &base->bg_sync_mutex);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ if (!base->bg_init)
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_thread_create;
+ }
+ }
+ DBUG_RETURN(0);
+
+error_thread_create:
+ pthread_cond_destroy(&base->bg_cond);
+error_cond_init:
+ pthread_cond_destroy(&base->bg_sync_cond);
+error_sync_cond_init:
+ pthread_mutex_destroy(&base->bg_mutex);
+error_mutex_init:
+ pthread_mutex_destroy(&base->bg_sync_mutex);
+error_sync_mutex_init:
+ DBUG_RETURN(error_num);
+}
+
+void ha_vp::free_bg_thread(
+ VP_BG_BASE *base
+) {
+ DBUG_ENTER("ha_vp::free_bg_thread");
+ if (base->bg_init)
+ {
+ pthread_mutex_lock(&base->bg_mutex);
+ base->bg_command = VP_BG_COMMAND_KILL;
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_cond);
+ pthread_mutex_unlock(&base->bg_mutex);
+ pthread_cond_wait(&base->bg_sync_cond, &base->bg_sync_mutex);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ pthread_cond_destroy(&base->bg_cond);
+ pthread_cond_destroy(&base->bg_sync_cond);
+ pthread_mutex_destroy(&base->bg_mutex);
+ pthread_mutex_destroy(&base->bg_sync_mutex);
+ base->bg_init = FALSE;
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::bg_kick(
+ VP_BG_BASE *base
+) {
+ DBUG_ENTER("ha_vp::bg_kick");
+ pthread_mutex_lock(&base->bg_mutex);
+ base->bg_caller_sync_wait = TRUE;
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_cond);
+ pthread_mutex_unlock(&base->bg_mutex);
+ pthread_cond_wait(&base->bg_sync_cond, &base->bg_sync_mutex);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ base->bg_caller_sync_wait = FALSE;
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::bg_wait(
+ VP_BG_BASE *base
+) {
+ DBUG_ENTER("ha_vp::bg_wait");
+ pthread_mutex_lock(&base->bg_mutex);
+ pthread_mutex_unlock(&base->bg_mutex);
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::init_select_column(bool rnd)
+{
+ DBUG_ENTER("ha_vp::init_select_column");
+#ifndef DBUG_OFF
+ int roop_count;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp read_bitmap is %d-%u", roop_count,
+ ((uchar *) table->read_set->bitmap)[roop_count]));
+ DBUG_PRINT("info",("vp write_bitmap is %d-%u", roop_count,
+ ((uchar *) table->write_set->bitmap)[roop_count]));
+ }
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ VP_BULK_ACCESS_INFO *bulk_access_info;
+ if (bulk_access_pre_called)
+ bulk_access_info = bulk_access_info_current;
+ else
+ bulk_access_info = bulk_access_info_exec_tgt;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share)
+ {
+ if (!rnd)
+ {
+ if (!bulk_access_info->partition_handler_share->idx_init_flg)
+ {
+ memcpy(bulk_access_info->partition_handler_share->
+ idx_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->partition_handler_share->
+ idx_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->partition_handler_share->idx_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set idx_init_bitmap"));
+ }
+ if (!bulk_access_info->idx_bitmap_init_flg)
+ {
+ memcpy(bulk_access_info->idx_init_read_bitmap,
+ bulk_access_info->partition_handler_share->idx_init_read_bitmap,
+ bitmap_map_size);
+ memcpy(bulk_access_info->idx_init_write_bitmap,
+ bulk_access_info->partition_handler_share->idx_init_write_bitmap,
+ bitmap_map_size);
+ bulk_access_info->idx_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp copy idx_init_bitmap"));
+ }
+ } else {
+ if (!bulk_access_info->partition_handler_share->rnd_init_flg)
+ {
+ memcpy(bulk_access_info->partition_handler_share->
+ rnd_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->partition_handler_share->
+ rnd_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->partition_handler_share->rnd_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set rnd_init_bitmap"));
+ }
+ if (!bulk_access_info->rnd_bitmap_init_flg)
+ {
+ memcpy(bulk_access_info->rnd_init_read_bitmap,
+ bulk_access_info->partition_handler_share->rnd_init_read_bitmap,
+ bitmap_map_size);
+ memcpy(bulk_access_info->rnd_init_write_bitmap,
+ bulk_access_info->partition_handler_share->rnd_init_write_bitmap,
+ bitmap_map_size);
+ bulk_access_info->rnd_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp copy rnd_init_bitmap"));
+ }
+ }
+ } else {
+#endif
+ if (!rnd)
+ {
+ if (!bulk_access_info->idx_bitmap_init_flg)
+ {
+ memcpy(bulk_access_info->idx_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->idx_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->idx_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set ha idx_init_bitmap"));
+ }
+ } else {
+ if (!bulk_access_info->rnd_bitmap_init_flg)
+ {
+ memcpy(bulk_access_info->rnd_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->rnd_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->rnd_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set ha rnd_init_bitmap"));
+ }
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ }
+#endif
+ } else {
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share)
+ {
+ if (!rnd)
+ {
+ if (!partition_handler_share->idx_init_flg)
+ {
+ memcpy(partition_handler_share->idx_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(partition_handler_share->idx_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ partition_handler_share->idx_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set idx_init_bitmap"));
+ }
+ if (!idx_bitmap_init_flg)
+ {
+ memcpy(idx_init_read_bitmap,
+ partition_handler_share->idx_init_read_bitmap, bitmap_map_size);
+ memcpy(idx_init_write_bitmap,
+ partition_handler_share->idx_init_write_bitmap, bitmap_map_size);
+ idx_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp copy idx_init_bitmap"));
+ }
+ } else {
+ if (!partition_handler_share->rnd_init_flg)
+ {
+ memcpy(partition_handler_share->rnd_init_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(partition_handler_share->rnd_init_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ partition_handler_share->rnd_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set rnd_init_bitmap"));
+ }
+ if (!rnd_bitmap_init_flg)
+ {
+ memcpy(rnd_init_read_bitmap,
+ partition_handler_share->rnd_init_read_bitmap, bitmap_map_size);
+ memcpy(rnd_init_write_bitmap,
+ partition_handler_share->rnd_init_write_bitmap, bitmap_map_size);
+ rnd_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp copy rnd_init_bitmap"));
+ }
+ }
+ } else {
+#endif
+ if (!rnd)
+ {
+ if (!idx_bitmap_init_flg)
+ {
+ memcpy(idx_init_read_bitmap, table->read_set->bitmap,
+ bitmap_map_size);
+ memcpy(idx_init_write_bitmap, table->write_set->bitmap,
+ bitmap_map_size);
+ idx_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set ha idx_init_bitmap"));
+ }
+ } else {
+ if (!rnd_bitmap_init_flg)
+ {
+ memcpy(rnd_init_read_bitmap, table->read_set->bitmap,
+ bitmap_map_size);
+ memcpy(rnd_init_write_bitmap, table->write_set->bitmap,
+ bitmap_map_size);
+ rnd_bitmap_init_flg = TRUE;
+ DBUG_PRINT("info",("vp set ha rnd_init_bitmap"));
+ }
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ }
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::check_select_column(bool rnd)
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::check_select_column");
+#ifndef DBUG_OFF
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp read_bitmap is %d-%u", roop_count,
+ ((uchar *) table->read_set->bitmap)[roop_count]));
+ DBUG_PRINT("info",("vp write_bitmap is %d-%u", roop_count,
+ ((uchar *) table->write_set->bitmap)[roop_count]));
+ }
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+ if (
+ bulk_access_started ||
+ (bulk_access_executing && bulk_access_info_exec_tgt->called)
+ ) {
+ VP_BULK_ACCESS_INFO *bulk_access_info;
+ if (bulk_access_pre_called)
+ {
+ DBUG_PRINT("info",("vp bulk_access_pre_called=TRUE"));
+ bulk_access_info = bulk_access_info_current;
+ } else {
+ DBUG_PRINT("info",("vp bulk_access_pre_called=FALSE"));
+ bulk_access_info = bulk_access_info_exec_tgt;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (bulk_access_info->partition_handler_share)
+ {
+ if (!rnd)
+ {
+ if (is_clone)
+ {
+ if (!bulk_access_info->clone_partition_handler_share->
+ idx_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->clone_partition_handler_share->
+ idx_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->clone_partition_handler_share->
+ idx_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->clone_partition_handler_share->
+ idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set clone idx_bitmap"));
+ }
+ if (!bulk_access_info->idx_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->idx_read_bitmap,
+ bulk_access_info->clone_partition_handler_share->
+ idx_read_bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->idx_write_bitmap,
+ bulk_access_info->clone_partition_handler_share->
+ idx_write_bitmap,
+ bitmap_map_size);
+ bulk_access_info->idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy clone idx_bitmap"));
+ }
+ TABLE *table2;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ table2 = part_tables[roop_count].table;
+ memcpy(table2->read_set->bitmap,
+ bulk_access_info->sel_key_init_child_bitmaps[0][roop_count],
+ table2->s->column_bitmap_size);
+ memcpy(table2->write_set->bitmap,
+ bulk_access_info->sel_key_init_child_bitmaps[1][roop_count],
+ table2->s->column_bitmap_size);
+#ifndef DBUG_OFF
+ int roop_count2;
+ for (roop_count2 = 0; roop_count2 <
+ (int) table2->s->column_bitmap_size; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp child read_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->read_set->bitmap)[roop_count2]));
+ DBUG_PRINT("info",("vp child write_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->write_set->bitmap)[roop_count2]));
+ }
+#endif
+ }
+ }
+ } else {
+ if (!bulk_access_info->partition_handler_share->idx_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->partition_handler_share->idx_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->partition_handler_share->idx_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->partition_handler_share->
+ idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set idx_bitmap"));
+ }
+ if (!bulk_access_info->idx_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->idx_read_bitmap,
+ bulk_access_info->partition_handler_share->idx_read_bitmap,
+ bitmap_map_size);
+ memcpy(bulk_access_info->idx_write_bitmap,
+ bulk_access_info->partition_handler_share->idx_write_bitmap,
+ bitmap_map_size);
+ bulk_access_info->idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy idx_bitmap"));
+ }
+ }
+ } else {
+ if (!bulk_access_info->partition_handler_share->rnd_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->partition_handler_share->rnd_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->partition_handler_share->rnd_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->partition_handler_share->rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set rnd_bitmap"));
+ }
+ if (!bulk_access_info->rnd_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->rnd_read_bitmap,
+ bulk_access_info->partition_handler_share->rnd_read_bitmap,
+ bitmap_map_size);
+ memcpy(bulk_access_info->rnd_write_bitmap,
+ bulk_access_info->partition_handler_share->rnd_write_bitmap,
+ bitmap_map_size);
+ bulk_access_info->rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy rnd_bitmap"));
+ }
+ }
+ } else {
+#endif
+ if (!rnd)
+ {
+ if (!bulk_access_info->idx_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->idx_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->idx_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set ha idx_bitmap"));
+ }
+ } else {
+ if (!bulk_access_info->rnd_bitmap_is_set)
+ {
+ memcpy(bulk_access_info->rnd_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(bulk_access_info->rnd_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ bulk_access_info->rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set ha rnd_bitmap"));
+ }
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ }
+#endif
+ } else {
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share)
+ {
+ if (!rnd)
+ {
+ if (is_clone)
+ {
+ if (!clone_partition_handler_share->idx_bitmap_is_set)
+ {
+ memcpy(clone_partition_handler_share->idx_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(clone_partition_handler_share->idx_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ clone_partition_handler_share->idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set clone idx_bitmap"));
+ }
+ if (!idx_bitmap_is_set)
+ {
+ memcpy(idx_read_bitmap,
+ clone_partition_handler_share->idx_read_bitmap, bitmap_map_size);
+ memcpy(idx_write_bitmap,
+ clone_partition_handler_share->idx_write_bitmap,
+ bitmap_map_size);
+ idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy clone idx_bitmap"));
+ }
+ TABLE *table2;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(use_tables, roop_count))
+ {
+ table2 = part_tables[roop_count].table;
+ memcpy(table2->read_set->bitmap,
+ sel_key_init_child_bitmaps[0][roop_count],
+ table2->s->column_bitmap_size);
+ memcpy(table2->write_set->bitmap,
+ sel_key_init_child_bitmaps[1][roop_count],
+ table2->s->column_bitmap_size);
+#ifndef DBUG_OFF
+ int roop_count2;
+ for (roop_count2 = 0; roop_count2 <
+ (int) table2->s->column_bitmap_size; roop_count2++)
+ {
+ DBUG_PRINT("info",("vp child read_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->read_set->bitmap)[roop_count2]));
+ DBUG_PRINT("info",("vp child write_bitmap is %d-%d-%u",
+ roop_count, roop_count2,
+ ((uchar *) table2->write_set->bitmap)[roop_count2]));
+ }
+#endif
+ }
+ }
+ } else {
+ if (!partition_handler_share->idx_bitmap_is_set)
+ {
+ memcpy(partition_handler_share->idx_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(partition_handler_share->idx_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ partition_handler_share->idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set idx_bitmap"));
+ }
+ if (!idx_bitmap_is_set)
+ {
+ memcpy(idx_read_bitmap,
+ partition_handler_share->idx_read_bitmap, bitmap_map_size);
+ memcpy(idx_write_bitmap,
+ partition_handler_share->idx_write_bitmap, bitmap_map_size);
+ idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy idx_bitmap"));
+ }
+ }
+ } else {
+ if (!partition_handler_share->rnd_bitmap_is_set)
+ {
+ memcpy(partition_handler_share->rnd_read_bitmap,
+ table->read_set->bitmap, bitmap_map_size);
+ memcpy(partition_handler_share->rnd_write_bitmap,
+ table->write_set->bitmap, bitmap_map_size);
+ partition_handler_share->rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set rnd_bitmap"));
+ }
+ if (!rnd_bitmap_is_set)
+ {
+ memcpy(rnd_read_bitmap,
+ partition_handler_share->rnd_read_bitmap, bitmap_map_size);
+ memcpy(rnd_write_bitmap,
+ partition_handler_share->rnd_write_bitmap, bitmap_map_size);
+ rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp copy rnd_bitmap"));
+ }
+ }
+ } else {
+#endif
+ if (!rnd)
+ {
+ if (!idx_bitmap_is_set)
+ {
+ memcpy(idx_read_bitmap, table->read_set->bitmap, bitmap_map_size);
+ memcpy(idx_write_bitmap, table->write_set->bitmap, bitmap_map_size);
+ idx_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set ha idx_bitmap"));
+ }
+ } else {
+ if (!rnd_bitmap_is_set)
+ {
+ memcpy(rnd_read_bitmap, table->read_set->bitmap, bitmap_map_size);
+ memcpy(rnd_write_bitmap, table->write_set->bitmap, bitmap_map_size);
+ rnd_bitmap_is_set = TRUE;
+ DBUG_PRINT("info",("vp set ha rnd_bitmap"));
+ }
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ }
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+ }
+#endif
+ DBUG_VOID_RETURN;
+}
+
+void ha_vp::clone_init_select_column()
+{
+ DBUG_ENTER("ha_vp::clone_init_select_column");
+#ifndef DBUG_OFF
+ int roop_count;
+ for (roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ {
+ DBUG_PRINT("info",("vp read_bitmap is %d-%u", roop_count,
+ ((uchar *) pt_clone_source_handler->idx_init_read_bitmap)[roop_count]));
+ DBUG_PRINT("info",("vp write_bitmap is %d-%u", roop_count,
+ ((uchar *) pt_clone_source_handler->idx_init_write_bitmap)[roop_count]));
+ }
+#endif
+ memcpy(idx_init_read_bitmap,
+ pt_clone_source_handler->idx_init_read_bitmap, bitmap_map_size);
+ memcpy(idx_init_write_bitmap,
+ pt_clone_source_handler->idx_init_write_bitmap, bitmap_map_size);
+ idx_bitmap_init_flg = TRUE;
+ DBUG_VOID_RETURN;
+}
+
+uint ha_vp::check_partitioned()
+{
+ uint part_num;
+ DBUG_ENTER("ha_vp::check_partitioned");
+ DBUG_PRINT("info",("vp this=%p", this));
+ table->file->get_no_parts("", &part_num);
+ if (part_num)
+ DBUG_RETURN(part_num);
+
+ TABLE_LIST *tmp_table_list = table->pos_in_table_list;
+ while ((tmp_table_list = tmp_table_list->parent_l))
+ {
+ tmp_table_list->table->file->get_no_parts("", &part_num);
+ if (part_num)
+ DBUG_RETURN(part_num);
+ }
+ DBUG_RETURN(0);
+}
+
+#ifdef HA_CAN_BULK_ACCESS
+VP_BULK_ACCESS_INFO *ha_vp::create_bulk_access_info()
+{
+ int roop_count;
+ TABLE_SHARE *part_table_share;
+ VP_BULK_ACCESS_INFO *bulk_access_info;
+ my_bitmap_map *tmp_idx_init_read_bitmap;
+ my_bitmap_map *tmp_idx_init_write_bitmap;
+ my_bitmap_map *tmp_rnd_init_read_bitmap;
+ my_bitmap_map *tmp_rnd_init_write_bitmap;
+ my_bitmap_map *tmp_idx_read_bitmap;
+ my_bitmap_map *tmp_idx_write_bitmap;
+ my_bitmap_map *tmp_rnd_read_bitmap;
+ my_bitmap_map *tmp_rnd_write_bitmap;
+ uchar **tmp_sel_key_init_child_bitmaps[2];
+ uchar **tmp_sel_key_child_bitmaps[2];
+ uchar **tmp_sel_rnd_child_bitmaps[2];
+ uchar **tmp_ins_child_bitmaps[2];
+ uchar *tmp_child_column_bitmap;
+ uchar *tmp_sel_key_init_use_tables;
+ uchar *tmp_sel_key_use_tables;
+ uchar *tmp_sel_rnd_use_tables;
+ void **tmp_info;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_HANDLER_SHARE *tmp_partition_handler_share;
+ my_bitmap_map *tmp_idx_init_read_bitmap2;
+ my_bitmap_map *tmp_idx_init_write_bitmap2;
+ my_bitmap_map *tmp_rnd_init_read_bitmap2;
+ my_bitmap_map *tmp_rnd_init_write_bitmap2;
+ my_bitmap_map *tmp_idx_read_bitmap2;
+ my_bitmap_map *tmp_idx_write_bitmap2;
+ my_bitmap_map *tmp_rnd_read_bitmap2;
+ my_bitmap_map *tmp_rnd_write_bitmap2;
+ VP_CLONE_PARTITION_HANDLER_SHARE *tmp_clone_partition_handler_share;
+ my_bitmap_map *tmp_idx_read_bitmap3;
+ my_bitmap_map *tmp_idx_write_bitmap3;
+#endif
+ DBUG_ENTER("ha_vp::create_bulk_access_info");
+ DBUG_PRINT("info",("vp this=%p", this));
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share && partition_handler_share->creator == this)
+ {
+ if (!(bulk_access_info = (VP_BULK_ACCESS_INFO *)
+ my_multi_malloc(MYF(MY_WME),
+ &bulk_access_info, sizeof(VP_BULK_ACCESS_INFO),
+ &tmp_idx_init_read_bitmap, bitmap_map_size,
+ &tmp_idx_init_write_bitmap, bitmap_map_size,
+ &tmp_rnd_init_read_bitmap, bitmap_map_size,
+ &tmp_rnd_init_write_bitmap, bitmap_map_size,
+ &tmp_idx_read_bitmap, bitmap_map_size,
+ &tmp_idx_write_bitmap, bitmap_map_size,
+ &tmp_rnd_read_bitmap, bitmap_map_size,
+ &tmp_rnd_write_bitmap, bitmap_map_size,
+ &tmp_ins_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_ins_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_init_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_init_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_rnd_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_rnd_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_child_column_bitmap, sizeof(uchar) * child_column_bitmap_size * 8,
+ &tmp_sel_key_init_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_sel_key_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_sel_rnd_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_info, sizeof(void *) * share->table_count,
+ &tmp_partition_handler_share, sizeof(VP_PARTITION_HANDLER_SHARE),
+ &tmp_idx_init_read_bitmap2, bitmap_map_size,
+ &tmp_idx_init_write_bitmap2, bitmap_map_size,
+ &tmp_rnd_init_read_bitmap2, bitmap_map_size,
+ &tmp_rnd_init_write_bitmap2, bitmap_map_size,
+ &tmp_idx_read_bitmap2, bitmap_map_size,
+ &tmp_idx_write_bitmap2, bitmap_map_size,
+ &tmp_rnd_read_bitmap2, bitmap_map_size,
+ &tmp_rnd_write_bitmap2, bitmap_map_size,
+ &tmp_clone_partition_handler_share,
+ sizeof(VP_CLONE_PARTITION_HANDLER_SHARE),
+ &tmp_idx_read_bitmap3, bitmap_map_size,
+ &tmp_idx_write_bitmap3, bitmap_map_size,
+ NullS))
+ ) {
+ goto error_bulk_malloc;
+ }
+ } else {
+#endif
+ if (!(bulk_access_info = (VP_BULK_ACCESS_INFO *)
+ my_multi_malloc(MYF(MY_WME),
+ &bulk_access_info, sizeof(VP_BULK_ACCESS_INFO),
+ &tmp_idx_init_read_bitmap, bitmap_map_size,
+ &tmp_idx_init_write_bitmap, bitmap_map_size,
+ &tmp_rnd_init_read_bitmap, bitmap_map_size,
+ &tmp_rnd_init_write_bitmap, bitmap_map_size,
+ &tmp_idx_read_bitmap, bitmap_map_size,
+ &tmp_idx_write_bitmap, bitmap_map_size,
+ &tmp_rnd_read_bitmap, bitmap_map_size,
+ &tmp_rnd_write_bitmap, bitmap_map_size,
+ &tmp_ins_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_ins_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_init_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_init_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_key_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_sel_rnd_child_bitmaps[0], sizeof(uchar *) * share->table_count,
+ &tmp_sel_rnd_child_bitmaps[1], sizeof(uchar *) * share->table_count,
+ &tmp_child_column_bitmap, sizeof(uchar) * child_column_bitmap_size * 8,
+ &tmp_sel_key_init_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_sel_key_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_sel_rnd_use_tables, sizeof(uchar) * share->use_tables_size,
+ &tmp_info, sizeof(void *) * share->table_count,
+ NullS))
+ ) {
+ goto error_bulk_malloc;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ }
+#endif
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_table_share = part_tables[roop_count].table->s;
+ tmp_ins_child_bitmaps[0][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_ins_child_bitmaps[1][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_key_init_child_bitmaps[0][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_key_init_child_bitmaps[1][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_key_child_bitmaps[0][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_key_child_bitmaps[1][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_rnd_child_bitmaps[0][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ tmp_sel_rnd_child_bitmaps[1][roop_count] = tmp_child_column_bitmap;
+ tmp_child_column_bitmap += part_table_share->column_bitmap_size;
+ }
+ bulk_access_info->idx_init_read_bitmap = tmp_idx_init_read_bitmap;
+ bulk_access_info->idx_init_write_bitmap = tmp_idx_init_write_bitmap;
+ bulk_access_info->rnd_init_read_bitmap = tmp_rnd_init_read_bitmap;
+ bulk_access_info->rnd_init_write_bitmap = tmp_rnd_init_write_bitmap;
+ bulk_access_info->idx_read_bitmap = tmp_idx_read_bitmap;
+ bulk_access_info->idx_write_bitmap = tmp_idx_write_bitmap;
+ bulk_access_info->rnd_read_bitmap = tmp_rnd_read_bitmap;
+ bulk_access_info->rnd_write_bitmap = tmp_rnd_write_bitmap;
+ bulk_access_info->ins_child_bitmaps[0] = tmp_ins_child_bitmaps[0];
+ bulk_access_info->ins_child_bitmaps[1] = tmp_ins_child_bitmaps[1];
+ bulk_access_info->sel_key_init_child_bitmaps[0] =
+ tmp_sel_key_init_child_bitmaps[0];
+ bulk_access_info->sel_key_init_child_bitmaps[1] =
+ tmp_sel_key_init_child_bitmaps[1];
+ bulk_access_info->sel_key_child_bitmaps[0] = tmp_sel_key_child_bitmaps[0];
+ bulk_access_info->sel_key_child_bitmaps[1] = tmp_sel_key_child_bitmaps[1];
+ bulk_access_info->sel_rnd_child_bitmaps[0] = tmp_sel_rnd_child_bitmaps[0];
+ bulk_access_info->sel_rnd_child_bitmaps[1] = tmp_sel_rnd_child_bitmaps[1];
+ bulk_access_info->sel_key_init_use_tables = tmp_sel_key_init_use_tables;
+ bulk_access_info->sel_key_use_tables = tmp_sel_key_use_tables;
+ bulk_access_info->sel_rnd_use_tables = tmp_sel_rnd_use_tables;
+ bulk_access_info->info = tmp_info;
+ bulk_access_info->next = NULL;
+ bulk_access_info->idx_bitmap_init_flg = FALSE;
+ bulk_access_info->rnd_bitmap_init_flg = FALSE;
+ bulk_access_info->idx_bitmap_is_set = FALSE;
+ bulk_access_info->rnd_bitmap_is_set = FALSE;
+ bulk_access_info->child_keyread = FALSE;
+ bulk_access_info->single_table = FALSE;
+ bulk_access_info->set_used_table = FALSE;
+ bulk_access_info->init_sel_key_init_bitmap = FALSE;
+ bulk_access_info->init_sel_key_bitmap = FALSE;
+ bulk_access_info->init_sel_rnd_bitmap = FALSE;
+ bulk_access_info->init_ins_bitmap = FALSE;
+ bulk_access_info->used = FALSE;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (partition_handler_share && partition_handler_share->creator == this)
+ {
+ tmp_partition_handler_share->idx_init_read_bitmap =
+ tmp_idx_init_read_bitmap2;
+ tmp_partition_handler_share->idx_init_write_bitmap =
+ tmp_idx_init_write_bitmap2;
+ tmp_partition_handler_share->rnd_init_read_bitmap =
+ tmp_rnd_init_read_bitmap2;
+ tmp_partition_handler_share->rnd_init_write_bitmap =
+ tmp_rnd_init_write_bitmap2;
+ tmp_partition_handler_share->idx_read_bitmap =
+ tmp_idx_read_bitmap2;
+ tmp_partition_handler_share->idx_write_bitmap =
+ tmp_idx_write_bitmap2;
+ tmp_partition_handler_share->rnd_read_bitmap =
+ tmp_rnd_read_bitmap2;
+ tmp_partition_handler_share->rnd_write_bitmap =
+ tmp_rnd_write_bitmap2;
+ tmp_partition_handler_share->idx_init_flg = FALSE;
+ tmp_partition_handler_share->rnd_init_flg = FALSE;
+ tmp_partition_handler_share->idx_bitmap_is_set = FALSE;
+ tmp_partition_handler_share->rnd_bitmap_is_set = FALSE;
+ tmp_clone_partition_handler_share->idx_read_bitmap =
+ tmp_idx_read_bitmap3;
+ tmp_clone_partition_handler_share->idx_write_bitmap =
+ tmp_idx_write_bitmap3;
+ tmp_clone_partition_handler_share->idx_bitmap_is_set = FALSE;
+ bulk_access_info->partition_handler_share =
+ tmp_partition_handler_share;
+ bulk_access_info->clone_partition_handler_share =
+ tmp_clone_partition_handler_share;
+ tmp_partition_handler_share->clone_partition_handler_share =
+ tmp_clone_partition_handler_share;
+ partition_handler_share->current_bulk_access_info = bulk_access_info;
+ } else if (partition_handler_share)
+ {
+ VP_BULK_ACCESS_INFO *bulk_access_info2 =
+ partition_handler_share->current_bulk_access_info;
+ bulk_access_info->partition_handler_share =
+ bulk_access_info2->partition_handler_share;
+ bulk_access_info->clone_partition_handler_share =
+ bulk_access_info2->clone_partition_handler_share;
+ } else {
+ bulk_access_info->partition_handler_share = NULL;
+ bulk_access_info->clone_partition_handler_share = NULL;
+ }
+#endif
+ DBUG_RETURN(bulk_access_info);
+
+error_bulk_malloc:
+ DBUG_RETURN(NULL);
+}
+
+void ha_vp::delete_bulk_access_info(
+ VP_BULK_ACCESS_INFO *bulk_access_info
+) {
+ DBUG_ENTER("ha_vp::delete_bulk_access_info");
+ DBUG_PRINT("info",("vp this=%p", this));
+ vp_my_free(bulk_access_info, MYF(0));
+ DBUG_VOID_RETURN;
+}
+#endif
+
+void ha_vp::overwrite_index_bits()
+{
+ uint roop_count, roop_count2;
+ DBUG_ENTER("ha_vp::overwrite_index_bits");
+ DBUG_PRINT("info",("vp this=%p", this));
+ table_share->keys_for_keyread.clear_all();
+ for (roop_count = 0; roop_count < table_share->fields; roop_count++)
+ {
+ Field *field = table_share->field[roop_count];
+ field->part_of_key.clear_all();
+ field->part_of_key_not_clustered.clear_all();
+ field->part_of_sortkey.clear_all();
+ }
+ for (roop_count = 0; roop_count < table_share->keys; roop_count++)
+ {
+ KEY *key_info = &table->s->key_info[roop_count];
+ KEY_PART_INFO *key_part = key_info->key_part;
+ VP_CORRESPOND_KEY *correspond_key = share->keys[roop_count].correspond_key;
+ for (roop_count2 = 0 ; roop_count2 < vp_user_defined_key_parts(key_info);
+ key_part++, roop_count2++)
+ {
+ Field *field = key_part->field;
+ VP_CORRESPOND_KEY *tmp_ck;
+ if (field->key_length() == key_part->length &&
+ !(field->flags & BLOB_FLAG))
+ {
+ for (tmp_ck = correspond_key; tmp_ck; tmp_ck = tmp_ck->next)
+ {
+ if (!(part_tables[tmp_ck->table_idx].table->file->index_flags(
+ tmp_ck->key_idx, roop_count2, 0) & HA_KEYREAD_ONLY))
+ break;
+ }
+ if (!tmp_ck)
+ {
+ table_share->keys_for_keyread.set_bit(roop_count);
+ field->part_of_key.set_bit(roop_count);
+ field->part_of_key_not_clustered.set_bit(roop_count);
+ }
+ for (tmp_ck = correspond_key; tmp_ck; tmp_ck = tmp_ck->next)
+ {
+ if (!(part_tables[tmp_ck->table_idx].table->file->index_flags(
+ tmp_ck->key_idx, roop_count2, 1) & HA_READ_ORDER))
+ break;
+ }
+ if (!tmp_ck)
+ field->part_of_sortkey.set_bit(roop_count);
+ }
+ if (roop_count == table_share->primary_key)
+ {
+ for (tmp_ck = correspond_key; tmp_ck; tmp_ck = tmp_ck->next)
+ {
+ if (
+ (uint) tmp_ck->key_idx !=
+ part_tables[tmp_ck->table_idx].table->s->primary_key ||
+ !(part_tables[tmp_ck->table_idx].table->file->ha_table_flags() &
+ HA_PRIMARY_KEY_IN_READ_INDEX)
+ )
+ break;
+ }
+ if (!tmp_ck)
+ {
+ if (field->key_length() == key_part->length &&
+ !(field->flags & BLOB_FLAG))
+ field->part_of_key = table_share->keys_in_use;
+ if (field->part_of_sortkey.is_set(roop_count))
+ field->part_of_sortkey = table_share->keys_in_use;
+ }
+ }
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+void ha_vp::check_and_set_bitmap_for_update(
+ bool rnd
+) {
+ DBUG_ENTER("ha_vp::check_and_set_bitmap_for_update");
+ DBUG_PRINT("info",("vp this=%p", this));
+ uchar *w_bitmap = (uchar *) table->write_set->bitmap;
+ memset(upd_target_tables, 0, sizeof(uchar) * share->use_tables_size);
+ for (int roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ int *correspond_columns_p =
+ &share->correspond_columns_p[roop_count * table_share->fields];
+ int *correspond_columns_c =
+ share->correspond_columns_c_ptr[roop_count];
+ for (uint roop_count2 = 0; roop_count2 < table_share->fields;
+ roop_count2++)
+ {
+ DBUG_PRINT("info",("vp field num=%u", roop_count2));
+ if (vp_bit_is_set(w_bitmap, roop_count2))
+ {
+ DBUG_PRINT("info",("vp correspond_columns_p=%d",
+ correspond_columns_p[roop_count2]));
+ if (correspond_columns_p[roop_count2] < MAX_FIELDS)
+ {
+ TABLE *child_table = part_tables[roop_count].table;
+ vp_set_bit(upd_target_tables, roop_count);
+ clear_child_bitmap(roop_count);
+ uchar *cw_bitmap = (uchar *) child_table->write_set->bitmap;
+ uchar *cr_bitmap = (uchar *) child_table->read_set->bitmap;
+ uchar *add_child_bitmap = add_from_child_bitmaps[0][roop_count];
+ vp_set_bit(cw_bitmap, correspond_columns_p[roop_count2]);
+ for (roop_count2++; roop_count2 < table_share->fields;
+ roop_count2++)
+ {
+ DBUG_PRINT("info",("vp field num=%u", roop_count2));
+ DBUG_PRINT("info",("vp correspond_columns_p=%d",
+ correspond_columns_p[roop_count2]));
+ if (
+ vp_bit_is_set(w_bitmap, roop_count2) &&
+ correspond_columns_p[roop_count2] < MAX_FIELDS
+ ) {
+ vp_set_bit(cw_bitmap, correspond_columns_p[roop_count2]);
+ }
+ }
+ child_table->file->check_and_set_bitmap_for_update(rnd);
+ uint child_col_num = 0;
+ DBUG_PRINT("info",("vp child fields=%u", child_table->s->fields));
+ DBUG_PRINT("info",("vp child column_bitmap_size=%u",
+ child_table->s->column_bitmap_size));
+ for (uint roop_count3 = 0;
+ roop_count3 < child_table->s->column_bitmap_size;
+ roop_count3++)
+ {
+ if (cr_bitmap[roop_count3])
+ {
+ for (uint roop_count4 = 0; roop_count4 < 8; roop_count4++)
+ {
+ DBUG_PRINT("info",("vp child column=%u", child_col_num));
+ if (vp_bit_is_set(&cr_bitmap[roop_count3], roop_count4))
+ {
+ uint correspond_column =
+ correspond_columns_c[child_col_num];
+ DBUG_PRINT("info",("vp add bitmap=%u",
+ correspond_column));
+ if (correspond_column < MAX_FIELDS)
+ {
+ vp_set_bit(((uchar *) table->read_set->bitmap),
+ correspond_column);
+ }
+ }
+ child_col_num++;
+ if (child_col_num >= child_table->s->fields)
+ break;
+ }
+ }
+ add_child_bitmap[roop_count3] = cr_bitmap[roop_count3];
+ if (child_col_num >= child_table->s->fields)
+ break;
+ }
+ break;
+ }
+ }
+ }
+ }
+#ifndef DBUG_OFF
+ for (int roop_count = 0; roop_count < share->bitmap_size; roop_count++)
+ DBUG_PRINT("info",("vp source bitmap is %d-%u", roop_count,
+ ((uchar *) table->read_set->bitmap)[roop_count]));
+#endif
+ DBUG_VOID_RETURN;
+}
+#endif
+
+#ifdef HA_CAN_BULK_ACCESS
+void ha_vp::bulk_req_exec()
+{
+ int roop_count;
+ DBUG_ENTER("ha_vp::bulk_req_exec");
+ DBUG_PRINT("info",("vp this=%p", this));
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(bulk_access_exec_bitmap, roop_count))
+ {
+ part_tables[roop_count].table->file->bulk_req_exec();
+ }
+ }
+ memset(bulk_access_exec_bitmap, 0, sizeof(uchar) * share->use_tables_size);
+ DBUG_VOID_RETURN;
+}
+#endif
+
+TABLE_LIST *ha_vp::get_parent_table_list()
+{
+ TABLE_LIST *table_list = table->pos_in_table_list;
+ DBUG_ENTER("ha_vp::get_parent_table_list");
+ if (table_list)
+ {
+ while (table_list->parent_l)
+ table_list = table_list->parent_l;
+ DBUG_RETURN(table_list);
+ }
+ DBUG_RETURN(NULL);
+}
+
+st_select_lex *ha_vp::get_select_lex()
+{
+ TABLE_LIST *table_list = get_parent_table_list();
+ DBUG_ENTER("ha_vp::get_select_lex");
+ if (table_list)
+ {
+ DBUG_PRINT("info",("vp select_lex=%p", table_list->select_lex));
+ DBUG_RETURN(table_list->select_lex);
+ }
+ DBUG_RETURN(NULL);
+}
+
+JOIN *ha_vp::get_join()
+{
+ st_select_lex *select_lex = get_select_lex();
+ DBUG_ENTER("ha_vp::get_join");
+ if (select_lex)
+ {
+ DBUG_PRINT("info",("vp join=%p", select_lex->join));
+ DBUG_RETURN(select_lex->join);
+ }
+ DBUG_RETURN(NULL);
+}
+
+#ifdef VP_HAS_EXPLAIN_QUERY
+Explain_select *ha_vp::get_explain_select()
+{
+ DBUG_ENTER("ha_vp::get_explain_select");
+ Explain_query *explain = current_thd->lex->explain;
+ if (explain)
+ {
+ st_select_lex *select_lex = get_select_lex();
+ if (select_lex)
+ {
+ DBUG_PRINT("info",("vp select_lex=%p", select_lex));
+ DBUG_PRINT("info",("vp select_number=%u",
+ select_lex->select_number));
+ Explain_select *explain_select =
+ explain->get_select(select_lex->select_number);
+ DBUG_PRINT("info",("vp explain_select=%p", explain_select));
+ DBUG_RETURN(explain_select);
+ }
+ }
+ DBUG_RETURN(NULL);
+}
+
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+Explain_update *ha_vp::get_explain_upd_del()
+{
+ DBUG_ENTER("ha_vp::get_explain_upd_del");
+ Explain_query *explain = current_thd->lex->explain;
+ if (explain)
+ {
+ Explain_update *explain_update = explain->get_upd_del();
+ DBUG_PRINT("info",("vp explain_update=%p", explain_update));
+ DBUG_RETURN(explain_update);
+ }
+ DBUG_RETURN(NULL);
+}
+#endif
+#endif
diff --git a/storage/vp/ha_vp.h b/storage/vp/ha_vp.h
new file mode 100644
index 00000000000..b26f528c746
--- /dev/null
+++ b/storage/vp/ha_vp.h
@@ -0,0 +1,1160 @@
+/* Copyright (C) 2009-201 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifdef USE_PRAGMA_INTERFACE
+#pragma interface
+#endif
+
+#define VP_TABLE_INFO_MAX_LEN 64
+#define VP_MAX_KEY_LENGTH 16384
+
+class ha_vp;
+struct st_vp_ft_info
+{
+ struct _ft_vft *please;
+ st_vp_ft_info *next;
+ ha_vp *file;
+ bool used_in_where;
+ VP_CORRESPOND_KEY *target;
+ FT_INFO *ft_handler;
+ uint flags;
+ uint inx;
+ String *key;
+};
+
+typedef struct st_vp_condition
+{
+ COND *cond;
+ st_vp_condition *next;
+} VP_CONDITION;
+
+#ifdef HA_CAN_BULK_ACCESS
+typedef struct st_vp_bulk_access_info
+{
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_HANDLER_SHARE *partition_handler_share;
+ VP_CLONE_PARTITION_HANDLER_SHARE *clone_partition_handler_share;
+#endif
+ my_bitmap_map *idx_init_read_bitmap;
+ my_bitmap_map *idx_init_write_bitmap;
+ my_bitmap_map *rnd_init_read_bitmap;
+ my_bitmap_map *rnd_init_write_bitmap;
+ my_bitmap_map *idx_read_bitmap;
+ my_bitmap_map *idx_write_bitmap;
+ my_bitmap_map *rnd_read_bitmap;
+ my_bitmap_map *rnd_write_bitmap;
+ bool idx_bitmap_init_flg;
+ bool rnd_bitmap_init_flg;
+ bool idx_bitmap_is_set;
+ bool rnd_bitmap_is_set;
+ bool child_keyread;
+ bool single_table;
+ bool set_used_table;
+ bool init_sel_key_init_bitmap;
+ bool init_sel_key_bitmap;
+ bool init_sel_rnd_bitmap;
+ bool init_ins_bitmap;
+ uchar **sel_key_init_child_bitmaps[2];
+ uchar **sel_key_child_bitmaps[2];
+ uchar **sel_rnd_child_bitmaps[2];
+ uchar **ins_child_bitmaps[2];
+ uchar *sel_key_init_use_tables;
+ uchar *sel_key_use_tables;
+ uchar *sel_rnd_use_tables;
+ int child_table_idx;
+ int child_key_idx;
+
+ uint sequence_num;
+ bool used;
+ bool called;
+ void **info;
+ st_vp_bulk_access_info *next;
+} VP_BULK_ACCESS_INFO;
+#endif
+
+class ha_vp: public handler
+{
+public:
+ enum child_bitmap_state {
+ CB_NO_SET, CB_SEL_KEY_INIT, CB_SEL_KEY, CB_SEL_RND,
+ CB_INSERT, CB_UPDATE, CB_DELETE
+ };
+
+ THR_LOCK_DATA lock;
+ VP_SHARE *share;
+ String *blob_buff;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_HANDLER_SHARE *partition_handler_share;
+ ha_vp *pt_handler_share_creator;
+ VP_CLONE_PARTITION_HANDLER_SHARE *clone_partition_handler_share;
+#endif
+ bool is_clone;
+ ha_vp *pt_clone_source_handler;
+ int bitmap_map_size;
+ my_bitmap_map *idx_init_read_bitmap;
+ my_bitmap_map *idx_init_write_bitmap;
+ my_bitmap_map *rnd_init_read_bitmap;
+ my_bitmap_map *rnd_init_write_bitmap;
+ my_bitmap_map *idx_read_bitmap;
+ my_bitmap_map *idx_write_bitmap;
+ my_bitmap_map *rnd_read_bitmap;
+ my_bitmap_map *rnd_write_bitmap;
+ bool idx_bitmap_init_flg;
+ bool rnd_bitmap_init_flg;
+ bool idx_bitmap_is_set;
+ bool rnd_bitmap_is_set;
+
+ uint sql_command;
+ int lock_mode;
+ enum thr_lock_type lock_type_sto;
+ int lock_type_ext;
+ bool rnd_scan;
+ VP_CONDITION *condition;
+ int store_error_num;
+ bool ft_inited;
+ bool ft_init_without_index_init;
+ bool ft_correspond_flag;
+ uint ft_init_idx;
+ uint ft_count;
+ st_vp_ft_info *ft_first;
+ st_vp_ft_info *ft_current;
+ bool use_pre_call;
+
+ TABLE_LIST *part_tables;
+ uint table_lock_count;
+#if MYSQL_VERSION_ID < 50500
+#else
+ TABLE_LIST *children_l;
+ TABLE_LIST **children_last_l;
+ VP_CHILD_INFO *children_info;
+ bool children_attached;
+ bool init_correspond_columns;
+#endif
+ uchar *use_tables;
+ uchar *use_tables2;
+ uchar *use_tables3;
+ uchar *select_ignore;
+ uchar *select_ignore_with_lock;
+ uchar *update_ignore;
+ uchar *pruned_tables;
+ uchar *upd_target_tables;
+ uchar *work_bitmap;
+ uchar *work_bitmap2;
+ uchar *work_bitmap3;
+ uchar *work_bitmap4;
+ bool child_keyread;
+ bool extra_use_cmp_ref;
+ bool single_table;
+ bool update_request;
+ bool set_used_table;
+ bool bulk_insert;
+ bool init_sel_key_init_bitmap;
+ bool init_sel_key_bitmap;
+ bool init_sel_rnd_bitmap;
+ bool init_ins_bitmap;
+ bool init_upd_bitmap;
+ bool init_del_bitmap;
+ bool rnd_init_and_first;
+ bool pruned;
+ bool suppress_autoinc;
+ uint child_column_bitmap_size;
+ uchar **sel_key_init_child_bitmaps[2];
+ uchar **sel_key_child_bitmaps[2];
+ uchar **sel_rnd_child_bitmaps[2];
+ uchar **ins_child_bitmaps[2];
+ uchar **upd_child_bitmaps[2];
+ uchar **del_child_bitmaps[2];
+ uchar **add_from_child_bitmaps[2];
+ uchar **child_record0;
+ uchar **child_record1;
+ uchar *sel_key_init_use_tables;
+ uchar *sel_key_use_tables;
+ uchar *sel_rnd_use_tables;
+ uchar *key_inited_tables;
+ uchar *rnd_inited_tables;
+ uchar *ft_inited_tables;
+ child_bitmap_state cb_state;
+ int child_table_idx;
+ int child_key_idx;
+ uchar *child_key;
+ uint child_key_length;
+ uchar child_key_different[MAX_KEY_LENGTH];
+ uchar child_end_key_different[MAX_KEY_LENGTH];
+ key_range child_start_key;
+ key_range child_end_key;
+ KEY_MULTI_RANGE *child_found_range;
+ KEY_MULTI_RANGE *child_multi_range_first;
+#if defined(HAVE_HANDLERSOCKET)
+ KEY_MULTI_RANGE *child_multi_range;
+ uchar *child_key_buff;
+#endif
+ int dup_table_idx;
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ Field ***top_table_field_for_childs;
+ uint allocated_top_table_fields;
+ bool top_table_self;
+#endif
+#ifndef WITHOUT_VP_BG_ACCESS
+ VP_BG_BASE *bg_base;
+#endif
+ longlong additional_table_flags;
+ uint *child_cond_count;
+ uint child_ref_length;
+
+ uchar *ref_buf;
+ uint ref_buf_length;
+
+#ifdef HA_CAN_BULK_ACCESS
+ bool bulk_access_started;
+ bool bulk_access_executing;
+ bool bulk_access_pre_called;
+ bool need_bulk_access_finish;
+ VP_BULK_ACCESS_INFO *bulk_access_info_first;
+ VP_BULK_ACCESS_INFO *bulk_access_info_current;
+ VP_BULK_ACCESS_INFO *bulk_access_info_exec_tgt;
+ uchar *bulk_access_exec_bitmap;
+#endif
+
+#ifdef VP_SUPPORT_MRR
+ HANDLER_BUFFER *m_mrr_buffer;
+ uint *m_mrr_buffer_size;
+ uchar *m_mrr_full_buffer;
+ uint m_mrr_full_buffer_size;
+ uint m_mrr_new_full_buffer_size;
+ uint *m_stock_range_seq;
+ range_id_t *m_range_info;
+ uint m_mrr_range_init_flags;
+ uint m_mrr_range_length;
+ VP_KEY_MULTI_RANGE *m_mrr_range_first;
+ VP_KEY_MULTI_RANGE *m_mrr_range_current;
+ uint *m_child_mrr_range_length;
+ VP_CHILD_KEY_MULTI_RANGE **m_child_mrr_range_first;
+ VP_CHILD_KEY_MULTI_RANGE **m_child_mrr_range_current;
+ VP_CHILD_KEY_MULTI_RANGE_HLD *m_child_key_multi_range_hld;
+ range_seq_t m_seq;
+ RANGE_SEQ_IF *m_seq_if;
+ RANGE_SEQ_IF m_child_seq_if;
+#endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ bool handler_close;
+#endif
+
+ bool mr_init;
+ MEM_ROOT mr;
+
+ ha_vp();
+ ha_vp(
+ handlerton *hton,
+ TABLE_SHARE *table_arg
+ );
+ handler *clone(
+ const char *name,
+ MEM_ROOT *mem_root
+ );
+ const char **bas_ext() const;
+ int open(
+ const char* name,
+ int mode,
+ uint test_if_locked
+ );
+ int close();
+ int external_lock(
+ THD *thd,
+ int lock_type
+ );
+ uint lock_count() const;
+#ifdef HA_CAN_BULK_ACCESS
+ int additional_lock(
+ THD *thd,
+ enum thr_lock_type lock_type
+ );
+#endif
+ THR_LOCK_DATA **store_lock(
+ THD *thd,
+ THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type
+ );
+ int reset();
+ int extra(
+ enum ha_extra_function operation
+ );
+ int extra_opt(
+ enum ha_extra_function operation,
+ ulong cachesize
+ );
+ int index_init(
+ uint idx,
+ bool sorted
+ );
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_index_init(
+ uint idx,
+ bool sorted
+ );
+#endif
+ int index_end();
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_index_end();
+#endif
+ int index_read_map(
+ uchar *buf,
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag
+ );
+#ifdef VP_HANDLER_HAS_HA_INDEX_READ_LAST_MAP
+ int index_read_last_map(
+ uchar *buf,
+ const uchar *key,
+ key_part_map keypart_map
+ );
+#endif
+ int index_next(
+ uchar *buf
+ );
+ int index_prev(
+ uchar *buf
+ );
+ int index_first(
+ uchar *buf
+ );
+ int index_last(
+ uchar *buf
+ );
+ int index_next_same(
+ uchar *buf,
+ const uchar *key,
+ uint keylen
+ );
+ int read_range_first(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted
+ );
+ int read_range_next();
+#ifdef VP_SUPPORT_MRR
+ ha_rows multi_range_read_info_const(
+ uint keyno,
+ RANGE_SEQ_IF *seq,
+ void *seq_init_param,
+ uint n_ranges,
+ uint *bufsz,
+ uint *mrr_mode,
+ Cost_estimate *cost
+ );
+ ha_rows multi_range_read_info(
+ uint keyno,
+ uint n_ranges,
+ uint keys,
+ uint key_parts,
+ uint *bufsz,
+ uint *mrr_mode,
+ Cost_estimate *cost
+ );
+ int multi_range_read_init(
+ RANGE_SEQ_IF *seq,
+ void *seq_init_param,
+ uint n_ranges,
+ uint mrr_mode,
+ HANDLER_BUFFER *buf
+ );
+ int pre_multi_range_read_next(
+ bool use_parallel
+ );
+ int multi_range_read_next(
+ range_id_t *range_info
+ );
+ int multi_range_read_explain_info(
+ uint mrr_mode,
+ char *str,
+ size_t size
+ );
+#else
+ int read_multi_range_first(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer
+ );
+ int read_multi_range_next(
+ KEY_MULTI_RANGE **found_range_p
+ );
+#endif
+ int rnd_init(
+ bool scan
+ );
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_rnd_init(
+ bool scan
+ );
+#endif
+ int rnd_end();
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_rnd_end();
+#endif
+ int rnd_next(
+ uchar *buf
+ );
+ void position(
+ const uchar *record
+ );
+ int rnd_pos(
+ uchar *buf,
+ uchar *pos
+ );
+ int cmp_ref(
+ const uchar *ref1,
+ const uchar *ref2
+ );
+ int pre_index_read_map(
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag,
+ bool use_parallel
+ );
+ int pre_index_first(bool use_parallel);
+ int pre_index_last(bool use_parallel);
+#ifdef VP_HANDLER_HAS_HA_INDEX_READ_LAST_MAP
+ int pre_index_read_last_map(
+ const uchar *key,
+ key_part_map keypart_map,
+ bool use_parallel
+ );
+#endif
+#ifdef VP_SUPPORT_MRR
+#else
+ int pre_read_multi_range_first(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer,
+ bool use_parallel
+ );
+#endif
+ int pre_read_range_first(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted,
+ bool use_parallel
+ );
+ int pre_ft_read(bool use_parallel);
+ int pre_rnd_next(bool use_parallel);
+ float ft_find_relevance(
+ FT_INFO *handler,
+ uchar *record,
+ uint length
+ );
+ float ft_get_relevance(
+ FT_INFO *handler
+ );
+ void ft_close_search(
+ FT_INFO *handler
+ );
+ FT_INFO *ft_init_ext(
+ uint flags,
+ uint inx,
+ String *key
+ );
+ int ft_init();
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_ft_init();
+#endif
+ void ft_end();
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_ft_end();
+#endif
+ int ft_read(
+ uchar *buf
+ );
+ int info(
+ uint flag
+ );
+ ha_rows records();
+ ha_rows records_in_range(
+ uint idx,
+ key_range *start_key,
+ key_range *end_key
+ );
+ const char *table_type() const;
+ ulonglong table_flags() const;
+ const char *index_type(
+ uint key_number
+ );
+ ulong index_flags(
+ uint idx,
+ uint part,
+ bool all_parts
+ ) const;
+ uint max_supported_record_length() const;
+ uint max_supported_keys() const;
+ uint max_supported_key_parts() const;
+ uint max_supported_key_length() const;
+ uint max_supported_key_part_length() const;
+ uint8 table_cache_type();
+#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
+ bool need_info_for_auto_inc();
+#endif
+ int update_auto_increment();
+ void set_next_insert_id(
+ ulonglong id
+ );
+ void get_auto_increment(
+ ulonglong offset,
+ ulonglong increment,
+ ulonglong nb_desired_values,
+ ulonglong *first_value,
+ ulonglong *nb_reserved_values
+ );
+ void restore_auto_increment(
+ ulonglong prev_insert_id
+ );
+ void release_auto_increment();
+ int reset_auto_increment(
+ ulonglong value
+ );
+#ifdef VP_HANDLER_START_BULK_INSERT_HAS_FLAGS
+ void start_bulk_insert(
+ ha_rows rows,
+ uint flags
+ );
+#else
+ void start_bulk_insert(
+ ha_rows rows
+ );
+#endif
+ /* call from MySQL */
+ int end_bulk_insert();
+ /* call from MariaDB */
+ int end_bulk_insert(
+ bool abort
+ );
+ int write_row(
+ uchar *buf
+ );
+#ifdef HA_CAN_BULK_ACCESS
+ int pre_write_row(
+ uchar *buf
+ );
+#endif
+ bool start_bulk_update();
+ int exec_bulk_update(
+ ha_rows *dup_key_found
+ );
+#ifdef VP_END_BULK_UPDATE_RETURNS_INT
+ int end_bulk_update();
+#else
+ void end_bulk_update();
+#endif
+#ifdef VP_UPDATE_ROW_HAS_CONST_NEW_DATA
+ int bulk_update_row(
+ const uchar *old_data,
+ const uchar *new_data,
+ ha_rows *dup_key_found
+ );
+ int update_row(
+ 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
+#ifdef VP_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,
+ 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
+#ifdef VP_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
+ int pre_direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+ );
+#else
+ int pre_direct_update_rows_init();
+#endif
+#endif
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ inline int direct_update_rows(ha_rows *update_rows)
+ {
+ return direct_update_rows(NULL, 0, FALSE, NULL, update_rows);
+ }
+ int direct_update_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data,
+ ha_rows *update_rows
+ );
+#else
+ int direct_update_rows(
+ ha_rows *update_rows
+ );
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ int pre_direct_update_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data,
+ uint *update_rows
+ );
+#else
+ int pre_direct_update_rows();
+#endif
+#endif
+#endif
+ bool start_bulk_delete();
+ int end_bulk_delete();
+ int delete_row(
+ const uchar *buf
+ );
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ inline int direct_delete_rows_init()
+ {
+ return direct_delete_rows_init(2, NULL, 0, FALSE);
+ }
+ int direct_delete_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted
+ );
+#else
+ int direct_delete_rows_init();
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ inline int pre_direct_delete_rows_init()
+ {
+ return pre_direct_delete_rows_init(2, NULL, 0, FALSE);
+ }
+ int pre_direct_delete_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted
+ );
+#else
+ int pre_direct_delete_rows_init();
+#endif
+#endif
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ inline int direct_delete_rows(ha_rows *delete_rows)
+ {
+ return direct_delete_rows(NULL, 0, FALSE, delete_rows);
+ }
+ int direct_delete_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ ha_rows *delete_rows
+ );
+#else
+ int direct_delete_rows(
+ ha_rows *delete_rows
+ );
+#endif
+#ifdef HA_CAN_BULK_ACCESS
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+ inline int pre_direct_delete_rows()
+ {
+ ha_rows delete_rows;
+
+ return pre_direct_delete_rows(NULL, 0, FALSE, &delete_rows);
+ }
+ int pre_direct_delete_rows(
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uint *delete_rows
+ );
+#else
+ int pre_direct_delete_rows();
+#endif
+#endif
+#endif
+ int delete_all_rows();
+ int truncate();
+ double scan_time();
+ double read_time(
+ uint index,
+ uint ranges,
+ ha_rows rows
+ );
+#ifdef HA_CAN_BULK_ACCESS
+ void bulk_req_exec();
+#endif
+ const key_map *keys_to_use_for_scanning();
+ ha_rows estimate_rows_upper_bound();
+ bool get_error_message(
+ int error,
+ String *buf
+ );
+ int create(
+ const char *name,
+ TABLE *form,
+ HA_CREATE_INFO *info
+ );
+ void update_create_info(
+ HA_CREATE_INFO* create_info
+ );
+ int rename_table(
+ const char *from,
+ const char *to
+ );
+ int delete_table(
+ const char *name
+ );
+ bool is_crashed() const;
+#ifdef VP_HANDLER_AUTO_REPAIR_HAS_ERROR
+ bool auto_repair(int error) const;
+#else
+ bool auto_repair() const;
+#endif
+ int disable_indexes(
+ uint mode
+ );
+ int enable_indexes(
+ uint mode
+ );
+ int check(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+ );
+ int repair(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+ );
+ bool check_and_repair(
+ THD *thd
+ );
+ int analyze(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+ );
+ int optimize(
+ THD* thd,
+ HA_CHECK_OPT* check_opt
+ );
+#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
+ int set_top_table_and_fields(
+ TABLE *top_table,
+ Field **top_table_field,
+ uint top_table_fields,
+ bool self
+ );
+ int set_top_table_and_fields(
+ TABLE *top_table,
+ Field **top_table_field,
+ uint top_table_fields
+ );
+#ifdef HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
+ bool prune_partitions_for_child(
+ THD *thd,
+ Item *pprune_cond
+ );
+#endif
+#ifdef HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+ TABLE_LIST *get_next_global_for_child();
+#endif
+ const COND *cond_push(
+ const COND *cond
+ );
+ void cond_pop();
+#endif
+ int info_push(
+ uint info_type,
+ void *info
+ );
+#ifdef HANDLER_HAS_DIRECT_AGGREGATE
+ void return_record_by_parent();
+#endif
+ int start_stmt(
+ THD *thd,
+ thr_lock_type lock_type
+ );
+ bool is_fatal_error(
+ int error_num,
+ uint flags
+ );
+ bool check_if_incompatible_data(
+ HA_CREATE_INFO *create_info,
+ uint table_changes
+ );
+ bool primary_key_is_clustered();
+ bool can_switch_engines();
+ VP_alter_table_operations alter_table_flags(
+ VP_alter_table_operations flags
+ );
+#ifdef VP_HANDLER_HAS_ADD_INDEX
+#if MYSQL_VERSION_ID < 50500 || MYSQL_VERSION_ID >= 50600
+ int add_index(
+ TABLE *table_arg,
+ KEY *key_info,
+ uint num_of_keys
+ );
+#else
+ int add_index(
+ TABLE *table_arg,
+ KEY *key_info,
+ uint num_of_keys,
+ handler_add_index **add
+ );
+ int final_add_index(
+ handler_add_index *add,
+ bool commit
+ );
+#endif
+#endif
+#ifdef VP_HANDLER_HAS_DROP_INDEX
+ int prepare_drop_index(
+ TABLE *table_arg,
+ uint *key_num,
+ uint num_of_keys
+ );
+ int final_drop_index(
+ TABLE *table_arg
+ );
+#endif
+/*
+ int check_for_upgrade(
+ HA_CHECK_OPT *check_opt
+ );
+*/
+ bool was_semi_consistent_read();
+ void try_semi_consistent_read(
+ bool yes
+ );
+ void unlock_row();
+ void init_table_handle_for_HANDLER();
+ void change_table_ptr(
+ TABLE *table_arg,
+ TABLE_SHARE *share_arg
+ );
+#if MYSQL_VERSION_ID < 50600
+ char *get_tablespace_name(
+ THD *thd,
+ char *name,
+ uint name_len
+ );
+#endif
+ bool is_fk_defined_on_table_or_index(
+ uint index
+ );
+ char *get_foreign_key_create_info();
+ int get_foreign_key_list(
+ THD *thd,
+ List<FOREIGN_KEY_INFO> *f_key_list
+ );
+#if MYSQL_VERSION_ID < 50500
+#else
+ int get_parent_foreign_key_list(
+ THD *thd,
+ List<FOREIGN_KEY_INFO> *f_key_list
+ );
+#endif
+ uint referenced_by_foreign_key();
+ void free_foreign_key_create_info(
+ char* str
+ );
+#ifdef VP_HANDLER_HAS_COUNT_QUERY_CACHE_DEPENDANT_TABLES
+#ifdef VP_REGISTER_QUERY_CACHE_TABLE_HAS_CONST_TABLE_KEY
+ my_bool register_query_cache_table(
+ THD *thd,
+ const char *table_key,
+ uint key_length,
+ qc_engine_callback *engine_callback,
+ ulonglong *engine_data
+ );
+#else
+ my_bool register_query_cache_table(
+ THD *thd,
+ char *table_key,
+ uint key_length,
+ qc_engine_callback *engine_callback,
+ ulonglong *engine_data
+ );
+#endif
+ uint count_query_cache_dependant_tables(
+ uint8 *tables_type
+ );
+ my_bool register_query_cache_dependant_tables(
+ THD *thd,
+ Query_cache *cache,
+ Query_cache_block_table **block,
+ uint *n
+ );
+#else
+#ifdef HTON_CAN_MERGE
+ int qcache_insert(
+ Query_cache *qcache,
+ Query_cache_block_table *block_table,
+ TABLE_COUNTER_TYPE &n
+ );
+ TABLE_COUNTER_TYPE qcache_table_count();
+#endif
+#endif
+
+private:
+ int choose_child_index(
+ uint idx,
+ uchar *read_set,
+ uchar *write_set,
+ int *table_idx,
+ int *key_idx
+ );
+ int choose_child_ft_tables(
+ uchar *read_set,
+ uchar *write_set
+ );
+ int choose_child_tables(
+ uchar *read_set,
+ uchar *write_set
+ );
+ void clear_child_bitmap(
+ int table_idx
+ );
+ uchar *create_child_key(
+ const uchar *key_same,
+ uchar *key_different,
+ key_part_map keypart_map,
+ uint key_length_same,
+ uint *key_length
+ );
+ int get_child_record_by_idx(
+ int table_idx,
+ my_ptrdiff_t ptr_diff
+ );
+ int get_child_record_by_pk(
+ my_ptrdiff_t ptr_diff
+ );
+ bool set_child_bitmap(
+ uchar *bitmap,
+ int table_idx,
+ bool write_flg
+ );
+ bool add_pk_bitmap_to_child();
+ void set_child_pt_bitmap();
+ void set_child_record_for_update(
+ my_ptrdiff_t ptr_diff,
+ int record_idx,
+ bool write_flg,
+ bool use_table_chk
+ );
+ void set_child_record_for_insert(
+ my_ptrdiff_t ptr_diff,
+ int table_idx
+ );
+ int search_by_pk(
+ int table_idx,
+ int record_idx,
+ VP_KEY_COPY *key_copy,
+ my_ptrdiff_t ptr_diff,
+ uchar **table_key
+ );
+ int search_by_pk_for_update(
+ int table_idx,
+ int record_idx,
+ VP_KEY_COPY *vp_key_copy,
+ my_ptrdiff_t ptr_diff,
+ int bgu_mode
+ );
+ int create_child_bitmap_buff();
+ void free_child_bitmap_buff();
+ bool get_added_bitmap(
+ uchar *added_bitmap,
+ const uchar *current_bitmap,
+ const uchar *pre_bitmap
+ );
+ void add_child_bitmap(
+ int table_idx,
+ uchar *bitmap
+ );
+ void prune_child_bitmap(
+ int table_idx
+ );
+ void prune_child();
+ int set_rnd_bitmap();
+ void reset_rnd_bitmap();
+ int set_rnd_bitmap_from_another(
+ ha_vp *another_vp
+ );
+ int open_item_type(
+ Item *item,
+ int table_idx
+ );
+ int open_item_cond(
+ Item_cond *item_cond,
+ int table_idx
+ );
+ int open_item_func(
+ Item_func *item_func,
+ int table_idx
+ );
+ int open_item_ident(
+ Item_ident *item_ident,
+ int table_idx
+ );
+ int open_item_field(
+ Item_field *item_field,
+ int table_idx
+ );
+ int open_item_ref(
+ Item_ref *item_ref,
+ int table_idx
+ );
+ int open_item_row(
+ Item_row *item_row,
+ int table_idx
+ );
+ int count_condition(
+ int table_idx
+ );
+ int create_bg_thread(
+ VP_BG_BASE *base
+ );
+ void free_bg_thread(
+ VP_BG_BASE *base
+ );
+ void bg_kick(
+ VP_BG_BASE *base
+ );
+ void bg_wait(
+ VP_BG_BASE *base
+ );
+ void init_select_column(
+ bool rnd
+ );
+ void check_select_column(
+ bool rnd
+ );
+ void clone_init_select_column();
+ uint check_partitioned();
+ void index_read_map_init(
+ const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag
+ );
+#ifdef VP_HANDLER_HAS_HA_INDEX_READ_LAST_MAP
+ void index_read_last_map_init(
+ const uchar *key,
+ key_part_map keypart_map
+ );
+#endif
+ void index_first_init();
+ void index_last_init();
+ void read_range_first_init(
+ const key_range *start_key,
+ const key_range *end_key,
+ bool eq_range,
+ bool sorted
+ );
+#ifdef VP_SUPPORT_MRR
+ int multi_range_key_create_key(
+ RANGE_SEQ_IF *seq,
+ range_seq_t seq_it,
+ int target_table_idx
+ );
+ int multi_range_read_next_first(
+ range_id_t *range_info
+ );
+ int multi_range_read_next_next(
+ range_id_t *range_info
+ );
+#else
+ int read_multi_range_first_init(
+ KEY_MULTI_RANGE **found_range_p,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ HANDLER_BUFFER *buffer
+ );
+#endif
+ int rnd_next_init();
+ int ft_read_init();
+#ifdef HA_CAN_BULK_ACCESS
+ VP_BULK_ACCESS_INFO *create_bulk_access_info();
+ void delete_bulk_access_info(
+ VP_BULK_ACCESS_INFO *bulk_access_info
+ );
+#endif
+ TABLE_LIST *get_parent_table_list();
+ st_select_lex *get_select_lex();
+ JOIN *get_join();
+#ifdef VP_HAS_EXPLAIN_QUERY
+ Explain_select *get_explain_select();
+#ifdef EXPLAIN_HAS_GET_UPD_DEL
+ Explain_update *get_explain_upd_del();
+#endif
+#endif
+
+public:
+ void overwrite_index_bits();
+#ifdef HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+ void check_and_set_bitmap_for_update(
+ bool rnd
+ );
+#endif
+};
diff --git a/storage/vp/mysql-test/vp/include/deinit_child2_1.inc b/storage/vp/mysql-test/vp/include/deinit_child2_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child2_1.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_child2_2.inc b/storage/vp/mysql-test/vp/include/deinit_child2_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child2_2.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_child2_3.inc b/storage/vp/mysql-test/vp/include/deinit_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_child3_1.inc b/storage/vp/mysql-test/vp/include/deinit_child3_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child3_1.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_child3_2.inc b/storage/vp/mysql-test/vp/include/deinit_child3_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child3_2.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_child3_3.inc b/storage/vp/mysql-test/vp/include/deinit_child3_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_child3_3.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_master_1.inc b/storage/vp/mysql-test/vp/include/deinit_master_1.inc
new file mode 100644
index 00000000000..817166ed393
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_master_1.inc
@@ -0,0 +1 @@
+--source ../include/deinit_vp.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_slave1_1.inc b/storage/vp/mysql-test/vp/include/deinit_slave1_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_slave1_1.inc
diff --git a/storage/vp/mysql-test/vp/include/deinit_vp.inc b/storage/vp/mysql-test/vp/include/deinit_vp.inc
new file mode 100644
index 00000000000..b8105ae7747
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/deinit_vp.inc
@@ -0,0 +1,2 @@
+DROP FUNCTION vp_copy_tables;
+UNINSTALL PLUGIN vp;
diff --git a/storage/vp/mysql-test/vp/include/init_child2_1.inc b/storage/vp/mysql-test/vp/include/init_child2_1.inc
new file mode 100644
index 00000000000..3e3804b6e48
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child2_1.inc
@@ -0,0 +1,234 @@
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r_2;
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE ta_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES=
+ SELECT a, b FROM ta_r ORDER BY a $STR_SEMICOLON
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES2=
+ DROP TABLE IF EXISTS ta_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r2_2;
+let $CHILD2_1_CREATE_TABLES2=
+ CREATE TABLE ta_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES2=
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, b FROM ta_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES3=
+ DROP TABLE IF EXISTS ta_r_no_idx;
+let $CHILD2_1_CREATE_TABLES3=
+ CREATE TABLE ta_r_no_idx (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES3=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a;
+let $CHILD2_1_DROP_TABLES4=
+ DROP TABLE IF EXISTS ta_r_auto_inc, ta_r_auto_inc_2;
+let $CHILD2_1_CREATE_TABLES4=
+ CREATE TABLE ta_r_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_auto_inc_2 (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES4=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc
+ ORDER BY a $STR_SEMICOLON
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc_2
+ ORDER BY a;
+let $CHILD2_1_DROP_TABLES5=
+ DROP TABLE IF EXISTS ta_r_int, ta_r_int_2;
+let $CHILD2_1_CREATE_TABLES5=
+ CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES5=
+ SELECT a, b, c FROM ta_r_int ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, b, c FROM ta_r_int_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES6=
+ DROP TABLE IF EXISTS ta_r_3;
+let $CHILD2_1_CREATE_TABLES6=
+ CREATE TABLE ta_r_3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a, b, c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES6=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a;
+let $CHILD2_1_DROP_FT_TABLES=
+ DROP TABLE IF EXISTS ft_r, ft_r_2;
+let $CHILD2_1_CREATE_FT_TABLES=
+ CREATE TABLE ft_r (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
+let $CHILD2_1_SELECT_FT_TABLES=
+ SELECT a, b, c FROM ft_r ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r_2 ORDER BY a;
+let $CHILD2_1_DROP_FT_TABLES2=
+ DROP TABLE IF EXISTS ft_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ft_r2_2;
+let $CHILD2_1_CREATE_FT_TABLES2=
+ CREATE TABLE ft_r2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r2_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
+let $CHILD2_1_SELECT_FT_TABLES2=
+ SELECT a, b, c FROM ft_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_GM_TABLES=
+ DROP TABLE IF EXISTS gm_r, gm_r_2;
+let $CHILD2_1_CREATE_GM_TABLES=
+ CREATE TABLE gm_r (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
+let $CHILD2_1_SELECT_GM_TABLES=
+ SELECT a, b FROM gm_r ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c FROM gm_r_2 ORDER BY a;
+let $CHILD2_1_DROP_GM_TABLES2=
+ DROP TABLE IF EXISTS gm_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS gm_r2_2;
+let $CHILD2_1_CREATE_GM_TABLES2=
+ CREATE TABLE gm_r2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r2_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
+let $CHILD2_1_SELECT_GM_TABLES2=
+ SELECT a, b FROM gm_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c FROM gm_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_LOCK_TABLES1=
+ DROP TABLE IF EXISTS t1_1;
+let $CHILD2_1_CREATE_LOCK_TABLES1=
+ CREATE TABLE t1_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_DROP_LOCK_TABLES2=
+ DROP TABLE IF EXISTS t2_2;
+let $CHILD2_1_CREATE_LOCK_TABLES2=
+ CREATE TABLE t2_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_DROP_INCREMENT_TABLES1=
+ DROP TABLE IF EXISTS t1_1;
+let $CHILD2_1_CREATE_INCREMENT_TABLES1=
+ CREATE TABLE t1_1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_INCREMENT_TABLES1=
+ SELECT id FROM t1_1 ORDER BY id;
+let $CHILD2_1_DROP_TEXT_PK_TABLES1=
+ DROP TABLE IF EXISTS t1;
+let $CHILD2_1_CREATE_TEXT_PK_TABLES1=
+ CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY (a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2;
+let $CHILD2_1_SELECT_TEXT_PK_TABLES1=
+ SELECT a FROM t1 ORDER BY a;
+let $CHILD2_1_DROP_TEXT_KEY_TABLES1=
+ DROP TABLE IF EXISTS t1;
+let $CHILD2_1_CREATE_TEXT_KEY_TABLES1=
+ CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TEXT_KEY_TABLES1=
+ SELECT a, b FROM t1 ORDER BY a, b;
+let $CHILD2_1_AUTO_INCREMENT_INCREMENT1=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_1_AUTO_INCREMENT_INCREMENT2=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_1_AUTO_INCREMENT_OFFSET1=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
+let $CHILD2_1_AUTO_INCREMENT_OFFSET2=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
diff --git a/storage/vp/mysql-test/vp/include/init_child2_2.inc b/storage/vp/mysql-test/vp/include/init_child2_2.inc
new file mode 100644
index 00000000000..6f0e7bcfa0f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child2_2.inc
@@ -0,0 +1,105 @@
+let $CHILD2_2_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r3_2;
+let $CHILD2_2_CREATE_TABLES=
+ CREATE TABLE ta_r3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r3_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_SELECT_TABLES=
+ SELECT a, b FROM ta_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_TABLES5=
+ DROP TABLE IF EXISTS ta_r_int, ta_r_int_2;
+let $CHILD2_2_CREATE_TABLES5=
+ CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_FT_TABLES=
+ DROP TABLE IF EXISTS ft_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ft_r3_2;
+let $CHILD2_2_CREATE_FT_TABLES=
+ CREATE TABLE ft_r3 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r3_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET;
+let $CHILD2_2_SELECT_FT_TABLES=
+ SELECT a, b, c FROM ft_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_GM_TABLES=
+ DROP TABLE IF EXISTS gm_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS gm_r3_2;
+let $CHILD2_2_CREATE_GM_TABLES=
+ CREATE TABLE gm_r3 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r3_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET;
+let $CHILD2_2_SELECT_GM_TABLES=
+ SELECT a, b FROM gm_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, c FROM gm_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_LOCK_TABLES1=
+ DROP TABLE IF EXISTS t1_2;
+let $CHILD2_2_CREATE_LOCK_TABLES1=
+ CREATE TABLE t1_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_LOCK_TABLES2=
+ DROP TABLE IF EXISTS t2_1;
+let $CHILD2_2_CREATE_LOCK_TABLES2=
+ CREATE TABLE t2_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_INCREMENT_TABLES1=
+ DROP TABLE IF EXISTS t1_2;
+let $CHILD2_2_CREATE_INCREMENT_TABLES1=
+ CREATE TABLE t1_2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_SELECT_INCREMENT_TABLES1=
+ SELECT id FROM t1_2 ORDER BY id;
+let $CHILD2_2_AUTO_INCREMENT_INCREMENT1=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_2_AUTO_INCREMENT_INCREMENT2=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_2_AUTO_INCREMENT_OFFSET1=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
+let $CHILD2_2_AUTO_INCREMENT_OFFSET2=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
diff --git a/storage/vp/mysql-test/vp/include/init_child2_3.inc b/storage/vp/mysql-test/vp/include/init_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/include/init_child3_1.inc b/storage/vp/mysql-test/vp/include/init_child3_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child3_1.inc
diff --git a/storage/vp/mysql-test/vp/include/init_child3_2.inc b/storage/vp/mysql-test/vp/include/init_child3_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child3_2.inc
diff --git a/storage/vp/mysql-test/vp/include/init_child3_3.inc b/storage/vp/mysql-test/vp/include/init_child3_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_child3_3.inc
diff --git a/storage/vp/mysql-test/vp/include/init_master_1.inc b/storage/vp/mysql-test/vp/include/init_master_1.inc
new file mode 100644
index 00000000000..93c4190518b
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_master_1.inc
@@ -0,0 +1,113 @@
+--source ../include/init_vp.inc
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r ta_r_2"';
+let $MASTER_1_COMMENT2_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_no_idx"';
+#let $MASTER_1_COMMENT_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r2 ta_r2_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ta_r2 ta_r2_2"'
+ PARTITION BY KEY(a) (
+ PARTITION pt1 COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 COMMENT='table_name_list "ta_r3 ta_r3_2"'
+ );
+#let $MASTER_1_COMMENT2_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r2 ta_r2_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT2_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ta_r2 ta_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "ta_r3 ta_r3_2"'
+ );
+let $MASTER_1_COMMENT3_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_auto_inc ta_r_auto_inc_2"';
+#let $MASTER_1_COMMENT3_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r_int ta_r_int_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT3_P_2_1=
+ CONNECTION='table_name_list "ta_r_int ta_r_int_2"'
+ PARTITION BY LIST(MOD(a, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT='default_database "auto_test_remote2"'
+ );
+let $MASTER_1_COMMENT4_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_int ta_r_int_2"';
+let $MASTER_1_COMMENT5_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_3"';
+let $MASTER_1_COMMENT_FT_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ft_r ft_r_2"';
+let $MASTER_1_COMMENT2_FT_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ft_r2 ft_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "ft_r3 ft_r3_2"'
+ );
+let $MASTER_1_COMMENT_GM_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "gm_r gm_r_2"';
+let $MASTER_1_COMMENT2_GM_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "gm_r2 gm_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "gm_r3 gm_r3_2"'
+ );
+let $MASTER_1_COMMENT_LOCK1=
+ COMMENT 'tnl "auto_test_remote.t1_1 auto_test_remote2.t1_2"';
+let $MASTER_1_COMMENT_LOCK2=
+ COMMENT 'tnl "auto_test_remote2.t2_1 auto_test_remote.t2_2"';
+let $MASTER_1_COMMENT_INCREMENT1_1=
+ COMMENT='tnl "t1_1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_INCREMENT1_P_1=
+ PARTITION BY LIST(MOD(id, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='tnl "t1_1", default_database "auto_test_remote"',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT='tnl "t1_2", default_database "auto_test_remote2"'
+ );
+let $MASTER_1_COMMENT_TEXT_PK1_1=
+ COMMENT 'tnl "t1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_TEXT_KEY1_1=
+ COMMENT 'tnl "t1", default_database "auto_test_remote"';
+let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS=
+ SHOW STATUS LIKE 'Vp_direct_update';
+let $MASTER_1_CHECK_DIRECT_DELETE_STATUS=
+ SHOW STATUS LIKE 'Vp_direct_delete';
+let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS=
+ SHOW STATUS LIKE 'Vp_direct_order_limit';
+let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS=
+ SHOW STATUS LIKE 'Vp_direct_aggregate';
+let $MASTER_1_AUTO_INCREMENT_INCREMENT1=
+ SET SESSION AUTO_INCREMENT_INCREMENT = 1;
+let $MASTER_1_AUTO_INCREMENT_INCREMENT2=
+ SET SESSION AUTO_INCREMENT_INCREMENT = 777;
+let $MASTER_1_AUTO_INCREMENT_OFFSET1=
+ SET SESSION AUTO_INCREMENT_OFFSET = 1;
+let $MASTER_1_AUTO_INCREMENT_OFFSET2=
+ SET SESSION AUTO_INCREMENT_OFFSET = 777;
+let $MASTER_1_AUTO_INCREMENT_OFFSET3=
+ SET SESSION AUTO_INCREMENT_OFFSET = 1;
+let $MASTER_1_AUTO_INCREMENT_OFFSET4=
+ SET SESSION AUTO_INCREMENT_OFFSET = 777;
diff --git a/storage/vp/mysql-test/vp/include/init_slave1_1.inc b/storage/vp/mysql-test/vp/include/init_slave1_1.inc
new file mode 100644
index 00000000000..73c3c6b9ef2
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_slave1_1.inc
@@ -0,0 +1,10 @@
+let $SLAVE1_1_COMMENT_INCREMENT1_1=
+ COMMENT '';
+let $SLAVE1_1_COMMENT_INCREMENT1_P_1=
+ COMMENT ''
+ PARTITION BY LIST(MOD(id, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT=''
+ );
diff --git a/storage/vp/mysql-test/vp/include/init_vp.inc b/storage/vp/mysql-test/vp/include/init_vp.inc
new file mode 100644
index 00000000000..4929b7ef657
--- /dev/null
+++ b/storage/vp/mysql-test/vp/include/init_vp.inc
@@ -0,0 +1,17 @@
+let $VERSION_COMPILE_OS_WIN=
+ `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`;
+if ($VERSION_COMPILE_OS_WIN)
+{
+ INSTALL PLUGIN vp SONAME 'ha_vp.dll';
+ CREATE FUNCTION vp_copy_tables RETURNS INT SONAME 'ha_vp.dll';
+}
+if (!$VERSION_COMPILE_OS_WIN)
+{
+ INSTALL PLUGIN vp SONAME 'ha_vp.so';
+ CREATE FUNCTION vp_copy_tables RETURNS INT SONAME 'ha_vp.so';
+}
+
+let $PLUGIN_VERSION=
+ `SELECT SUBSTRING_INDEX(plugin_version, '.', 1)
+ FROM information_schema.plugins
+ WHERE plugin_name = 'VP'`;
diff --git a/storage/vp/mysql-test/vp/my.cnf b/storage/vp/mysql-test/vp/my.cnf
new file mode 100644
index 00000000000..030b1411e24
--- /dev/null
+++ b/storage/vp/mysql-test/vp/my.cnf
@@ -0,0 +1,86 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld.1.1]
+
+[mysqld.4.1]
+
+
+[ENV]
+USE_GEOMETRY_TEST= 1
+USE_FULLTEXT_TEST= 1
+USE_HA_TEST= 0
+USE_GENERAL_LOG= 1
+USE_REPLICATION= 1
+MASTER_1_MYPORT= @mysqld.1.1.port
+MASTER_1_MYSOCK= @mysqld.1.1.socket
+MASTER_1_ENGINE_TYPE= VP
+MASTER_1_ENGINE= ENGINE=VP
+MASTER_1_CHARSET= DEFAULT CHARSET=utf8
+MASTER_1_MERGE= 1
+MASTER_1_NEEDPK= 1
+MASTER_1_ENGINE2= ENGINE=MyISAM
+MASTER_1_CHARSET2= DEFAULT CHARSET=utf8
+MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+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
+USE_CHILD_GROUP2= 1
+OUTPUT_CHILD_GROUP2= 0
+CHILD2_1_MYPORT= @mysqld.1.1.port
+CHILD2_1_MYSOCK= @mysqld.1.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_2_MYPORT= @mysqld.1.1.port
+CHILD2_2_MYSOCK= @mysqld.1.1.socket
+CHILD2_2_ENGINE_TYPE= InnoDB
+CHILD2_2_ENGINE= ENGINE=InnoDB
+CHILD2_2_CHARSET= DEFAULT CHARSET=utf8
+CHILD2_3_MYPORT= @mysqld.1.1.port
+CHILD2_3_MYSOCK= @mysqld.1.1.socket
+CHILD2_3_ENGINE_TYPE= InnoDB
+CHILD2_3_ENGINE= ENGINE=InnoDB
+CHILD2_3_CHARSET= DEFAULT CHARSET=utf8
+CHILD2_1_FT_MYPORT= @mysqld.1.1.port
+CHILD2_1_FT_MYSOCK= @mysqld.1.1.socket
+CHILD2_1_FT_ENGINE_TYPE= MyISAM
+CHILD2_1_FT_ENGINE= ENGINE=MyISAM
+CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8
+CHILD2_2_FT_MYPORT= @mysqld.1.1.port
+CHILD2_2_FT_MYSOCK= @mysqld.1.1.socket
+CHILD2_2_FT_ENGINE_TYPE= MyISAM
+CHILD2_2_FT_ENGINE= ENGINE=MyISAM
+CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8
+CHILD2_1_GM_MYPORT= @mysqld.1.1.port
+CHILD2_1_GM_MYSOCK= @mysqld.1.1.socket
+CHILD2_1_GM_ENGINE_TYPE= MyISAM
+CHILD2_1_GM_ENGINE= ENGINE=MyISAM
+CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8
+CHILD2_2_GM_MYPORT= @mysqld.1.1.port
+CHILD2_2_GM_MYSOCK= @mysqld.1.1.socket
+CHILD2_2_GM_ENGINE_TYPE= MyISAM
+CHILD2_2_GM_ENGINE= ENGINE=MyISAM
+CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8
+USE_CHILD_GROUP3= 0
+OUTPUT_CHILD_GROUP3= 0
+CHILD3_1_MYPORT= @mysqld.1.1.port
+CHILD3_1_MYSOCK= @mysqld.1.1.socket
+CHILD3_1_ENGINE_TYPE= InnoDB
+CHILD3_1_ENGINE= ENGINE=InnoDB
+CHILD3_1_CHARSET= DEFAULT CHARSET=utf8
+CHILD3_2_MYPORT= @mysqld.1.1.port
+CHILD3_2_MYSOCK= @mysqld.1.1.socket
+CHILD3_2_ENGINE_TYPE= InnoDB
+CHILD3_2_ENGINE= ENGINE=InnoDB
+CHILD3_2_CHARSET= DEFAULT CHARSET=utf8
+CHILD3_3_MYPORT= @mysqld.1.1.port
+CHILD3_3_MYSOCK= @mysqld.1.1.socket
+CHILD3_3_ENGINE_TYPE= InnoDB
+CHILD3_3_ENGINE= ENGINE=InnoDB
+CHILD3_3_CHARSET= DEFAULT CHARSET=utf8
+
+STR_SEMICOLON= ;
diff --git a/storage/vp/mysql-test/vp/r/basic_sql.result b/storage/vp/mysql-test/vp/r/basic_sql.result
new file mode 100644
index 00000000000..cc8feef99d9
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/basic_sql.result
@@ -0,0 +1,736 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+create table ignore select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'f', '2008-07-01 10:21:39'),
+(2, 'g', '2000-02-01 00:00:00'),
+(3, 'j', '2007-05-04 20:03:11'),
+(4, 'i', '2003-10-30 05:01:03'),
+(5, 'h', '2001-10-31 23:59:59');
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+IGNORE SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
+Warning 1062 Duplicate entry '2' for key 'PRIMARY'
+Warning 1062 Duplicate entry '3' for key 'PRIMARY'
+Warning 1062 Duplicate entry '4' for key 'PRIMARY'
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+create table ignore select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+REPLACE SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+create no index table
+connection master_1;
+DROP TABLE IF EXISTS ta_l_no_idx;
+CREATE TABLE ta_l_no_idx
+MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1
+SELECT a, b, c FROM tb_l
+ERROR 42000: This table type requires a primary key
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table shared mode
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table for update
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+FOR UPDATE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table join
+connection master_1;
+SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b
+WHERE a.a = b.a ORDER BY a.a;
+a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table straight_join
+connection master_1;
+SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')
+FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a;
+a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_small_result
+connection master_1;
+SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_big_result
+connection master_1;
+SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_buffer_result
+connection master_1;
+SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_cache
+connection master_1;
+SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_no_cache
+connection master_1;
+SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_calc_found_rows
+connection master_1;
+SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a LIMIT 4;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+connection master_1;
+SELECT found_rows();
+found_rows()
+5
+
+select high_priority
+connection master_1;
+SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select distinct
+connection master_1;
+SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select count
+connection master_1;
+SELECT count(*) FROM ta_l ORDER BY a;
+count(*)
+5
+
+select table join not use index
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
+EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select using pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+select using index and pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+insert
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert select
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+insert select a
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+
+insert low_priority
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert high_priority
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e',
+'2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert ignore
+connection master_1;
+INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01');
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'PRIMARY'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert update (insert)
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert update (update)
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 f 2005-08-08 11:11:11
+
+replace
+connection master_1;
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 f 2008-02-02 02:02:02
+
+replace select
+connection master_1;
+REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+replace select a
+connection master_1;
+REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+replace low_priority
+connection master_1;
+REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g',
+'2009-03-03 03:03:03');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 g 2000-02-01 00:00:00
+3 g 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+update
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 f 2008-02-02 02:02:02
+
+update select
+connection master_1;
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM
+tb_l);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+update select a
+connection master_1;
+UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM
+tb_l ORDER BY a LIMIT 1);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 h 2010-04-04 04:04:04
+2 g 2009-03-03 03:03:03
+
+update join
+connection master_1;
+UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+
+update join a
+connection master_1;
+UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE
+a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+update low_priority
+connection master_1;
+UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 f 2008-02-02 02:02:02
+
+update ignore
+connection master_1;
+UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 f 2008-02-02 02:02:02
+
+update pushdown
+connection master_1;
+update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 j 2009-03-03 03:03:03
+
+update index pushdown
+connection master_1;
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+delete
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete all
+connection master_1;
+DELETE FROM ta_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+
+delete select
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete select a
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete join
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete low_priority
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE LOW_PRIORITY FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete ignore
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE IGNORE FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete quick
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE QUICK FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+10 j 2008-01-01 23:59:59
+
+delete index pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a > 0 AND b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+10 j 2008-01-01 23:59:59
+
+truncate
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/basic_sql_part.result b/storage/vp/mysql-test/vp/r/basic_sql_part.result
new file mode 100644
index 00000000000..a17d5031b26
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/basic_sql_part.result
@@ -0,0 +1,136 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'f', '2008-07-01 10:21:39'),
+(2, 'g', '2000-02-01 00:00:00'),
+(3, 'j', '2007-05-04 20:03:11'),
+(4, 'i', '2003-10-30 05:01:03'),
+(5, 'h', '2001-10-31 23:59:59');
+
+create table with partition and select test
+connection master_1;
+CREATE TABLE ta_l2 (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l2' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select partition using pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+select partition using index pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+update partition pushdown
+connection master_1;
+UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 e 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+update partition index pushdown
+connection master_1;
+UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+delete partition pushdown
+TRUNCATE TABLE ta_l2;
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+connection master_1;
+DELETE FROM ta_l2 WHERE b = 'g';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+delete partition index pushdown
+TRUNCATE TABLE ta_l2;
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+connection master_1;
+DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/direct_aggregate.result b/storage/vp/mysql-test/vp/r/direct_aggregate.result
new file mode 100644
index 00000000000..e9a741db9cf
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/direct_aggregate.result
@@ -0,0 +1,88 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+direct_aggregating test
+connection master_1;
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT COUNT(*) FROM ta_l;
+COUNT(*)
+5
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MAX(a) FROM ta_l;
+MAX(a)
+5
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MIN(a) FROM ta_l;
+MIN(a)
+1
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MAX(a) FROM ta_l WHERE a < 5;
+MAX(a)
+4
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MIN(a) FROM ta_l WHERE a > 1;
+MIN(a)
+2
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/direct_aggregate_part.result b/storage/vp/mysql-test/vp/r/direct_aggregate_part.result
new file mode 100644
index 00000000000..a70b7862a98
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/direct_aggregate_part.result
@@ -0,0 +1,78 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT COUNT(*) FROM ta_l2;
+COUNT(*)
+5
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MAX(a) FROM ta_l2;
+MAX(a)
+5
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MIN(a) FROM ta_l2;
+MIN(a)
+1
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MAX(a) FROM ta_l2 WHERE a < 5;
+MAX(a)
+4
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+SELECT MIN(a) FROM ta_l2 WHERE a > 1;
+MIN(a)
+2
+SHOW STATUS LIKE 'Vp_direct_aggregate';
+Variable_name Value
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/direct_update.result b/storage/vp/mysql-test/vp/r/direct_update.result
new file mode 100644
index 00000000000..dadcf54572e
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/direct_update.result
@@ -0,0 +1,141 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+direct_updating test
+connection master_1;
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+update all rows with function
+UPDATE ta_l SET c = ADDDATE(c, 1);
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 e 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key
+UPDATE ta_l SET b = 'x' WHERE a = 3;
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by a column without index
+UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-17 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key with order and limit
+UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by primary key with order and limit
+DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by a column without index
+DELETE FROM ta_l WHERE b = 'c';
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+delete by primary key
+DELETE FROM ta_l WHERE a = 3;
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+4 d 2003-12-01 05:01:03
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/direct_update_part.result b/storage/vp/mysql-test/vp/r/direct_update_part.result
new file mode 100644
index 00000000000..89499aa6261
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/direct_update_part.result
@@ -0,0 +1,131 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+update all rows with function
+UPDATE ta_l2 SET c = ADDDATE(c, 1);
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 e 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key
+UPDATE ta_l2 SET b = 'x' WHERE a = 3;
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by a column without index
+UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-17 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key with order and limit
+UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+SHOW STATUS LIKE 'Vp_direct_update';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by primary key with order and limit
+DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by a column without index
+DELETE FROM ta_l2 WHERE b = 'c';
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+delete by primary key
+DELETE FROM ta_l2 WHERE a = 3;
+SHOW STATUS LIKE 'Vp_direct_delete';
+Variable_name Value
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+4 d 2003-12-01 05:01:03
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/fulltext.result b/storage/vp/mysql-test/vp/r/fulltext.result
new file mode 100644
index 00000000000..feae998a915
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/fulltext.result
@@ -0,0 +1,70 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS ft_l;
+CREATE TABLE ft_l (
+a INT DEFAULT 0,
+b TEXT,
+c TEXT,
+d TEXT,
+PRIMARY KEY(a),
+FULLTEXT INDEX ft_idx1(b),
+FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_FT_2_1
+INSERT INTO ft_l (a,b,c,d) VALUES
+(1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+(2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+(3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+(4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+(5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+
+fulltext search
+connection master_1;
+select a, b, c, d from ft_l where match(b) against('fedc');
+a b c d
+3 cccc cdef fedc dddd defg gfed eeee efgh hgfe
+select a, b, c, d from ft_l where match(c) against('hgfe');
+a b c d
+4 dddd defg gfed eeee efgh hgfe ffff fghi ihgf
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/fulltext_part.result b/storage/vp/mysql-test/vp/r/fulltext_part.result
new file mode 100644
index 00000000000..a647193aeb5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/fulltext_part.result
@@ -0,0 +1,59 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ft_l2 (
+a INT DEFAULT 0,
+b TEXT,
+c TEXT,
+d TEXT,
+PRIMARY KEY(a),
+FULLTEXT INDEX ft_idx1(b),
+FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_FT_P_2_1
+select a, b, c, d from ft_l2 where match(b) against('fedc');
+a b c d
+3 cccc cdef fedc dddd defg gfed eeee efgh hgfe
+select a, b, c, d from ft_l2 where match(c) against('hgfe');
+a b c d
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/function.result b/storage/vp/mysql-test/vp/r/function.result
new file mode 100644
index 00000000000..67681d4127e
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/function.result
@@ -0,0 +1,154 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+in()
+connection master_1;
+CREATE TABLE t1 (
+a VARCHAR(255),
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1
+insert into t1 values ('1');
+insert into t1 select a + 1 from t1;
+insert into t1 select a + 2 from t1;
+insert into t1 select a + 4 from t1;
+insert into t1 select a + 8 from t1;
+insert into t1 select a + 16 from t1;
+insert into t1 select a + 32 from t1;
+insert into t1 select a + 64 from t1;
+insert into t1 select a + 128 from t1;
+insert into t1 select a + 256 from t1;
+insert into t1 select a + 512 from t1;
+flush tables;
+connection master_1;
+select a from t1 where a in ('15', '120');
+a
+120
+15
+
+date_sub()
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-08-01 10:21:39
+2 b 1999-01-01 00:00:00
+3 e 2006-06-04 20:03:11
+4 d 2002-11-30 05:01:03
+5 c 2000-12-31 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-11-01 10:21:39
+2 b 1999-04-01 00:00:00
+3 e 2006-09-04 20:03:11
+4 d 2003-02-28 05:01:03
+5 c 2001-03-31 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-01 10:21:39
+2 b 1999-03-01 00:00:00
+3 e 2006-08-04 20:03:11
+4 d 2003-01-28 05:01:03
+5 c 2001-02-28 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-08 10:21:39
+2 b 1999-03-08 00:00:00
+3 e 2006-08-11 20:03:11
+4 d 2003-02-04 05:01:03
+5 c 2001-03-07 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 10:21:39
+2 b 1999-03-07 00:00:00
+3 e 2006-08-10 20:03:11
+4 d 2003-02-03 05:01:03
+5 c 2001-03-06 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:21:39
+2 b 1999-03-07 01:00:00
+3 e 2006-08-10 21:03:11
+4 d 2003-02-03 06:01:03
+5 c 2001-03-07 00:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:20:39
+2 b 1999-03-07 00:59:00
+3 e 2006-08-10 21:02:11
+4 d 2003-02-03 06:00:03
+5 c 2001-03-07 00:58:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:20:40
+2 b 1999-03-07 00:59:01
+3 e 2006-08-10 21:02:12
+4 d 2003-02-03 06:00:04
+5 c 2001-03-07 00:59:00
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/geometry.result b/storage/vp/mysql-test/vp/r/geometry.result
new file mode 100644
index 00000000000..077cf93a419
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/geometry.result
@@ -0,0 +1,103 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS gm_l;
+CREATE TABLE gm_l (
+a INT DEFAULT 0,
+b GEOMETRY NOT NULL,
+c GEOMETRY NOT NULL,
+PRIMARY KEY(a),
+SPATIAL INDEX sp_idx1(b),
+SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+geometry search
+connection master_1;
+SELECT AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+AsText(b)
+POINT(40000 15000)
+POINT(40000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+AsText(c)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(80000 15000)
+POINT(80000 16000)
+POINT(70000 16000)
+POINT(60000 15000)
+POINT(60000 16000)
+POINT(50000 15000)
+POINT(50000 16000)
+POINT(40000 15000)
+POINT(40000 16000)
+POINT(30000 15000)
+POINT(30000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/geometry_normal.result b/storage/vp/mysql-test/vp/r/geometry_normal.result
new file mode 100644
index 00000000000..2dfb445978c
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/geometry_normal.result
@@ -0,0 +1,85 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+SELECT 1;
+1
+1
+
+create table and insert
+DROP TABLE IF EXISTS gm_l;
+CREATE TABLE gm_l (
+a INT DEFAULT 0,
+b GEOMETRY NOT NULL,
+c GEOMETRY NOT NULL,
+PRIMARY KEY(a),
+SPATIAL INDEX sp_idx1(b),
+SPATIAL INDEX sp_idx2(c)
+) ENGINE=MyISAM MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+geometry search
+SELECT AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+AsText(b)
+POINT(40000 15000)
+POINT(40000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+AsText(c)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(80000 15000)
+POINT(80000 16000)
+POINT(70000 16000)
+POINT(60000 15000)
+POINT(60000 16000)
+POINT(50000 15000)
+POINT(50000 16000)
+POINT(40000 15000)
+POINT(40000 16000)
+POINT(30000 15000)
+POINT(30000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+
+deinit
+DROP DATABASE IF EXISTS auto_test_local;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/geometry_part.result b/storage/vp/mysql-test/vp/r/geometry_part.result
new file mode 100644
index 00000000000..a2e57cc512a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/geometry_part.result
@@ -0,0 +1,86 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE gm_l2 (
+a INT DEFAULT 0,
+b GEOMETRY NOT NULL,
+c GEOMETRY NOT NULL,
+PRIMARY KEY(a),
+SPATIAL INDEX sp_idx1(b),
+SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_GM_P_2_1
+SELECT AsText(b) FROM gm_l2 WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+AsText(b)
+POINT(40000 16000)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+AsText(c)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(80000 15000)
+POINT(80000 16000)
+POINT(70000 16000)
+POINT(60000 15000)
+POINT(60000 16000)
+POINT(50000 15000)
+POINT(50000 16000)
+POINT(40000 15000)
+POINT(40000 16000)
+POINT(30000 15000)
+POINT(30000 16000)
+SELECT AsText(c) FROM gm_l2 WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+SELECT AsText(c) FROM gm_l2 WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/ha.result b/storage/vp/mysql-test/vp/r/ha.result
new file mode 100644
index 00000000000..53265d9b63d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/ha.result
@@ -0,0 +1,2 @@
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/ha_part.result b/storage/vp/mysql-test/vp/r/ha_part.result
new file mode 100644
index 00000000000..53265d9b63d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/ha_part.result
@@ -0,0 +1,2 @@
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/handler.result b/storage/vp/mysql-test/vp/r/handler.result
new file mode 100644
index 00000000000..bb2a5bf76c7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/handler.result
@@ -0,0 +1,122 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+handler test
+connection master_1;
+HANDLER ta_l OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+1 a 2008-08-01 10:21:39
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+HANDLER a READ FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ FIRST WHERE b = 'c';
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a CLOSE;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/handler_part.result b/storage/vp/mysql-test/vp/r/handler_part.result
new file mode 100644
index 00000000000..26c7311f156
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/handler_part.result
@@ -0,0 +1,112 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+handler with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+HANDLER ta_l2 OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+1 a 2008-08-01 10:21:39
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+HANDLER a READ FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+3 e 2007-06-04 20:03:11
+HANDLER a READ NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+2 b 2000-01-01 00:00:00
+HANDLER a READ NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ FIRST WHERE b = 'c';
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a CLOSE;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/spider3_fixes.result b/storage/vp/mysql-test/vp/r/spider3_fixes.result
new file mode 100644
index 00000000000..2eae8a4f380
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/spider3_fixes.result
@@ -0,0 +1,206 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+3.1
+auto_increment
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT MAX(id) FROM t1;
+MAX(id)
+777
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1554
+SELECT MAX(id) FROM t2;
+MAX(id)
+1554
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2332
+SELECT MAX(id) FROM t1;
+MAX(id)
+2332
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3885
+SELECT MAX(id) FROM t2;
+MAX(id)
+3885
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+4663
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2332
+3885
+4663
+5440
+6217
+6994
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+8547
+SELECT id FROM t2 ORDER BY id;
+id
+777
+1554
+2332
+3885
+4663
+5440
+6217
+6994
+8547
+9324
+10101
+10878
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3885
+SELECT id FROM t2 ORDER BY id;
+id
+777
+1554
+2331
+3108
+3885
+4662
+5439
+6216
+SET INSERT_ID=5000;
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+6216
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t2;
+MAX(id)
+6993
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t2;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+5000
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/spider3_fixes_part.result b/storage/vp/mysql-test/vp/r/spider3_fixes_part.result
new file mode 100644
index 00000000000..9e4c9ae7c52
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/spider3_fixes_part.result
@@ -0,0 +1,204 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+auto_increment with partition
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT MAX(id) FROM t1;
+MAX(id)
+777
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1554
+SELECT MAX(id) FROM t2;
+MAX(id)
+1554
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+778
+SELECT MAX(id) FROM t1;
+MAX(id)
+1554
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2331
+SELECT MAX(id) FROM t2;
+MAX(id)
+2331
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1555
+SELECT id FROM t1 ORDER BY id;
+id
+777
+778
+1554
+1555
+2331
+2332
+3109
+3886
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3108
+SELECT id FROM t2 ORDER BY id;
+id
+777
+778
+1554
+1555
+2331
+2332
+3108
+3109
+3885
+3886
+4662
+5439
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3885
+SELECT id FROM t2 ORDER BY id;
+id
+777
+1554
+2331
+3108
+3885
+4662
+5439
+6216
+SET INSERT_ID=5000;
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+6216
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t2;
+MAX(id)
+6993
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6993
+SELECT MAX(id) FROM t2;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+5000
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/spider_fixes.result b/storage/vp/mysql-test/vp/r/spider_fixes.result
new file mode 100644
index 00000000000..07192c3dbc2
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/spider_fixes.result
@@ -0,0 +1,542 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+2.13
+select table with "order by desc" and "<"
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a < 5 ORDER BY a DESC LIMIT 3;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+
+select table with "order by desc" and "<="
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a <= 5 ORDER BY a DESC LIMIT 3;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+
+2.14
+update table with range scan and split_read
+connection master_1;
+UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-02-02 00:00:00
+3 e 2000-02-02 00:00:00
+4 d 2000-02-02 00:00:00
+5 c 2000-02-02 00:00:00
+
+2.15
+select table with range scan
+TRUNCATE TABLE ta_l;
+DROP TABLE IF EXISTS ta_l;
+connection master_1;
+CREATE TABLE ta_l (
+a int(11) NOT NULL DEFAULT '0',
+b char(1) DEFAULT NULL,
+c datetime DEFAULT NULL,
+PRIMARY KEY (a, b, c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c'
+AND c = '2001-12-31 23:59:59';
+a b c
+5 c 2001-12-31 23:59:59
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND b <= 'd' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND b < 'e' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1
+AND b >= 'b' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+connection master_1;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1
+AND b >= 'b' AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+
+2.16
+auto_increment insert with trigger
+connection master_1;
+CREATE TABLE ta_l_auto_inc (
+a INT AUTO_INCREMENT,
+b CHAR(1) DEFAULT 'c',
+c DATETIME DEFAULT '1999-10-10 10:10:10',
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1
+CREATE TABLE tc_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;;
+connection master_1;
+INSERT INTO ta_l_auto_inc (a, b, c) VALUES
+(NULL, 's', '2008-12-31 20:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 s 2008-12-31 20:59:59
+
+2.17
+engine-condition-pushdown with "or" and joining
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l);
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+2.23
+index merge
+connection master_1;
+CREATE TABLE ta_l_int (
+a INT AUTO_INCREMENT,
+b INT DEFAULT 10,
+c INT DEFAULT 11,
+PRIMARY KEY(a),
+KEY idx1(b),
+KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+connection master_1;
+SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+a b c
+3 4 5
+4 5 6
+5 6 7
+
+2.24
+index scan update without PK
+connection master_1;
+DROP TABLE IF EXISTS ta_l_int;
+CREATE TABLE ta_l_int (
+a INT NOT NULL,
+b INT DEFAULT 10,
+c INT DEFAULT 11,
+KEY idx1(b),
+KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+ERROR 42000: This table type requires a primary key
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+a b c
+1 2 3
+2 3 4
+3 4 5
+4 5 6
+5 6 7
+6 7 8
+7 8 9
+8 9 10
+9 10 11
+10 11 12
+11 12 13
+12 13 14
+13 14 15
+14 15 16
+15 16 17
+16 17 18
+INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3);
+INSERT INTO ta_l_int (a, b, c) VALUES (18, 2, 3);
+connection master_1;
+UPDATE ta_l_int SET c = 4 WHERE b = 2;
+connection master_1;
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+a b c
+1 2 4
+2 3 4
+3 4 5
+4 5 6
+5 6 7
+6 7 8
+7 8 9
+8 9 10
+9 10 11
+10 11 12
+11 12 13
+12 13 14
+13 14 15
+14 15 16
+15 16 17
+16 17 18
+17 2 4
+18 2 4
+
+2.25
+direct order limit
+connection master_1;
+SHOW STATUS LIKE 'Vp_direct_order_limit';
+Variable_name Value
+SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3;
+a b c
+1 2 4
+2 3 4
+3 4 5
+SHOW STATUS LIKE 'Vp_direct_order_limit';
+Variable_name Value
+
+2.26
+lock tables
+connection master_1;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1
+CREATE TABLE t2 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2
+LOCK TABLES t1 READ, t2 READ;
+UNLOCK TABLES;
+
+auto_increment
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT MAX(id) FROM t1;
+MAX(id)
+777
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1554
+SELECT MAX(id) FROM t1;
+MAX(id)
+1554
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2331
+SELECT MAX(id) FROM t1;
+MAX(id)
+2331
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3108
+SELECT MAX(id) FROM t1;
+MAX(id)
+3108
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3885
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+3885
+4662
+5439
+6216
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+6216
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1000
+1554
+2331
+3108
+3885
+4662
+5000
+5439
+6216
+10000
+connection master_1;
+
+read only
+skipped
+
+2.27
+error mode
+skipped
+
+3.0
+is null
+connection master_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a VARCHAR(255),
+b VARCHAR(255),
+c VARCHAR(255),
+KEY idx1(a,b),
+KEY idx2(b),
+PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1
+insert into t1 values (null, null, '2048');
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a + 32, b + 32, c + 32 from t1;
+insert into t1 select a + 64, b + 64, c + 64 from t1;
+insert into t1 select a + 128, b + 128, c + 128 from t1;
+insert into t1 select a + 256, b + 256, c + 256 from t1;
+insert into t1 select a + 512, b + 512, c + 512 from t1;
+flush tables;
+connection master_1;
+select a from t1 where a is null order by a limit 30;
+a
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+select b from t1 where b is null order by b limit 30;
+b
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+
+direct_order_limit
+connection master_1;
+TRUNCATE TABLE t1;
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a, b + 32, c + 32 from t1;
+insert into t1 select a, b + 64, c + 64 from t1;
+insert into t1 select a, b + 128, c + 128 from t1;
+flush tables;
+connection master_1;
+select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5;
+a b c
+10 74 74
+10 42 42
+10 234 234
+10 202 202
+10 170 170
+select a, c from t1 where a = '10' order by b desc limit 5;
+a c
+10 74
+10 42
+10 234
+10 202
+10 170
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/spider_fixes_part.result b/storage/vp/mysql-test/vp/r/spider_fixes_part.result
new file mode 100644
index 00000000000..5f96c27350a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/spider_fixes_part.result
@@ -0,0 +1,219 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+2.17
+partition with sort
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+2.23
+partition update with moving partition
+connection master_1;
+DROP TABLE IF EXISTS ta_l2;
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
+UPDATE ta_l2 SET a = 4 WHERE a = 3;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+4 B 2010-09-26 00:00:00
+index merge with partition
+connection master_1;
+DROP TABLE IF EXISTS ta_l_int;
+connection master_1;
+CREATE TABLE ta_l_int (
+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_COMMENT3_P_2_1
+INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+connection master_1;
+SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+a b c
+3 4 5
+4 5 6
+5 6 7
+
+2.26
+auto_increment with partition
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+777
+SELECT MAX(id) FROM t1;
+MAX(id)
+777
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1554
+SELECT MAX(id) FROM t1;
+MAX(id)
+1554
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2331
+SELECT MAX(id) FROM t1;
+MAX(id)
+2331
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3108
+SELECT MAX(id) FROM t1;
+MAX(id)
+3108
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3885
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1554
+2331
+3108
+3885
+4662
+5439
+6216
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+6216
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5000
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+777
+1000
+1554
+2331
+3108
+3885
+4662
+5000
+5439
+6216
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/r/vp_fixes.result b/storage/vp/mysql-test/vp/r/vp_fixes.result
new file mode 100644
index 00000000000..b42bd293307
--- /dev/null
+++ b/storage/vp/mysql-test/vp/r/vp_fixes.result
@@ -0,0 +1,89 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+0.9
+create different primary key table
+connection master_1;
+CREATE TABLE ta_l_int (
+a INT DEFAULT 10,
+b INT AUTO_INCREMENT,
+c INT DEFAULT 11,
+PRIMARY KEY(b)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+connection master_1;
+INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ERROR HY000: Can't correspond PK 'ta_r_int'
+create un-correspond primary key table
+connection master_1;
+DROP TABLE IF EXISTS ta_l_int;
+connection master_1;
+CREATE TABLE ta_l_int (
+a INT DEFAULT 10,
+b INT DEFAULT 12,
+c INT DEFAULT 11,
+PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+connection master_1;
+INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ERROR HY000: Can't correspond PK 'ta_r_int'
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/disabled.def b/storage/vp/mysql-test/vp/spider/disabled.def
new file mode 100644
index 00000000000..08b9abcf394
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/disabled.def
@@ -0,0 +1 @@
+spider_fixes : need to fix
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child2_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child2_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child2_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child2_2.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child3_1.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child3_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child3_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child3_2.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child3_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child3_2.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_child3_3.inc b/storage/vp/mysql-test/vp/spider/include/deinit_child3_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_child3_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_master_1.inc b/storage/vp/mysql-test/vp/spider/include/deinit_master_1.inc
new file mode 100644
index 00000000000..50b8eaa662c
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_master_1.inc
@@ -0,0 +1,5 @@
+DROP DATABASE IF EXISTS auto_test_remote2;
+DROP DATABASE IF EXISTS auto_test_remote;
+set optimizer_switch = @optimizer_switch_backup;
+--source ../../include/deinit_vp.inc
+--source ../../../../../spider/mysql-test/spider/include/deinit_spider.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/deinit_slave1_1.inc b/storage/vp/mysql-test/vp/spider/include/deinit_slave1_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/deinit_slave1_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_2.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_1.inc
new file mode 100644
index 00000000000..8da57396d48
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_1.inc
@@ -0,0 +1,2 @@
+DROP DATABASE IF EXISTS auto_test_remote;
+--source ../../../../../spider/mysql-test/spider/include/deinit_spider.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_2.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_2.inc
new file mode 100644
index 00000000000..8da57396d48
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_2.inc
@@ -0,0 +1,2 @@
+DROP DATABASE IF EXISTS auto_test_remote;
+--source ../../../../../spider/mysql-test/spider/include/deinit_spider.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_3.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_3.inc
new file mode 100644
index 00000000000..8da57396d48
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_child3_3.inc
@@ -0,0 +1,2 @@
+DROP DATABASE IF EXISTS auto_test_remote;
+--source ../../../../../spider/mysql-test/spider/include/deinit_spider.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_deinit_master_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_deinit_master_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_deinit_master_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_1.inc
new file mode 100644
index 00000000000..c7fb2aa7dc4
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_1.inc
@@ -0,0 +1,16 @@
+let $CHILD2_1_HA_AS_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r_2;
+let $CHILD2_1_HA_AS_CREATE_TABLES=
+ CREATE TABLE ta_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_HA_AS_DROP_TABLES2=
+ DROP TABLE IF EXISTS ta_r2_2;
+let $CHILD2_1_HA_AS_CREATE_TABLES2=
+ CREATE TABLE ta_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_2.inc
new file mode 100644
index 00000000000..e6e1254112a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_2.inc
@@ -0,0 +1,8 @@
+let $CHILD2_2_HA_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r3_2;
+let $CHILD2_2_HA_CREATE_TABLES=
+ CREATE TABLE ta_r3_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_3.inc
new file mode 100644
index 00000000000..f922eb6b77e
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child2_3.inc
@@ -0,0 +1,8 @@
+let $CHILD2_3_HA_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r4_2;
+let $CHILD2_3_HA_CREATE_TABLES=
+ CREATE TABLE ta_r4_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET;
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child3_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_1.inc
new file mode 100644
index 00000000000..a9de2268633
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_1.inc
@@ -0,0 +1,109 @@
+--let $CHILD3_1_ENGINE_TYPE=Spider
+--let $CHILD3_1_ENGINE=ENGINE=Spider
+--source ../../../../../spider/mysql-test/spider/include/init_spider.inc
+eval INSERT INTO mysql.spider_link_mon_servers
+(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
+ username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
+ ssl_verify_server_cert, default_file, default_group) VALUES
+('%auto_test%', '%a%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
+let $CHILD3_1_CHECK_LINK_STATUS=
+ SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ ORDER BY db_name, table_name, link_id;
+let $CHILD3_1_CHECK_LINK_FAILED_LOG=
+ SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+let $CHILD3_1_SET_RECOVERY_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 2"';
+let $CHILD3_1_SET_OK_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 1"';
+let $CHILD3_1_SET_OK_STATUS_AS_2_1=
+ ALTER TABLE auto_test_remote.as_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "1 0"';
+
+let $CHILD3_1_DROP_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_1_CREATE_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_1_CREATE_TABLES_HA_AS_2_1=
+ SELECT 1;
+let $CHILD3_1_DROP_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_1_CREATE_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1=
+ SELECT 1;
+let $CHILD3_1_SET_RECOVERY_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 2"';
+let $CHILD3_1_SET_OK_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 1"';
+let $CHILD3_1_SET_OK_STATUS_AS_P_2_1=
+ ALTER TABLE auto_test_remote.as_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "1 0"';
+
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE ha_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE as_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE ha_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE as_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE ha_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE as_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE ha_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
+eval CREATE TABLE as_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child3_2.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_2.inc
new file mode 100644
index 00000000000..fc292de5b78
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_2.inc
@@ -0,0 +1,109 @@
+--let $CHILD3_2_ENGINE_TYPE=Spider
+--let $CHILD3_2_ENGINE=ENGINE=Spider
+--source ../../../../../spider/mysql-test/spider/include/init_spider.inc
+eval INSERT INTO mysql.spider_link_mon_servers
+(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
+ username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
+ ssl_verify_server_cert, default_file, default_group) VALUES
+('%auto_test%', '%a%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
+let $CHILD3_2_CHECK_LINK_STATUS=
+ SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ ORDER BY db_name, table_name, link_id;
+let $CHILD3_2_CHECK_LINK_FAILED_LOG=
+ SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+let $CHILD3_2_SET_RECOVERY_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 2"';
+let $CHILD3_2_SET_OK_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 1"';
+let $CHILD3_2_SET_OK_STATUS_AS_2_1=
+ ALTER TABLE auto_test_remote.as_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "1 0"';
+
+let $CHILD3_2_DROP_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_2_CREATE_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_2_CREATE_TABLES_HA_AS_2_1=
+ SELECT 1;
+let $CHILD3_2_DROP_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_2_CREATE_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1=
+ SELECT 1;
+let $CHILD3_2_SET_RECOVERY_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 2"';
+let $CHILD3_2_SET_OK_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 1"';
+let $CHILD3_2_SET_OK_STATUS_AS_P_2_1=
+ ALTER TABLE auto_test_remote.as_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "1 0"';
+
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE ha_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE as_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE ha_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE as_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE ha_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE as_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE ha_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
+eval CREATE TABLE as_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_child3_3.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_3.inc
new file mode 100644
index 00000000000..8b089174b81
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_child3_3.inc
@@ -0,0 +1,109 @@
+--let $CHILD3_3_ENGINE_TYPE=Spider
+--let $CHILD3_3_ENGINE=ENGINE=Spider
+--source ../../../../../spider/mysql-test/spider/include/init_spider.inc
+eval INSERT INTO mysql.spider_link_mon_servers
+(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
+ username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
+ ssl_verify_server_cert, default_file, default_group) VALUES
+('%auto_test%', '%a%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
+let $CHILD3_3_CHECK_LINK_STATUS=
+ SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ ORDER BY db_name, table_name, link_id;
+let $CHILD3_3_CHECK_LINK_FAILED_LOG=
+ SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+let $CHILD3_3_SET_RECOVERY_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 2"';
+let $CHILD3_3_SET_OK_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 1"';
+let $CHILD3_3_SET_OK_STATUS_AS_2_1=
+ ALTER TABLE auto_test_remote.as_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "1 0"';
+
+let $CHILD3_3_DROP_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_3_CREATE_TABLES_HA_2_1=
+ SELECT 1;
+let $CHILD3_3_CREATE_TABLES_HA_AS_2_1=
+ SELECT 1;
+let $CHILD3_3_DROP_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_3_CREATE_TABLES_HA_P_2_1=
+ SELECT 1;
+let $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1=
+ SELECT 1;
+let $CHILD3_3_SET_RECOVERY_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 2"';
+let $CHILD3_3_SET_OK_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 1"';
+let $CHILD3_3_SET_OK_STATUS_AS_P_2_1=
+ ALTER TABLE auto_test_remote.as_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "1 0"';
+
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE ha_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE as_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE ha_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE as_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE ha_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE as_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE ha_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
+eval CREATE TABLE as_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
diff --git a/storage/vp/mysql-test/vp/spider/include/ha_init_master_1.inc b/storage/vp/mysql-test/vp/spider/include/ha_init_master_1.inc
new file mode 100644
index 00000000000..705bbc3b7f3
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/ha_init_master_1.inc
@@ -0,0 +1,117 @@
+eval INSERT INTO mysql.spider_link_mon_servers
+(db_name, table_name, link_id, sid, server, scheme, host, port, socket,
+ username, password, ssl_ca, ssl_capath, ssl_cert, ssl_cipher, ssl_key,
+ ssl_verify_server_cert, default_file, default_group) VALUES
+('%auto_test%', '%a%', '%', $CHILD3_1_SERVER_ID, 's_3_1', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_2_SERVER_ID, 's_3_2', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL),
+('%auto_test%', '%a%', '%', $CHILD3_3_SERVER_ID, 's_3_3', NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
+let $MASTER_1_CHECK_LINK_STATUS=
+ SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ ORDER BY db_name, table_name, link_id;
+let $MASTER_1_CHECK_LINK_FAILED_LOG=
+ SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+let $MASTER_1_SET_RECOVERY_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 2"';
+let $MASTER_1_SET_OK_STATUS_2_1=
+ ALTER TABLE auto_test_remote.ha_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 1"';
+let $MASTER_1_SET_OK_STATUS_AS_2_1=
+ ALTER TABLE auto_test_remote.as_r_2
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "1 0"';
+let $MASTER_1_COPY_TABLES_2_1=
+ SELECT spider_copy_tables('auto_test_remote.ha_r_2', '0', '1');
+let $MASTER_1_COMMENT_HA_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ha_r ha_r_2"';
+let $MASTER_1_COMMENT_HA_AS_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "as_r as_r_2"';
+let $MASTER_1_COMMENT_HA_P_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ PARTITION BY KEY(a) (
+ PARTITION pt1 COMMENT='tnl "ha_r ha_r_2"',
+ PARTITION pt2 COMMENT='tnl "ha_r2 ha_r2_2"'
+ );
+let $MASTER_1_COMMENT_HA_AS_P_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ PARTITION BY KEY(a) (
+ PARTITION pt1 COMMENT='tnl "as_r as_r_2"',
+ PARTITION pt2 COMMENT='tnl "as_r2 as_r2_2"'
+ );
+let $MASTER_1_SET_RECOVERY_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 2"';
+let $MASTER_1_SET_OK_STATUS_P_2_1=
+ ALTER TABLE auto_test_remote.ha_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 1"';
+let $MASTER_1_SET_OK_STATUS_AS_P_2_1=
+ ALTER TABLE auto_test_remote.as_r2_2
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "1 0"';
+let $MASTER_1_COPY_TABLES_P_2_1=
+ SELECT spider_copy_tables('auto_test_remote.ha_r2_2', '0', '1');
+
+USE auto_test_remote;
+eval CREATE TABLE ha_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE as_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r ta_r3"';
+eval CREATE TABLE ha_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE as_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2"';
+eval CREATE TABLE ha_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE as_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2 ta_r4"';
+eval CREATE TABLE ha_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
+eval CREATE TABLE as_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ CONNECTION='msi "$CHILD3_1_SERVER_ID", mkd "2", alc "1"'
+ COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2"';
+let $MASTER_1_CHECK_HA_STATUS=
+ SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+let $MASTER_1_CHANGE_HA_MON=
+ SELECT spider_flush_table_mon_cache();
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_1.inc
new file mode 100644
index 00000000000..a442551d6e7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_1.inc
@@ -0,0 +1 @@
+--source ../../../spider/include/deinit_handlersocket.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_2.inc
new file mode 100644
index 00000000000..a442551d6e7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_2.inc
@@ -0,0 +1 @@
+--source ../../../spider/include/deinit_handlersocket.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_deinit_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_deinit_master_1.inc b/storage/vp/mysql-test/vp/spider/include/hs_deinit_master_1.inc
new file mode 100644
index 00000000000..527f4beaa09
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_deinit_master_1.inc
@@ -0,0 +1,3 @@
+DROP DATABASE IF EXISTS auto_test_remote2;
+DROP DATABASE IF EXISTS auto_test_remote;
+--source ../../../spider/include/deinit_handlersocket.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_init_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_1.inc
new file mode 100644
index 00000000000..1af3b6de852
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_1.inc
@@ -0,0 +1,37 @@
+--source ../../../spider/include/init_handlersocket.inc
+let $CHILD2_1_HS_DROP_TABLES=
+ DROP TABLE IF EXISTS hs_r $STR_SEMICOLON
+ DROP TABLE IF EXISTS hs_r_2;
+let $CHILD2_1_HS_CREATE_TABLES=
+ CREATE TABLE hs_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE hs_r_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 11,
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_HS_SELECT_TABLES=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM hs_r ORDER BY a $STR_SEMICOLON
+ SELECT a, d FROM hs_r_2 ORDER BY a;
+let $CHILD2_1_HS_DROP_TABLES2=
+ DROP TABLE IF EXISTS hs_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS hs_r2_2;
+let $CHILD2_1_HS_CREATE_TABLES2=
+ CREATE TABLE hs_r2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE hs_r2_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 11,
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_HS_SELECT_TABLES2=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM hs_r2 ORDER BY a $STR_SEMICOLON
+ SELECT a, d FROM hs_r2_2 ORDER BY a;
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_init_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_2.inc
new file mode 100644
index 00000000000..de9385313b8
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_2.inc
@@ -0,0 +1,19 @@
+--source ../../../spider/include/init_handlersocket.inc
+let $CHILD2_2_HS_DROP_TABLES=
+ DROP TABLE IF EXISTS hs_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS hs_r3_2;
+let $CHILD2_2_HS_CREATE_TABLES=
+ CREATE TABLE hs_r3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET $STR_SEMICOLON
+ CREATE TABLE hs_r3_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 11,
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_HS_SELECT_TABLES=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM hs_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, d FROM hs_r3_2 ORDER BY a;
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_init_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_init_child2_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/hs_init_master_1.inc b/storage/vp/mysql-test/vp/spider/include/hs_init_master_1.inc
new file mode 100644
index 00000000000..99bdf99f67f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/hs_init_master_1.inc
@@ -0,0 +1,61 @@
+--source ../../../spider/include/init_handlersocket.inc
+let $MASTER_1_HS_COMMENT_TMP=
+ COMMENT='';
+let $MASTER_1_HS_COMMENT_2_1=
+ COMMENT='ddb "auto_test_remote", tnl "hs_r hs_r_2"';
+let $MASTER_1_HS_COMMENT_P_2_1=
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='ddb "auto_test_remote", tnl "hs_r2 hs_r2_2"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='ddb "auto_test_remote2", tnl "hs_r3 hs_r3_2"'
+ );
+let $MASTER_1_HIDDEN_HS_COMMENT_2_1=
+ COMMENT='srv "s_2_1", uhr "1", uhw "1", hrp "$CHILD2_1_HSRPORT", hwp "$CHILD2_1_HSWPORT"';
+let $MASTER_1_HIDDEN_HS_COMMENT_2_2=
+ COMMENT='srv "s_2_2", uhr "1", uhw "1", hrp "$CHILD2_2_HSRPORT", hwp "$CHILD2_2_HSWPORT"';
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE hs_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_1;
+eval CREATE TABLE hs_r_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 10,
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_1;
+eval CREATE TABLE hs_r2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_1;
+eval CREATE TABLE hs_r2_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 10,
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_1;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+eval CREATE TABLE hs_r3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_2;
+eval CREATE TABLE hs_r3_2 (
+ a INT DEFAULT 10,
+ d INT DEFAULT 10,
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_HS_COMMENT_2_2;
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child2_1.inc b/storage/vp/mysql-test/vp/spider/include/init_child2_1.inc
new file mode 100644
index 00000000000..1f6152e8359
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child2_1.inc
@@ -0,0 +1,234 @@
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r_2;
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE ta_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES=
+ SELECT a, b FROM ta_r ORDER BY a $STR_SEMICOLON
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES2=
+ DROP TABLE IF EXISTS ta_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r2_2;
+let $CHILD2_1_CREATE_TABLES2=
+ CREATE TABLE ta_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES2=
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, b FROM ta_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES3=
+ DROP TABLE IF EXISTS ta_r_no_idx;
+let $CHILD2_1_CREATE_TABLES3=
+ CREATE TABLE ta_r_no_idx (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES3=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_no_idx ORDER BY a;
+let $CHILD2_1_DROP_TABLES4=
+ DROP TABLE IF EXISTS ta_r_auto_inc, ta_r_auto_inc_2;
+let $CHILD2_1_CREATE_TABLES4=
+ CREATE TABLE ta_r_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_auto_inc_2 (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES4=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc
+ ORDER BY a $STR_SEMICOLON
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_auto_inc_2
+ ORDER BY a;
+let $CHILD2_1_DROP_TABLES5=
+ DROP TABLE IF EXISTS ta_r_int, ta_r_int_2;
+let $CHILD2_1_CREATE_TABLES5=
+ CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES5=
+ SELECT a, b, c FROM ta_r_int ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, b, c FROM ta_r_int_2 ORDER BY a;
+let $CHILD2_1_DROP_TABLES6=
+ DROP TABLE IF EXISTS ta_r_3;
+let $CHILD2_1_CREATE_TABLES6=
+ CREATE TABLE ta_r_3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a, b, c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TABLES6=
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a;
+let $CHILD2_1_DROP_FT_TABLES=
+ DROP TABLE IF EXISTS ft_r, ft_r_2;
+let $CHILD2_1_CREATE_FT_TABLES=
+ CREATE TABLE ft_r (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
+let $CHILD2_1_SELECT_FT_TABLES=
+ SELECT a, b, c FROM ft_r ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r_2 ORDER BY a;
+let $CHILD2_1_DROP_FT_TABLES2=
+ DROP TABLE IF EXISTS ft_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ft_r2_2;
+let $CHILD2_1_CREATE_FT_TABLES2=
+ CREATE TABLE ft_r2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r2_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_1_FT_ENGINE $CHILD2_1_FT_CHARSET;
+let $CHILD2_1_SELECT_FT_TABLES2=
+ SELECT a, b, c FROM ft_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_GM_TABLES=
+ DROP TABLE IF EXISTS gm_r, gm_r_2;
+let $CHILD2_1_CREATE_GM_TABLES=
+ CREATE TABLE gm_r (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
+let $CHILD2_1_SELECT_GM_TABLES=
+ SELECT a, b FROM gm_r ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c FROM gm_r_2 ORDER BY a;
+let $CHILD2_1_DROP_GM_TABLES2=
+ DROP TABLE IF EXISTS gm_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS gm_r2_2;
+let $CHILD2_1_CREATE_GM_TABLES2=
+ CREATE TABLE gm_r2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r2_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_1_GM_ENGINE $CHILD2_1_GM_CHARSET;
+let $CHILD2_1_SELECT_GM_TABLES2=
+ SELECT a, b FROM gm_r2 ORDER BY a
+ $STR_SEMICOLON
+ SELECT a, c FROM gm_r2_2 ORDER BY a;
+let $CHILD2_1_DROP_LOCK_TABLES1=
+ DROP TABLE IF EXISTS t1_1;
+let $CHILD2_1_CREATE_LOCK_TABLES1=
+ CREATE TABLE t1_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_DROP_LOCK_TABLES2=
+ DROP TABLE IF EXISTS t2_2;
+let $CHILD2_1_CREATE_LOCK_TABLES2=
+ CREATE TABLE t2_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_DROP_INCREMENT_TABLES1=
+ DROP TABLE IF EXISTS ai1_1;
+let $CHILD2_1_CREATE_INCREMENT_TABLES1=
+ CREATE TABLE ai1_1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_INCREMENT_TABLES1=
+ SELECT id FROM ai1_1 ORDER BY id;
+let $CHILD2_1_DROP_TEXT_PK_TABLES1=
+ DROP TABLE IF EXISTS t1;
+let $CHILD2_1_CREATE_TEXT_PK_TABLES1=
+ CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY (a)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET2;
+let $CHILD2_1_SELECT_TEXT_PK_TABLES1=
+ SELECT a FROM t1 ORDER BY a;
+let $CHILD2_1_DROP_TEXT_KEY_TABLES1=
+ DROP TABLE IF EXISTS t1;
+let $CHILD2_1_CREATE_TEXT_KEY_TABLES1=
+ CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+let $CHILD2_1_SELECT_TEXT_KEY_TABLES1=
+ SELECT a, b FROM t1 ORDER BY a, b;
+let $CHILD2_1_AUTO_INCREMENT_INCREMENT1=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_1_AUTO_INCREMENT_INCREMENT2=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 4;
+let $CHILD2_1_AUTO_INCREMENT_OFFSET1=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
+let $CHILD2_1_AUTO_INCREMENT_OFFSET2=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 2;
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child2_2.inc b/storage/vp/mysql-test/vp/spider/include/init_child2_2.inc
new file mode 100644
index 00000000000..8ea20e75942
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child2_2.inc
@@ -0,0 +1,105 @@
+let $CHILD2_2_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r3_2;
+let $CHILD2_2_CREATE_TABLES=
+ CREATE TABLE ta_r3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r3_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_SELECT_TABLES=
+ SELECT a, b FROM ta_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_TABLES5=
+ DROP TABLE IF EXISTS ta_r_int, ta_r_int_2;
+let $CHILD2_2_CREATE_TABLES5=
+ CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_FT_TABLES=
+ DROP TABLE IF EXISTS ft_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ft_r3_2;
+let $CHILD2_2_CREATE_FT_TABLES=
+ CREATE TABLE ft_r3 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+ ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET $STR_SEMICOLON
+ CREATE TABLE ft_r3_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $CHILD2_2_FT_ENGINE $CHILD2_2_FT_CHARSET;
+let $CHILD2_2_SELECT_FT_TABLES=
+ SELECT a, b, c FROM ft_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, c, d FROM ft_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_GM_TABLES=
+ DROP TABLE IF EXISTS gm_r3 $STR_SEMICOLON
+ DROP TABLE IF EXISTS gm_r3_2;
+let $CHILD2_2_CREATE_GM_TABLES=
+ CREATE TABLE gm_r3 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+ ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET $STR_SEMICOLON
+ CREATE TABLE gm_r3_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+ ) $CHILD2_2_GM_ENGINE $CHILD2_2_GM_CHARSET;
+let $CHILD2_2_SELECT_GM_TABLES=
+ SELECT a, b FROM gm_r3 ORDER BY a $STR_SEMICOLON
+ SELECT a, c FROM gm_r3_2 ORDER BY a;
+let $CHILD2_2_DROP_LOCK_TABLES1=
+ DROP TABLE IF EXISTS t1_2;
+let $CHILD2_2_CREATE_LOCK_TABLES1=
+ CREATE TABLE t1_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_LOCK_TABLES2=
+ DROP TABLE IF EXISTS t2_1;
+let $CHILD2_2_CREATE_LOCK_TABLES2=
+ CREATE TABLE t2_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_DROP_INCREMENT_TABLES1=
+ DROP TABLE IF EXISTS ai1_2;
+let $CHILD2_2_CREATE_INCREMENT_TABLES1=
+ CREATE TABLE ai1_2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
+let $CHILD2_2_SELECT_INCREMENT_TABLES1=
+ SELECT id FROM ai1_2 ORDER BY id;
+let $CHILD2_2_AUTO_INCREMENT_INCREMENT1=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 1;
+let $CHILD2_2_AUTO_INCREMENT_INCREMENT2=
+ SET GLOBAL AUTO_INCREMENT_INCREMENT = 4;
+let $CHILD2_2_AUTO_INCREMENT_OFFSET1=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 1;
+let $CHILD2_2_AUTO_INCREMENT_OFFSET2=
+ SET GLOBAL AUTO_INCREMENT_OFFSET = 3;
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child2_3.inc b/storage/vp/mysql-test/vp/spider/include/init_child2_3.inc
new file mode 100644
index 00000000000..95cb023df33
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child2_3.inc
@@ -0,0 +1,17 @@
+let $CHILD2_3_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r4 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r4_2;
+let $CHILD2_3_CREATE_TABLES=
+ CREATE TABLE ta_r4 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r4_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+ ) $CHILD2_3_ENGINE $CHILD2_3_CHARSET;
+let $CHILD2_3_SELECT_TABLES=
+ SELECT a, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r4 ORDER BY a $STR_SEMICOLON
+ SELECT a, b FROM ta_r4_2 ORDER BY a;
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child3_1.inc b/storage/vp/mysql-test/vp/spider/include/init_child3_1.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child3_1.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child3_2.inc b/storage/vp/mysql-test/vp/spider/include/init_child3_2.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child3_2.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/init_child3_3.inc b/storage/vp/mysql-test/vp/spider/include/init_child3_3.inc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_child3_3.inc
diff --git a/storage/vp/mysql-test/vp/spider/include/init_master_1.inc b/storage/vp/mysql-test/vp/spider/include/init_master_1.inc
new file mode 100644
index 00000000000..424832563ad
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_master_1.inc
@@ -0,0 +1,425 @@
+--source ../../include/init_vp.inc
+--source ../../../../../spider/mysql-test/spider/include/init_spider.inc
+SET spider_internal_sql_log_off= 0;
+SET spider_connect_timeout= 600;
+SET @optimizer_switch_backup = @@optimizer_switch;
+SET optimizer_switch = 'engine_condition_pushdown=on';
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r ta_r_2"';
+let $MASTER_1_COMMENT2_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_no_idx"';
+#let $MASTER_1_COMMENT_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r2 ta_r2_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ta_r2 ta_r2_2"'
+ PARTITION BY KEY(a) (
+ PARTITION pt1 COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 COMMENT='table_name_list "ta_r3 ta_r3_2"'
+ );
+#let $MASTER_1_COMMENT2_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r2 ta_r2_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT2_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ta_r2 ta_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "ta_r3 ta_r3_2"'
+ );
+let $MASTER_1_COMMENT3_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_auto_inc ta_r_auto_inc_2"';
+#let $MASTER_1_COMMENT3_P_2_1=
+# COMMENT='default_database "auto_test_remote"'
+# CONNECTION='table_name_list "ta_r_int ta_r_int_2"';
+#If you apply the patch, you can use table partitioning test.
+let $MASTER_1_COMMENT3_P_2_1=
+ CONNECTION='table_name_list "ta_r_int ta_r_int_2"'
+ PARTITION BY LIST(MOD(a, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT='default_database "auto_test_remote2"'
+ );
+let $MASTER_1_COMMENT4_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_int ta_r_int_2"';
+let $MASTER_1_COMMENT5_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ta_r_3"';
+let $MASTER_1_COMMENT_FT_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "ft_r ft_r_2"';
+let $MASTER_1_COMMENT2_FT_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "ft_r2 ft_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "ft_r3 ft_r3_2"'
+ );
+let $MASTER_1_COMMENT_GM_2_1=
+ COMMENT='default_database "auto_test_remote"'
+ CONNECTION='table_name_list "gm_r gm_r_2"';
+let $MASTER_1_COMMENT2_GM_P_2_1=
+ COMMENT='default_database "auto_test_remote2"'
+ CONNECTION='table_name_list "gm_r2 gm_r2_2"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (4)
+ COMMENT='default_database "auto_test_remote"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE
+ COMMENT='table_name_list "gm_r3 gm_r3_2"'
+ );
+let $MASTER_1_COMMENT_LOCK1=
+ COMMENT 'tnl "auto_test_remote.t1_1 auto_test_remote2.t1_2"';
+let $MASTER_1_COMMENT_LOCK2=
+ COMMENT 'tnl "auto_test_remote2.t2_1 auto_test_remote.t2_2"';
+let $MASTER_1_COMMENT_INCREMENT1_1=
+ COMMENT='tnl "ai1_1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_INCREMENT1_P_1=
+ PARTITION BY LIST(MOD(id, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='tnl "ai1_1", default_database "auto_test_remote"',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT='tnl "ai1_2", default_database "auto_test_remote2"'
+ );
+let $MASTER_1_COMMENT_READONLY1_1=
+ COMMENT='tnl "ro1_1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_ERROR_MODE1_1=
+ COMMENT 'tnl "em1_1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_TEXT_PK1_1=
+ COMMENT 'tnl "t1", default_database "auto_test_remote"';
+let $MASTER_1_COMMENT_TEXT_KEY1_1=
+ COMMENT 'tnl "t2", default_database "auto_test_remote"';
+let $MASTER_1_AUTO_INCREMENT_INCREMENT1=
+ SET SESSION AUTO_INCREMENT_INCREMENT = 1 $STR_SEMICOLON
+ SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '',
+ 'srv "s_2_1"') $STR_SEMICOLON
+ SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 1', '',
+ 'srv "s_2_2"');
+let $MASTER_1_AUTO_INCREMENT_INCREMENT2=
+ SET SESSION AUTO_INCREMENT_INCREMENT = 777 $STR_SEMICOLON
+ SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+ 'srv "s_2_1"') $STR_SEMICOLON
+ SELECT spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+ 'srv "s_2_2"');
+let $MASTER_1_AUTO_INCREMENT_OFFSET1=
+ SET SESSION AUTO_INCREMENT_OFFSET = 1 $STR_SEMICOLON
+ SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '',
+ 'srv "s_2_1"') $STR_SEMICOLON
+ SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 1', '',
+ 'srv "s_2_2"');
+let $MASTER_1_AUTO_INCREMENT_OFFSET2=
+ SET SESSION AUTO_INCREMENT_OFFSET = 777 $STR_SEMICOLON
+ SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
+ 'srv "s_2_1"') $STR_SEMICOLON
+ SELECT spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
+ 'srv "s_2_2"');
+let $MASTER_1_AUTO_INCREMENT_OFFSET3=
+ SET SESSION AUTO_INCREMENT_OFFSET = 1;
+let $MASTER_1_AUTO_INCREMENT_OFFSET4=
+ SET SESSION AUTO_INCREMENT_OFFSET = 777;
+if ($VERSION_COMPILE_OS_WIN)
+{
+ let $MASTER_1_HIDDEN_COMMENT_2_1=
+ COMMENT='database "auto_test_remote"'
+ CONNECTION='host "localhost", port "$CHILD2_1_MYPORT", user "root",
+ password ""';
+}
+if (!$VERSION_COMPILE_OS_WIN)
+{
+ let $MASTER_1_HIDDEN_COMMENT_2_1=
+ COMMENT='database "auto_test_remote"'
+ CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root",
+ password ""';
+}
+if ($VERSION_COMPILE_OS_WIN)
+{
+ let $MASTER_1_HIDDEN_COMMENT_2_2=
+ COMMENT='database "auto_test_remote2"'
+ CONNECTION='host "localhost", port "$CHILD2_2_MYPORT", user "root",
+ password ""';
+}
+if (!$VERSION_COMPILE_OS_WIN)
+{
+ let $MASTER_1_HIDDEN_COMMENT_2_2=
+ COMMENT='database "auto_test_remote2"'
+ CONNECTION='host "localhost", socket "$CHILD2_2_MYSOCK", user "root",
+ password ""';
+}
+let $MASTER_1_HIDDEN_COMMENT_INCREMENT_2_1=
+ COMMENT='aim "3", srv "s_2_1", bsz "0"';
+let $MASTER_1_HIDDEN_COMMENT_INCREMENT_2_2=
+ COMMENT='aim "3", srv "s_2_2", bsz "0"';
+let $MASTER_1_HIDDEN_COMMENT_READONLY_2_1=
+ COMMENT 'read_only_mode "1", tbl "ai1_1", srv "s_2_1"';
+let $MASTER_1_HIDDEN_COMMENT_ERROR_MODE_2_1=
+ COMMENT 'erm "1", ewm "1", tbl "ter1_1", srv "s_2_1"';
+let $MASTER_1_HIDDEN_COMMENT_TEXT_PK_2_1=
+ COMMENT='srv "s_2_1", tbl "t1"';
+let $MASTER_1_HIDDEN_COMMENT_TEXT_KEY_2_1=
+ COMMENT='srv "s_2_1", tbl "t1"';
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE ta_r (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a),
+ KEY idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r2_2 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_no_idx (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_auto_inc_2 (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ta_r_3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a, b, c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ft_r (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ft_r_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ft_r2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ft_r2_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE gm_r (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE gm_r_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE gm_r2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE gm_r2_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE t1_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE t2_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_1;
+eval CREATE TABLE ai1_1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_INCREMENT_2_1;
+eval CREATE TABLE ro1_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_READONLY_2_1;
+eval CREATE TABLE em1_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_ERROR_MODE_2_1;
+eval CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY (a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET2
+ $MASTER_1_HIDDEN_COMMENT_TEXT_PK_2_1;
+eval CREATE TABLE t2 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_TEXT_KEY_2_1;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+eval CREATE TABLE ta_r3 (
+ a INT DEFAULT 10,
+ b CHAR(1) DEFAULT 'c',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ta_r3_2 (
+ a INT DEFAULT 10,
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ft_r3 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ft_r3_2 (
+ a INT DEFAULT 0,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE gm_r3 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE gm_r3_2 (
+ a INT DEFAULT 0,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ta_r_int (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx2(c)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ta_r_int_2 (
+ a INT AUTO_INCREMENT,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ PRIMARY KEY(a),
+ KEY idx1(b)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE t1_2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE t2_1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_2_2;
+eval CREATE TABLE ai1_2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_HIDDEN_ENGINE $MASTER_1_HIDDEN_CHARSET
+ $MASTER_1_HIDDEN_COMMENT_INCREMENT_2_2;
+let $MASTER_1_CHECK_DIRECT_UPDATE_STATUS=
+ SHOW STATUS LIKE 'Spider_direct_update';
+let $MASTER_1_CHECK_DIRECT_DELETE_STATUS=
+ SHOW STATUS LIKE 'Spider_direct_delete';
+let $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS=
+ SHOW STATUS LIKE 'Spider_direct_order_limit';
+let $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS=
+ SHOW STATUS LIKE 'Spider_direct_aggregate';
diff --git a/storage/vp/mysql-test/vp/spider/include/init_slave1_1.inc b/storage/vp/mysql-test/vp/spider/include/init_slave1_1.inc
new file mode 100644
index 00000000000..73c3c6b9ef2
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/init_slave1_1.inc
@@ -0,0 +1,10 @@
+let $SLAVE1_1_COMMENT_INCREMENT1_1=
+ COMMENT '';
+let $SLAVE1_1_COMMENT_INCREMENT1_P_1=
+ COMMENT ''
+ PARTITION BY LIST(MOD(id, 2)) (
+ PARTITION pt1 VALUES IN (0)
+ COMMENT='',
+ PARTITION pt2 VALUES IN (1)
+ COMMENT=''
+ );
diff --git a/storage/vp/mysql-test/vp/spider/include/item_insert_value_deinit.inc b/storage/vp/mysql-test/vp/spider/include/item_insert_value_deinit.inc
new file mode 100644
index 00000000000..a7b61d7c001
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/item_insert_value_deinit.inc
@@ -0,0 +1,18 @@
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+--connection child2_1
+DROP DATABASE IF EXISTS auto_test_remote1;
+DROP DATABASE IF EXISTS auto_test_remote10;
+--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
+--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/vp/mysql-test/vp/spider/include/item_insert_value_init.inc b/storage/vp/mysql-test/vp/spider/include/item_insert_value_init.inc
new file mode 100644
index 00000000000..6e8a382d80b
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/include/item_insert_value_init.inc
@@ -0,0 +1,73 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../t/test_init.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+
+--connection child2_1
+--disable_warnings
+DROP DATABASE IF EXISTS auto_test_remote1;
+CREATE DATABASE auto_test_remote1;
+DROP DATABASE IF EXISTS auto_test_remote10;
+CREATE DATABASE auto_test_remote10;
+--enable_warnings
+
+--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='table_name_list "tbl_1 tbl_4", pk_correspond_mode "1"';
+let $VP_CHARSET=
+ DEFAULT CHARSET=utf8;
+--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS `auto_test_remote1`.`tbl_a` $STR_SEMICOLON
+ DROP TABLE IF EXISTS `auto_test_remote10`.`tbl_a`;
+--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE `auto_test_remote1`.`tbl_a` (
+ `id` bigint(20) NOT NULL,
+ `id_2` bigint(20) NOT NULL,
+ `id_3` bigint(20) NOT NULL,
+ `id_4` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+ ) $CHILD2_1_ENGINE $VP_CHARSET $STR_SEMICOLON
+ CREATE TABLE `auto_test_remote10`.`tbl_a` (
+ `id` bigint(20) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) $CHILD2_1_ENGINE $VP_CHARSET;
+--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
+let $CHILD2_1_SELECT_TABLES=
+ SELECT id FROM `auto_test_remote1`.`tbl_a` ORDER BY id $STR_SEMICOLON
+ SELECT id FROM `auto_test_remote10`.`tbl_a` ORDER BY id;
+let $CHILD2_1_SELECT_ARGUMENT1=
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+--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
+--disable_warnings
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+--enable_warnings
+
+let $VP_HIDDEN_COMMENT_2_1=
+ COMMENT='srv "s_2_1", table "tbl_a", database "auto_test_remote1"';
+let $VP_HIDDEN_COMMENT_4_1=
+ COMMENT='srv "s_2_1", table "tbl_a", database "auto_test_remote10"';
+
+eval CREATE TABLE `tbl_1` (
+ `id` bigint(20) NOT NULL,
+ `id_2` bigint(20) NOT NULL,
+ `id_3` bigint(20) NOT NULL,
+ `id_4` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) $MASTER_1_HIDDEN_ENGINE $VP_CHARSET $VP_HIDDEN_COMMENT_2_1;
+
+eval CREATE TABLE `tbl_4` (
+ `id` bigint(20) NOT NULL,
+ PRIMARY KEY (`id`)
+) $MASTER_1_HIDDEN_ENGINE $VP_CHARSET $VP_HIDDEN_COMMENT_4_1;
diff --git a/storage/vp/mysql-test/vp/spider/my.cnf b/storage/vp/mysql-test/vp/spider/my.cnf
new file mode 100644
index 00000000000..0ca337c8546
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/my.cnf
@@ -0,0 +1,147 @@
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld.1.1]
+loose_handlersocket_port= 20000
+loose_handlersocket_port_wr= 20001
+loose_handlersocket_threads= 2
+loose_handlersocket_threads_wr= 1
+loose_handlersocket_support_merge_table= 1
+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
+
+[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= 1
+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
+
+[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= 1
+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
+
+[mysqld.2.3]
+
+[mysqld.3.1]
+
+[mysqld.3.2]
+
+[mysqld.3.3]
+
+[mysqld.4.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= VP
+MASTER_1_ENGINE= ENGINE=VP
+MASTER_1_CHARSET= DEFAULT CHARSET=utf8
+MASTER_1_MERGE= 1
+MASTER_1_NEEDPK= 1
+MASTER_1_ENGINE2= ENGINE=MyISAM
+MASTER_1_CHARSET2= DEFAULT CHARSET=utf8
+MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+MASTER_1_HIDDEN_ENGINE_TYPE= Spider
+MASTER_1_HIDDEN_ENGINE= ENGINE=Spider
+MASTER_1_HIDDEN_CHARSET= DEFAULT CHARSET=utf8
+MASTER_1_HIDDEN_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
+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
+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_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_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
+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_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_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
+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
+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
+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
+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
+
+STR_SEMICOLON= ;
diff --git a/storage/vp/mysql-test/vp/spider/r/basic_sql.result b/storage/vp/mysql-test/vp/spider/r/basic_sql.result
new file mode 100644
index 00000000000..c13854ec323
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/basic_sql.result
@@ -0,0 +1,742 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+create table ignore select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'f', '2008-07-01 10:21:39'),
+(2, 'g', '2000-02-01 00:00:00'),
+(3, 'j', '2007-05-04 20:03:11'),
+(4, 'i', '2003-10-30 05:01:03'),
+(5, 'h', '2001-10-31 23:59:59');
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+IGNORE SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
+Warning 1062 Duplicate entry '2' for key 'PRIMARY'
+Warning 1062 Duplicate entry '3' for key 'PRIMARY'
+Warning 1062 Duplicate entry '4' for key 'PRIMARY'
+Warning 1062 Duplicate entry '5' for key 'PRIMARY'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+create table ignore select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+REPLACE SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+create no index table
+connection master_1;
+DROP TABLE IF EXISTS ta_l_no_idx;
+CREATE TABLE ta_l_no_idx
+MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1
+SELECT a, b, c FROM tb_l
+ERROR 42000: This table type requires a primary key
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table shared mode
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table for update
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+FOR UPDATE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table join
+connection master_1;
+SELECT a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b
+WHERE a.a = b.a ORDER BY a.a;
+a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select table straight_join
+connection master_1;
+SELECT STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')
+FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a;
+a b date_format(b.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_small_result
+connection master_1;
+SELECT SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_big_result
+connection master_1;
+SELECT SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_buffer_result
+connection master_1;
+SELECT SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_cache
+connection master_1;
+SELECT SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_no_cache
+connection master_1;
+SELECT SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select sql_calc_found_rows
+connection master_1;
+SELECT SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a LIMIT 4;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+connection master_1;
+SELECT found_rows();
+found_rows()
+5
+
+select high_priority
+connection master_1;
+SELECT HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select distinct
+connection master_1;
+SELECT DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select count
+connection master_1;
+SELECT count(*) FROM ta_l ORDER BY a;
+count(*)
+5
+
+select table join not use index
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
+EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select using pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+select using index and pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+insert
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert select
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+insert select a
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+
+insert low_priority
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert high_priority
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e',
+'2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert ignore
+connection master_1;
+INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01');
+Warnings:
+Warning 1062 Duplicate entry '2' for key 'PRIMARY'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert update (insert)
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+
+insert update (update)
+connection master_1;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 f 2005-08-08 11:11:11
+
+replace
+connection master_1;
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 f 2008-02-02 02:02:02
+
+replace select
+connection master_1;
+REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+replace select a
+connection master_1;
+REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+replace low_priority
+connection master_1;
+REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g',
+'2009-03-03 03:03:03');
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 g 2000-02-01 00:00:00
+3 g 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+update
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59');
+connection master_1;
+UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+2 f 2008-02-02 02:02:02
+
+update select
+connection master_1;
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM
+tb_l);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+update select a
+connection master_1;
+UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM
+tb_l ORDER BY a LIMIT 1);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 h 2010-04-04 04:04:04
+2 g 2009-03-03 03:03:03
+
+update join
+connection master_1;
+UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+
+update join a
+connection master_1;
+UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE
+a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+update low_priority
+connection master_1;
+UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 f 2008-02-02 02:02:02
+
+update ignore
+connection master_1;
+UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 f 2008-02-02 02:02:02
+
+update pushdown
+connection master_1;
+update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 j 2009-03-03 03:03:03
+
+update index pushdown
+connection master_1;
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 g 2009-03-03 03:03:03
+2 g 2009-03-03 03:03:03
+
+delete
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete all
+connection master_1;
+DELETE FROM ta_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+
+delete select
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete select a
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete join
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete low_priority
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE LOW_PRIORITY FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete ignore
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE IGNORE FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete quick
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE QUICK FROM ta_l WHERE a = 2;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 e 2008-01-01 23:59:59
+3 e 2008-01-01 23:59:59
+4 e 2008-01-01 23:59:59
+5 e 2008-01-01 23:59:59
+6 e 2008-01-01 23:59:59
+7 e 2008-01-01 23:59:59
+8 e 2008-01-01 23:59:59
+9 e 2008-01-01 23:59:59
+10 j 2008-01-01 23:59:59
+
+delete pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+10 j 2008-01-01 23:59:59
+
+delete index pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+connection master_1;
+DELETE FROM ta_l WHERE a > 0 AND b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+10 j 2008-01-01 23:59:59
+
+truncate
+connection master_1;
+TRUNCATE TABLE ta_l;
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/basic_sql_part.result b/storage/vp/mysql-test/vp/spider/r/basic_sql_part.result
new file mode 100644
index 00000000000..4c8648024ea
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/basic_sql_part.result
@@ -0,0 +1,142 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'f', '2008-07-01 10:21:39'),
+(2, 'g', '2000-02-01 00:00:00'),
+(3, 'j', '2007-05-04 20:03:11'),
+(4, 'i', '2003-10-30 05:01:03'),
+(5, 'h', '2001-10-31 23:59:59');
+
+create table with partition and select test
+connection master_1;
+CREATE TABLE ta_l2 (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+SELECT a, b, c FROM tb_l
+ERROR HY000: 'auto_test_local.ta_l2' is not of type 'BASE TABLE'
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+select partition using pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+select partition using index pushdown
+connection master_1;
+SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+a b date_format(a.c, '%Y-%m-%d %H:%i:%s')
+2 g 2000-02-01 00:00:00
+
+update partition pushdown
+connection master_1;
+UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 e 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+update partition index pushdown
+connection master_1;
+UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+2 g 2000-02-01 00:00:00
+3 j 2009-03-03 03:03:03
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+delete partition pushdown
+TRUNCATE TABLE ta_l2;
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+connection master_1;
+DELETE FROM ta_l2 WHERE b = 'g';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+delete partition index pushdown
+TRUNCATE TABLE ta_l2;
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+connection master_1;
+DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 f 2008-07-01 10:21:39
+3 j 2007-05-04 20:03:11
+4 i 2003-10-30 05:01:03
+5 h 2001-10-31 23:59:59
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/direct_aggregate.result b/storage/vp/mysql-test/vp/spider/r/direct_aggregate.result
new file mode 100644
index 00000000000..af06349c65a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/direct_aggregate.result
@@ -0,0 +1,100 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+direct_aggregating test
+connection master_1;
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 0
+SELECT COUNT(*) FROM ta_l;
+COUNT(*)
+5
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 1
+SELECT MAX(a) FROM ta_l;
+MAX(a)
+5
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 2
+SELECT MIN(a) FROM ta_l;
+MIN(a)
+1
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 3
+SELECT MAX(a) FROM ta_l WHERE a < 5;
+MAX(a)
+4
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 4
+SELECT MIN(a) FROM ta_l WHERE a > 1;
+MIN(a)
+2
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 5
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/direct_aggregate_part.result b/storage/vp/mysql-test/vp/spider/r/direct_aggregate_part.result
new file mode 100644
index 00000000000..02cdc033a88
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/direct_aggregate_part.result
@@ -0,0 +1,90 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 0
+SELECT COUNT(*) FROM ta_l2;
+COUNT(*)
+5
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 2
+SELECT MAX(a) FROM ta_l2;
+MAX(a)
+5
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 4
+SELECT MIN(a) FROM ta_l2;
+MIN(a)
+1
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 6
+SELECT MAX(a) FROM ta_l2 WHERE a < 5;
+MAX(a)
+4
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 8
+SELECT MIN(a) FROM ta_l2 WHERE a > 1;
+MIN(a)
+2
+SHOW STATUS LIKE 'Spider_direct_aggregate';
+Variable_name Value
+Spider_direct_aggregate 10
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/direct_update.result b/storage/vp/mysql-test/vp/spider/r/direct_update.result
new file mode 100644
index 00000000000..91a388209e9
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/direct_update.result
@@ -0,0 +1,155 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+direct_updating test
+connection master_1;
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+update all rows with function
+UPDATE ta_l SET c = ADDDATE(c, 1);
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 e 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key
+UPDATE ta_l SET b = 'x' WHERE a = 3;
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 2
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by a column without index
+UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 2
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-17 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key with order and limit
+UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 2
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by primary key with order and limit
+DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by a column without index
+DELETE FROM ta_l WHERE b = 'c';
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+delete by primary key
+DELETE FROM ta_l WHERE a = 3;
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 3
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+4 d 2003-12-01 05:01:03
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/direct_update_part.result b/storage/vp/mysql-test/vp/spider/r/direct_update_part.result
new file mode 100644
index 00000000000..6ef190546db
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/direct_update_part.result
@@ -0,0 +1,145 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+update all rows with function
+UPDATE ta_l2 SET c = ADDDATE(c, 1);
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 2
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 e 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key
+UPDATE ta_l2 SET b = 'x' WHERE a = 3;
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 3
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2007-06-05 20:03:11
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by a column without index
+UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 3
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-17 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+update by primary key with order and limit
+UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 3
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+2 b 2000-01-02 00:00:00
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by primary key with order and limit
+DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+5 c 2002-01-01 23:59:59
+delete by a column without index
+DELETE FROM ta_l2 WHERE b = 'c';
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+3 x 2011-10-18 00:00:00
+4 d 2003-12-01 05:01:03
+delete by primary key
+DELETE FROM ta_l2 WHERE a = 3;
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 3
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-02 10:21:39
+4 d 2003-12-01 05:01:03
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/fulltext.result b/storage/vp/mysql-test/vp/spider/r/fulltext.result
new file mode 100644
index 00000000000..abf7c6a76ad
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/fulltext.result
@@ -0,0 +1,76 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS ft_l;
+CREATE TABLE ft_l (
+a INT DEFAULT 0,
+b TEXT,
+c TEXT,
+d TEXT,
+PRIMARY KEY(a),
+FULLTEXT INDEX ft_idx1(b),
+FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_FT_2_1
+INSERT INTO ft_l (a,b,c,d) VALUES
+(1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+(2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+(3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+(4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+(5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+
+fulltext search
+connection master_1;
+select a, b, c, d from ft_l where match(b) against('fedc');
+a b c d
+3 cccc cdef fedc dddd defg gfed eeee efgh hgfe
+select a, b, c, d from ft_l where match(c) against('hgfe');
+a b c d
+4 dddd defg gfed eeee efgh hgfe ffff fghi ihgf
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/fulltext_part.result b/storage/vp/mysql-test/vp/spider/r/fulltext_part.result
new file mode 100644
index 00000000000..ea60aaa1e13
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/fulltext_part.result
@@ -0,0 +1,65 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE ft_l2 (
+a INT DEFAULT 0,
+b TEXT,
+c TEXT,
+d TEXT,
+PRIMARY KEY(a),
+FULLTEXT INDEX ft_idx1(b),
+FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_FT_P_2_1
+select a, b, c, d from ft_l2 where match(b) against('fedc');
+a b c d
+3 cccc cdef fedc dddd defg gfed eeee efgh hgfe
+select a, b, c, d from ft_l2 where match(c) against('hgfe');
+a b c d
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/function.result b/storage/vp/mysql-test/vp/spider/r/function.result
new file mode 100644
index 00000000000..c088a8a9541
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/function.result
@@ -0,0 +1,160 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+in()
+connection master_1;
+CREATE TABLE t1 (
+a VARCHAR(255),
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1
+insert into t1 values ('1');
+insert into t1 select a + 1 from t1;
+insert into t1 select a + 2 from t1;
+insert into t1 select a + 4 from t1;
+insert into t1 select a + 8 from t1;
+insert into t1 select a + 16 from t1;
+insert into t1 select a + 32 from t1;
+insert into t1 select a + 64 from t1;
+insert into t1 select a + 128 from t1;
+insert into t1 select a + 256 from t1;
+insert into t1 select a + 512 from t1;
+flush tables;
+connection master_1;
+select a from t1 where a in ('15', '120');
+a
+120
+15
+
+date_sub()
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-08-01 10:21:39
+2 b 1999-01-01 00:00:00
+3 e 2006-06-04 20:03:11
+4 d 2002-11-30 05:01:03
+5 c 2000-12-31 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-11-01 10:21:39
+2 b 1999-04-01 00:00:00
+3 e 2006-09-04 20:03:11
+4 d 2003-02-28 05:01:03
+5 c 2001-03-31 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-01 10:21:39
+2 b 1999-03-01 00:00:00
+3 e 2006-08-04 20:03:11
+4 d 2003-01-28 05:01:03
+5 c 2001-02-28 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-08 10:21:39
+2 b 1999-03-08 00:00:00
+3 e 2006-08-11 20:03:11
+4 d 2003-02-04 05:01:03
+5 c 2001-03-07 23:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 10:21:39
+2 b 1999-03-07 00:00:00
+3 e 2006-08-10 20:03:11
+4 d 2003-02-03 05:01:03
+5 c 2001-03-06 23:59:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:21:39
+2 b 1999-03-07 01:00:00
+3 e 2006-08-10 21:03:11
+4 d 2003-02-03 06:01:03
+5 c 2001-03-07 00:59:59
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:20:39
+2 b 1999-03-07 00:59:00
+3 e 2006-08-10 21:02:11
+4 d 2003-02-03 06:00:03
+5 c 2001-03-07 00:58:59
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2007-10-07 11:20:40
+2 b 1999-03-07 00:59:01
+3 e 2006-08-10 21:02:12
+4 d 2003-02-03 06:00:04
+5 c 2001-03-07 00:59:00
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/geometry.result b/storage/vp/mysql-test/vp/spider/r/geometry.result
new file mode 100644
index 00000000000..4c77d787f91
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/geometry.result
@@ -0,0 +1,109 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS gm_l;
+CREATE TABLE gm_l (
+a INT DEFAULT 0,
+b GEOMETRY NOT NULL,
+c GEOMETRY NOT NULL,
+PRIMARY KEY(a),
+SPATIAL INDEX sp_idx1(b),
+SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+geometry search
+connection master_1;
+SELECT AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+AsText(b)
+POINT(40000 15000)
+POINT(40000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+AsText(c)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(80000 15000)
+POINT(80000 16000)
+POINT(70000 16000)
+POINT(60000 15000)
+POINT(60000 16000)
+POINT(50000 15000)
+POINT(50000 16000)
+POINT(40000 15000)
+POINT(40000 16000)
+POINT(30000 15000)
+POINT(30000 16000)
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/geometry_part.result b/storage/vp/mysql-test/vp/spider/r/geometry_part.result
new file mode 100644
index 00000000000..83bbbe9a367
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/geometry_part.result
@@ -0,0 +1,92 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+with partition test
+connection master_1;
+CREATE TABLE gm_l2 (
+a INT DEFAULT 0,
+b GEOMETRY NOT NULL,
+c GEOMETRY NOT NULL,
+PRIMARY KEY(a),
+SPATIAL INDEX sp_idx1(b),
+SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_GM_P_2_1
+SELECT AsText(b) FROM gm_l2 WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+AsText(b)
+POINT(40000 15000)
+POINT(40000 16000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+AsText(c)
+POINT(40000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(80000 15000)
+POINT(80000 16000)
+POINT(70000 16000)
+POINT(60000 15000)
+POINT(60000 16000)
+POINT(50000 15000)
+POINT(50000 16000)
+POINT(40000 15000)
+POINT(40000 16000)
+POINT(30000 15000)
+POINT(30000 16000)
+SELECT AsText(c) FROM gm_l2 WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+POINT(70000 15000)
+SELECT AsText(c) FROM gm_l2 WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+SELECT AsText(c) FROM gm_l2 WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+AsText(c)
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/ha.result b/storage/vp/mysql-test/vp/spider/r/ha.result
new file mode 100644
index 00000000000..2dc3eecf7eb
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/ha.result
@@ -0,0 +1,510 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+connection child2_3;
+DROP DATABASE IF EXISTS auto_test_remote3;
+CREATE DATABASE auto_test_remote3;
+USE auto_test_remote3;
+connection child3_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child3_2;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child3_3;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+select test
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+fail-over test
+connection master_1;
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 0
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+ERROR HY000: Table 'auto_test_remote2.ta_r3_2' get a problem
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 3
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+db_name table_name link_id
+auto_test_remote ha_r_2 1
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 1
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+6 e 2011-05-05 20:04:05
+
+recovery test
+connection master_1;
+ALTER TABLE auto_test_remote.ha_r_2
+COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 2"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 2
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT spider_copy_tables('auto_test_remote.ha_r_2', '0', '1');
+spider_copy_tables('auto_test_remote.ha_r_2', '0', '1')
+1
+connection master_1;
+ALTER TABLE auto_test_remote.ha_r_2
+COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "0 1"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+INSERT INTO ta_l (a, b, c) VALUES
+(8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+6 e 2011-05-05 20:04:05
+8 g 2011-05-05 21:33:30
+DROP TABLE ta_l;
+connection master_1;
+SELECT spider_flush_table_mon_cache();
+spider_flush_table_mon_cache()
+1
+
+active standby test
+create table test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+select test
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+fail-over test
+connection master_1;
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 1
+Spider_mon_table_cache_version_req 2
+INSERT INTO ta_l (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+ERROR HY000: Table 'auto_test_remote.ta_r_2' get a problem
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 3
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+db_name table_name link_id
+auto_test_remote ha_r_2 1
+auto_test_remote as_r_2 0
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 2
+Spider_mon_table_cache_version_req 2
+INSERT INTO ta_l (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+6 e 2011-05-05 20:04:05
+
+recovery test
+connection master_1;
+ALTER TABLE auto_test_remote.as_r_2
+COMMENT='srv "s_2_1 s_2_2", tbl "ta_r_2 ta_r3_2", lst "1 0"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+INSERT INTO ta_l (a, b, c) VALUES
+(8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+8 g 2011-05-05 21:33:30
+DROP TABLE ta_l;
+connection master_1;
+SELECT spider_flush_table_mon_cache();
+spider_flush_table_mon_cache()
+1
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+connection child2_3;
+DROP DATABASE IF EXISTS auto_test_remote3;
+connection child3_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child3_2;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child3_3;
+DROP DATABASE IF EXISTS auto_test_local;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/ha_part.result b/storage/vp/mysql-test/vp/spider/r/ha_part.result
new file mode 100644
index 00000000000..b6f0885cbb5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/ha_part.result
@@ -0,0 +1,511 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+connection child2_3;
+DROP DATABASE IF EXISTS auto_test_remote3;
+CREATE DATABASE auto_test_remote3;
+USE auto_test_remote3;
+connection child3_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child3_2;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child3_3;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table with partition test
+connection master_1;
+DROP TABLE IF EXISTS ta_l2;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+select test
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+fail-over test
+connection master_1;
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 0
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+ERROR HY000: Table 'auto_test_remote3.ta_r4_2' get a problem
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 3
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+db_name table_name link_id
+auto_test_remote ha_r2_2 1
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 1
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+6 e 2011-05-05 20:04:05
+
+recovery test
+connection master_1;
+ALTER TABLE auto_test_remote.ha_r2_2
+COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 2"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 2
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT spider_copy_tables('auto_test_remote.ha_r2_2', '0', '1');
+spider_copy_tables('auto_test_remote.ha_r2_2', '0', '1')
+1
+connection master_1;
+ALTER TABLE auto_test_remote.ha_r2_2
+COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "0 1"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(8, 'g', '2011-05-05 21:33:30'),
+(9, 'h', '2011-05-05 22:32:10');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+6 e 2011-05-05 20:04:05
+8 g 2011-05-05 21:33:30
+9 h 2011-05-05 22:32:10
+DROP TABLE ta_l2;
+
+create table with partition test
+connection master_1;
+DROP TABLE IF EXISTS ta_l2;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+select test
+connection master_1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+fail-over test
+connection master_1;
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 1
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+ERROR HY000: Table 'auto_test_remote.ta_r2_2' get a problem
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 3
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+SELECT db_name, table_name, link_id FROM mysql.spider_link_failed_log;
+db_name table_name link_id
+auto_test_remote ha_r2_2 1
+auto_test_remote as_r2_2 0
+SHOW STATUS LIKE 'Spider_mon_table_cache_version%';
+Variable_name Value
+Spider_mon_table_cache_version 1
+Spider_mon_table_cache_version_req 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+3 e 2007-06-04 20:03:11
+5 c 2001-12-31 23:59:59
+6 e 2011-05-05 20:04:05
+
+recovery test
+connection master_1;
+ALTER TABLE auto_test_remote.as_r2_2
+COMMENT='srv "s_2_1 s_2_3", tbl "ta_r2_2 ta_r4_2", lst "1 0"';
+SELECT db_name, table_name, link_id, link_status FROM mysql.spider_tables
+ORDER BY db_name, table_name, link_id;
+db_name table_name link_id link_status
+auto_test_remote ai1_1 0 1
+auto_test_remote as_r 0 1
+auto_test_remote as_r 1 1
+auto_test_remote as_r2 0 1
+auto_test_remote as_r2 1 1
+auto_test_remote as_r2_2 0 1
+auto_test_remote as_r2_2 1 1
+auto_test_remote as_r_2 0 1
+auto_test_remote as_r_2 1 1
+auto_test_remote em1_1 0 1
+auto_test_remote ft_r 0 1
+auto_test_remote ft_r2 0 1
+auto_test_remote ft_r2_2 0 1
+auto_test_remote ft_r_2 0 1
+auto_test_remote gm_r 0 1
+auto_test_remote gm_r2 0 1
+auto_test_remote gm_r2_2 0 1
+auto_test_remote gm_r_2 0 1
+auto_test_remote ha_r 0 1
+auto_test_remote ha_r 1 1
+auto_test_remote ha_r2 0 1
+auto_test_remote ha_r2 1 1
+auto_test_remote ha_r2_2 0 1
+auto_test_remote ha_r2_2 1 1
+auto_test_remote ha_r_2 0 1
+auto_test_remote ha_r_2 1 1
+auto_test_remote ro1_1 0 1
+auto_test_remote t1 0 1
+auto_test_remote t1_1 0 1
+auto_test_remote t2 0 1
+auto_test_remote t2_2 0 1
+auto_test_remote ta_r 0 1
+auto_test_remote ta_r2 0 1
+auto_test_remote ta_r2_2 0 1
+auto_test_remote ta_r_2 0 1
+auto_test_remote ta_r_3 0 1
+auto_test_remote ta_r_auto_inc 0 1
+auto_test_remote ta_r_auto_inc_2 0 1
+auto_test_remote ta_r_int 0 1
+auto_test_remote ta_r_int_2 0 1
+auto_test_remote ta_r_no_idx 0 1
+auto_test_remote2 ai1_2 0 1
+auto_test_remote2 ft_r3 0 1
+auto_test_remote2 ft_r3_2 0 1
+auto_test_remote2 gm_r3 0 1
+auto_test_remote2 gm_r3_2 0 1
+auto_test_remote2 t1_2 0 1
+auto_test_remote2 t2_1 0 1
+auto_test_remote2 ta_r3 0 1
+auto_test_remote2 ta_r3_2 0 1
+auto_test_remote2 ta_r_int 0 1
+auto_test_remote2 ta_r_int_2 0 1
+INSERT INTO ta_l2 (a, b, c) VALUES
+(8, 'g', '2011-05-05 21:33:30'),
+(9, 'h', '2011-05-05 22:32:10');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+3 e 2007-06-04 20:03:11
+5 c 2001-12-31 23:59:59
+8 g 2011-05-05 21:33:30
+9 h 2011-05-05 22:32:10
+DROP TABLE ta_l2;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+connection child2_3;
+DROP DATABASE IF EXISTS auto_test_remote3;
+connection child3_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child3_2;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child3_3;
+DROP DATABASE IF EXISTS auto_test_local;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/handler.result b/storage/vp/mysql-test/vp/spider/r/handler.result
new file mode 100644
index 00000000000..4c268b57396
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/handler.result
@@ -0,0 +1,128 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table select test
+connection master_1;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+handler test
+connection master_1;
+HANDLER ta_l OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+1 a 2008-08-01 10:21:39
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+HANDLER a READ FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ FIRST WHERE b = 'c';
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a CLOSE;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/handler_part.result b/storage/vp/mysql-test/vp/spider/r/handler_part.result
new file mode 100644
index 00000000000..5ecb0f46e4f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/handler_part.result
@@ -0,0 +1,118 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+handler with partition test
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+HANDLER ta_l2 OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+a b c
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+1 a 2008-08-01 10:21:39
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+HANDLER a READ FIRST LIMIT 2;
+a b c
+1 a 2008-08-01 10:21:39
+3 e 2007-06-04 20:03:11
+HANDLER a READ NEXT LIMIT 2;
+a b c
+5 c 2001-12-31 23:59:59
+2 b 2000-01-01 00:00:00
+HANDLER a READ NEXT LIMIT 2;
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+a b c
+4 d 2003-11-30 05:01:03
+HANDLER a READ FIRST WHERE b = 'c';
+a b c
+5 c 2001-12-31 23:59:59
+HANDLER a CLOSE;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/handlersocket.result b/storage/vp/mysql-test/vp/spider/r/handlersocket.result
new file mode 100644
index 00000000000..bb48aaf03b4
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/handlersocket.result
@@ -0,0 +1,141 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+
+drop and create databases
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+SELECT 1;
+1
+1
+
+handlersocket insert test
+DROP TABLE IF EXISTS hs_l;
+CREATE TABLE hs_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+d INT,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_HS_COMMENT_2_1
+CREATE TEMPORARY TABLE tmp_hs (
+a INT,
+b CHAR(1),
+c DATETIME,
+d INT,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_HS_COMMENT_TMP
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t+\t4\t1\ta\t2008-08-01 10:21:39\t101','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT spider_direct_sql('1\t+\t4\t1\ta\t2008-08-01 10:21:39\t101','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT spider_direct_sql('1\t+\t4\t2\tb\t2000-01-01 00:00:00\t102\n1\t+\t4\t3\te\t2007-06-04 20:03:11\t103\n1\t+\t4\t4\td\t2003-11-30 05:01:03\t104\n1\t+\t4\t5\tc\t2001-12-31 23:59:59\t105','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+
+handlersocket select test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t2\t100000\t0','tmp_hs', 'host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0','tmp_hs', 'host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM tmp_hs ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+2 b 2000-01-01 00:00:00 102
+3 e 2007-06-04 20:03:11 103
+
+handlersocket update test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tU\t3\tq\t2011-09-06 19:40:00\t4','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tU\t3\tq\t2011-09-06 19:40:00\t4','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 4
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket increment test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t+\t0\t0\t0\t51','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t+\t0\t0\t0\t51','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 55
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket decrement test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t-\t0\t0\t0\t32','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t-\t0\t0\t0\t32','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 23
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket delete test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tD','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tD','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+deinit
+DROP DATABASE IF EXISTS auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/handlersocket_part.result b/storage/vp/mysql-test/vp/spider/r/handlersocket_part.result
new file mode 100644
index 00000000000..7548023beae
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/handlersocket_part.result
@@ -0,0 +1,141 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+
+drop and create databases
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+SELECT 1;
+1
+1
+CREATE TEMPORARY TABLE tmp_hs (
+a INT,
+b CHAR(1),
+c DATETIME,
+d INT,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET MASTER_1_HS_COMMENT_TMP
+
+handler with partition test
+CREATE TABLE hs_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+d INT,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_HS_COMMENT_P_2_1
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t+\t4\t1\ta\t2008-08-01 10:21:39\t101','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT spider_direct_sql('1\t+\t4\t1\ta\t2008-08-01 10:21:39\t101','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT spider_direct_sql('1\t+\t4\t2\tb\t2000-01-01 00:00:00\t102\n1\t+\t4\t3\te\t2007-06-04 20:03:11\t103\n1\t+\t4\t4\td\t2003-11-30 05:01:03\t104\n1\t+\t4\t5\tc\t2001-12-31 23:59:59\t105','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+
+handlersocket select test
+TRUNCATE tmp_hs;
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t2\t100000\t0','tmp_hs', 'host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0','tmp_hs', 'host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM tmp_hs ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+2 b 2000-01-01 00:00:00 102
+3 e 2007-06-04 20:03:11 103
+
+handlersocket update test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tU\t3\tq\t2011-09-06 19:40:00\t4','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tU\t3\tq\t2011-09-06 19:40:00\t4','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l2 ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 4
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket increment test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t+\t0\t0\t0\t51','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t+\t0\t0\t0\t51','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l2 ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 55
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket decrement test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t-\t0\t0\t0\t32','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\t-\t0\t0\t0\t32','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_update';
+Variable_name Value
+Spider_direct_update 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l2 ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+3 q 2011-09-06 19:40:00 23
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+handlersocket delete test
+SELECT spider_direct_sql('P\t1\tauto_test_local\ths_l2\tPRIMARY\ta,b,c,d','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tD','','host "localhost", port "MASTER_1_HSRPORT", access_mode "1"')
+SELECT spider_direct_sql('1\t=\t1\t3\t100000\t0\tD','','host "localhost", port "MASTER_1_HSWPORT", access_mode "2"')
+SHOW STATUS LIKE 'Spider_direct_delete';
+Variable_name Value
+Spider_direct_delete 0
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s'), d FROM hs_l2 ORDER BY a LOCK IN SHARE MODE;
+a b date_format(c, '%Y-%m-%d %H:%i:%s') d
+1 a 2008-08-01 10:21:39 101
+2 b 2000-01-01 00:00:00 102
+4 d 2003-11-30 05:01:03 104
+5 c 2001-12-31 23:59:59 105
+
+deinit
+DROP DATABASE IF EXISTS auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/item_insert_value.result b/storage/vp/mysql-test/vp/spider/r/item_insert_value.result
new file mode 100644
index 00000000000..5c90e33029b
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/item_insert_value.result
@@ -0,0 +1,107 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote1;
+CREATE DATABASE auto_test_remote1;
+DROP DATABASE IF EXISTS auto_test_remote10;
+CREATE DATABASE auto_test_remote10;
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+CREATE TABLE `tbl_1` (
+`id` bigint(20) NOT NULL,
+`id_2` bigint(20) NOT NULL,
+`id_3` bigint(20) NOT NULL,
+`id_4` bigint(20) DEFAULT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='srv "s_2_1", table "tbl_a", database "auto_test_remote1"';
+CREATE TABLE `tbl_4` (
+`id` bigint(20) NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='srv "s_2_1", table "tbl_a", database "auto_test_remote10"';
+
+drop and create databases
+connection master_1;
+set @save_spider_direct_dup_insert= @@spider_direct_dup_insert;
+set spider_direct_dup_insert= 1;
+connection child2_1;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+connection child2_1;
+SELECT 1;
+1
+1
+
+create table
+connection child2_1;
+CHILD2_1_DROP_TABLES
+CHILD2_1_CREATE_TABLES
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+DROP TABLE IF EXISTS tbl_a;
+CREATE TABLE `tbl_a` (
+`id` bigint(20) NOT NULL,
+`id_2` bigint(20) NOT NULL,
+`id_3` bigint(20) NOT NULL,
+`id_4` bigint(20) DEFAULT NULL,
+PRIMARY KEY (`id`)
+) MASTER_1_ENGINE VP_CHARSET MASTER_1_COMMENT_2_1
+
+insert test
+connection child2_1;
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+insert into tbl_a (id, id_2, id_3, id_4) VALUES (1, 2, 3, 4), (2, 3, 4, 5);
+insert into tbl_a (id, id_2, id_3, id_4) VALUES (1, 3, 4, 5), (2, 4, 5, 6) ON DUPLICATE KEY UPDATE id_4 = VALUES(id_4);
+connection child2_1;
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+argument
+insert into `auto_test_remote1`.`tbl_a`(`id`,`id_2`,`id_3`,`id_4`)values(1,2,3,4),(2,3,4,5)
+insert into `auto_test_remote10`.`tbl_a`(`id`)values(1),(2)
+insert high_priority into `auto_test_remote1`.`tbl_a`(`id`,`id_2`,`id_3`,`id_4`)values(1,3,4,5),(2,4,5,6) on duplicate key update `id_4` = values(`id_4`)
+insert high_priority ignore into `auto_test_remote10`.`tbl_a`(`id`)values(1),(2)
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'
+SELECT id FROM `auto_test_remote1`.`tbl_a` ORDER BY id ;
+SELECT id FROM `auto_test_remote10`.`tbl_a` ORDER BY id;
+id
+1
+2
+id
+1
+2
+
+deinit
+connection master_1;
+set spider_direct_dup_insert= @save_spider_direct_dup_insert;
+connection child2_1;
+SET GLOBAL log_output = @old_log_output;
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote1;
+DROP DATABASE IF EXISTS auto_test_remote10;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/spider3_fixes.result b/storage/vp/mysql-test/vp/spider/r/spider3_fixes.result
new file mode 100644
index 00000000000..7a8641afc85
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/spider3_fixes.result
@@ -0,0 +1,240 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+3.1
+auto_increment
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_1"')
+1
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_2"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
+'srv "s_2_1"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
+'srv "s_2_2"')
+1
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT MAX(id) FROM t1;
+MAX(id)
+2
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6
+SELECT MAX(id) FROM t2;
+MAX(id)
+6
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+10
+SELECT MAX(id) FROM t1;
+MAX(id)
+10
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+14
+SELECT MAX(id) FROM t2;
+MAX(id)
+14
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT id FROM t1 ORDER BY id;
+id
+2
+6
+10
+14
+18
+22
+26
+30
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+34
+SELECT id FROM t2 ORDER BY id;
+id
+2
+6
+10
+14
+18
+22
+26
+30
+34
+38
+42
+46
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT id FROM t1 ORDER BY id;
+id
+2
+6
+10
+14
+INSERT INTO t2 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT id FROM t2 ORDER BY id;
+id
+2
+6
+10
+14
+18
+22
+26
+30
+SET INSERT_ID=5000;
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+34
+SELECT MAX(id) FROM t1;
+MAX(id)
+34
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+38
+SELECT MAX(id) FROM t2;
+MAX(id)
+38
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+38
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+38
+SELECT MAX(id) FROM t2;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+2
+34
+777
+1554
+2331
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/spider3_fixes_part.result b/storage/vp/mysql-test/vp/spider/r/spider3_fixes_part.result
new file mode 100644
index 00000000000..d454d8fe72e
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/spider3_fixes_part.result
@@ -0,0 +1,238 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+auto_increment with partition
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_1"')
+1
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_2"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
+'srv "s_2_1"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
+'srv "s_2_2"')
+1
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3
+SELECT MAX(id) FROM t1;
+MAX(id)
+3
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+7
+SELECT MAX(id) FROM t2;
+MAX(id)
+7
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT MAX(id) FROM t1;
+MAX(id)
+7
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6
+SELECT MAX(id) FROM t2;
+MAX(id)
+7
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+10
+SELECT id FROM t1 ORDER BY id;
+id
+2
+3
+6
+7
+10
+11
+14
+15
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT id FROM t2 ORDER BY id;
+id
+2
+3
+6
+7
+10
+11
+14
+15
+18
+19
+22
+23
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT id FROM t1 ORDER BY id;
+id
+2
+3
+6
+7
+INSERT INTO t2 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+10
+SELECT id FROM t2 ORDER BY id;
+id
+2
+3
+6
+7
+10
+11
+14
+15
+SET INSERT_ID=5000;
+MASTER_1_AUTO_INCREMENT_OFFSET3
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT MAX(id) FROM t1;
+MAX(id)
+18
+MASTER_1_AUTO_INCREMENT_OFFSET4
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+19
+SELECT MAX(id) FROM t2;
+MAX(id)
+19
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+19
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+19
+SELECT MAX(id) FROM t2;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+2
+18
+777
+1554
+2331
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/spider_fixes.result b/storage/vp/mysql-test/vp/spider/r/spider_fixes.result
new file mode 100644
index 00000000000..2e02d53ef61
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/spider_fixes.result
@@ -0,0 +1,574 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for slave1_1
+
+drop and create databases
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+SELECT 1;
+1
+1
+
+create table and insert
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+2.13
+select table with "order by desc" and "<"
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a < 5 ORDER BY a DESC LIMIT 3;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+2 b 2000-01-01 00:00:00
+
+select table with "order by desc" and "<="
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a <= 5 ORDER BY a DESC LIMIT 3;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+5 c 2001-12-31 23:59:59
+4 d 2003-11-30 05:01:03
+3 e 2007-06-04 20:03:11
+
+2.14
+update table with range scan and split_read
+UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-02-02 00:00:00
+3 e 2000-02-02 00:00:00
+4 d 2000-02-02 00:00:00
+5 c 2000-02-02 00:00:00
+
+2.15
+select table with range scan
+TRUNCATE TABLE ta_l;
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+a int(11) NOT NULL DEFAULT '0',
+b char(1) DEFAULT NULL,
+c datetime DEFAULT NULL,
+PRIMARY KEY (a, b, c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c'
+AND c = '2001-12-31 23:59:59';
+a b c
+5 c 2001-12-31 23:59:59
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e'
+AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND b <= 'd' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND b < 'e' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1
+AND b >= 'b' AND c = '2003-11-30 05:01:03';
+a b c
+4 d 2003-11-30 05:01:03
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1
+AND b >= 'b' AND c = '2000-01-01 00:00:00';
+a b c
+2 b 2000-01-01 00:00:00
+
+2.16
+auto_increment insert with trigger
+CREATE TABLE ta_l_auto_inc (
+a INT AUTO_INCREMENT,
+b CHAR(1) DEFAULT 'c',
+c DATETIME DEFAULT '1999-10-10 10:10:10',
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1
+CREATE TABLE tc_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;;
+INSERT INTO ta_l_auto_inc (a, b, c) VALUES
+(NULL, 's', '2008-12-31 20:59:59');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 s 2008-12-31 20:59:59
+
+2.17
+engine-condition-pushdown with "or" and joining
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l);
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+1 a 2008-08-01 10:21:39
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+2.23
+index merge
+CREATE TABLE ta_l_int (
+a INT AUTO_INCREMENT,
+b INT DEFAULT 10,
+c INT DEFAULT 11,
+PRIMARY KEY(a),
+KEY idx1(b),
+KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+a b c
+3 4 5
+4 5 6
+5 6 7
+
+2.24
+index scan update without PK
+DROP TABLE IF EXISTS ta_l_int;
+CREATE TABLE ta_l_int (
+a INT NOT NULL,
+b INT DEFAULT 10,
+c INT DEFAULT 11,
+KEY idx1(b),
+KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+ERROR 42000: This table type requires a primary key
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+a b c
+1 2 3
+2 3 4
+3 4 5
+4 5 6
+5 6 7
+6 7 8
+7 8 9
+8 9 10
+9 10 11
+10 11 12
+11 12 13
+12 13 14
+13 14 15
+14 15 16
+15 16 17
+16 17 18
+INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3);
+INSERT INTO ta_l_int (a, b, c) VALUES (18, 2, 3);
+UPDATE ta_l_int SET c = 4 WHERE b = 2;
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+a b c
+1 2 4
+2 3 4
+3 4 5
+4 5 6
+5 6 7
+6 7 8
+7 8 9
+8 9 10
+9 10 11
+10 11 12
+11 12 13
+12 13 14
+13 14 15
+14 15 16
+15 16 17
+16 17 18
+17 2 4
+18 2 4
+
+2.25
+direct order limit
+SHOW STATUS LIKE 'Spider_direct_order_limit';
+Variable_name Value
+Spider_direct_order_limit 4
+SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3;
+a b c
+1 2 4
+2 3 4
+3 4 5
+SHOW STATUS LIKE 'Spider_direct_order_limit';
+Variable_name Value
+Spider_direct_order_limit 5
+
+2.26
+lock tables
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1
+CREATE TABLE t2 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2
+LOCK TABLES t1 READ, t2 READ;
+UNLOCK TABLES;
+
+auto_increment
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_1"')
+1
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_2"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
+'srv "s_2_1"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
+'srv "s_2_2"')
+1
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT MAX(id) FROM t1;
+MAX(id)
+2
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6
+SELECT MAX(id) FROM t1;
+MAX(id)
+6
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+10
+SELECT MAX(id) FROM t1;
+MAX(id)
+10
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+14
+SELECT MAX(id) FROM t1;
+MAX(id)
+14
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT id FROM t1 ORDER BY id;
+id
+2
+6
+10
+14
+18
+22
+26
+30
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+34
+SELECT MAX(id) FROM t1;
+MAX(id)
+34
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+34
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+34
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+SELECT id FROM t1 ORDER BY id;
+id
+2
+6
+10
+14
+18
+34
+777
+1000
+1554
+2331
+10000
+
+read only
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1
+SELECT id FROM t1 ORDER BY id;
+id
+2
+6
+10
+14
+18
+22
+26
+30
+34
+1000
+10000
+INSERT INTO t1 (id) VALUES (1);
+ERROR HY000: Table 'auto_test_remote.ro1_1' is read only
+UPDATE t1 SET id = 4 WHERE id = 2;
+ERROR HY000: Table 'auto_test_remote.ro1_1' is read only
+DELETE FROM t1 WHERE id = 2;
+ERROR HY000: Table 'auto_test_remote.ro1_1' is read only
+DELETE FROM t1;
+ERROR HY000: Table 'auto_test_remote.ro1_1' is read only
+TRUNCATE t1;
+ERROR HY000: Table 'auto_test_remote.ro1_1' is read only
+
+2.27
+error mode
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1
+SELECT id FROM t1 ORDER BY id;
+id
+Warnings:
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
+INSERT INTO t1 (id) VALUES (1);
+Warnings:
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
+DELETE FROM t1;
+Warnings:
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
+TRUNCATE t1;
+Warnings:
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 12702 Remote table 'auto_test_remote.ter1_1' is not found
+Error 1146 Table 'auto_test_remote.ter1_1' doesn't exist
+
+3.0
+is null
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+a VARCHAR(255),
+b VARCHAR(255),
+c VARCHAR(255),
+KEY idx1(a,b),
+KEY idx2(b),
+PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1
+insert into t1 values (null, null, '2048');
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a + 32, b + 32, c + 32 from t1;
+insert into t1 select a + 64, b + 64, c + 64 from t1;
+insert into t1 select a + 128, b + 128, c + 128 from t1;
+insert into t1 select a + 256, b + 256, c + 256 from t1;
+insert into t1 select a + 512, b + 512, c + 512 from t1;
+flush tables;
+select a from t1 where a is null order by a limit 30;
+a
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+select b from t1 where b is null order by b limit 30;
+b
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+
+direct_order_limit
+TRUNCATE TABLE t1;
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a, b + 32, c + 32 from t1;
+insert into t1 select a, b + 64, c + 64 from t1;
+insert into t1 select a, b + 128, c + 128 from t1;
+flush tables;
+select a, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5;
+a b c
+10 74 74
+10 42 42
+10 234 234
+10 202 202
+10 170 170
+select a, c from t1 where a = '10' order by b desc limit 5;
+a c
+10 74
+10 42
+10 234
+10 202
+10 170
+
+deinit
+DROP DATABASE IF EXISTS auto_test_local;
+DROP DATABASE IF EXISTS auto_test_local;
+DROP DATABASE IF EXISTS auto_test_remote;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/spider_fixes_part.result b/storage/vp/mysql-test/vp/spider/r/spider_fixes_part.result
new file mode 100644
index 00000000000..89e84372b14
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/spider_fixes_part.result
@@ -0,0 +1,241 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+for slave1_1
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+
+2.17
+partition with sort
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
+ORDER BY a;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+2 b 2000-01-01 00:00:00
+3 e 2007-06-04 20:03:11
+4 d 2003-11-30 05:01:03
+5 c 2001-12-31 23:59:59
+
+2.23
+partition update with moving partition
+connection master_1;
+DROP TABLE IF EXISTS ta_l2;
+connection master_1;
+CREATE TABLE ta_l2 (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
+INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
+UPDATE ta_l2 SET a = 4 WHERE a = 3;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
+a b date_format(c, '%Y-%m-%d %H:%i:%s')
+4 B 2010-09-26 00:00:00
+index merge with partition
+connection master_1;
+DROP TABLE IF EXISTS ta_l_int;
+connection master_1;
+CREATE TABLE ta_l_int (
+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_COMMENT3_P_2_1
+INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+connection master_1;
+SELECT a, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+a b c
+3 4 5
+4 5 6
+5 6 7
+
+2.26
+auto_increment with partition
+connection master_1;
+connection slave1_1;
+connection master_1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1
+MASTER_1_AUTO_INCREMENT_INCREMENT2
+MASTER_1_AUTO_INCREMENT_OFFSET2
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_1"')
+1
+spider_direct_sql('SET SESSION AUTO_INCREMENT_INCREMENT = 4', '',
+'srv "s_2_2"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 2', '',
+'srv "s_2_1"')
+1
+spider_bg_direct_sql('SET SESSION AUTO_INCREMENT_OFFSET = 3', '',
+'srv "s_2_2"')
+1
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3
+SELECT MAX(id) FROM t1;
+MAX(id)
+3
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+2
+SELECT MAX(id) FROM t1;
+MAX(id)
+3
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+7
+SELECT MAX(id) FROM t1;
+MAX(id)
+7
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+6
+SELECT MAX(id) FROM t1;
+MAX(id)
+7
+INSERT INTO t1 () VALUES (),(),(),();
+Warnings:
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+Note 12520 Binlog's auto-inc value is probably different from linked table's auto-inc value
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+10
+SELECT id FROM t1 ORDER BY id;
+id
+2
+3
+6
+7
+10
+11
+14
+15
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT MAX(id) FROM t1;
+MAX(id)
+18
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+18
+SELECT MAX(id) FROM t1;
+MAX(id)
+10000
+connection slave1_1;
+SELECT id FROM t1 ORDER BY id;
+id
+2
+3
+6
+7
+10
+18
+777
+1000
+1554
+2331
+10000
+connection master_1;
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection slave1_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for slave1_1
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/r/vp_fixes.result b/storage/vp/mysql-test/vp/spider/r/vp_fixes.result
new file mode 100644
index 00000000000..b0a51d851ac
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/r/vp_fixes.result
@@ -0,0 +1,95 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+drop and create databases
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+CREATE DATABASE auto_test_remote2;
+USE auto_test_remote2;
+
+test select 1
+connection master_1;
+SELECT 1;
+1
+1
+
+create table and insert
+connection master_1;
+DROP TABLE IF EXISTS tb_l;
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tb_l (a, b, c) VALUES
+(1, 'a', '2008-08-01 10:21:39'),
+(2, 'b', '2000-01-01 00:00:00'),
+(3, 'e', '2007-06-04 20:03:11'),
+(4, 'd', '2003-11-30 05:01:03'),
+(5, 'c', '2001-12-31 23:59:59');
+DROP TABLE IF EXISTS ta_l;
+CREATE TABLE ta_l (
+PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+0.9
+create different primary key table
+connection master_1;
+CREATE TABLE ta_l_int (
+a INT DEFAULT 10,
+b INT AUTO_INCREMENT,
+c INT DEFAULT 11,
+PRIMARY KEY(b)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+connection master_1;
+INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ERROR HY000: Can't correspond PK 'ta_r_int'
+create un-correspond primary key table
+connection master_1;
+DROP TABLE IF EXISTS ta_l_int;
+connection master_1;
+CREATE TABLE ta_l_int (
+a INT DEFAULT 10,
+b INT DEFAULT 12,
+c INT DEFAULT 11,
+PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1
+connection master_1;
+INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ERROR HY000: Can't correspond PK 'ta_r_int'
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+connection child2_2;
+DROP DATABASE IF EXISTS auto_test_remote2;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+
+end of test
diff --git a/storage/vp/mysql-test/vp/spider/suite.opt b/storage/vp/mysql-test/vp/spider/suite.opt
new file mode 100644
index 00000000000..fece48adaed
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/suite.opt
@@ -0,0 +1,2 @@
+--loose-innodb
+--loose-partition
diff --git a/storage/vp/mysql-test/vp/spider/suite.pm b/storage/vp/mysql-test/vp/spider/suite.pm
new file mode 100644
index 00000000000..6ddc6e0dddb
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/suite.pm
@@ -0,0 +1,11 @@
+package My::Suite::Vp;
+
+@ISA = qw(My::Suite);
+
+return "No Vp engine" unless $ENV{HA_VP_SO};
+return "Not run for embedded server" if $::opt_embedded_server;
+
+sub is_default { 1 }
+
+bless { };
+
diff --git a/storage/vp/mysql-test/vp/spider/t/basic_sql.test b/storage/vp/mysql-test/vp/spider/t/basic_sql.test
new file mode 100644
index 00000000000..5bb040047fc
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/basic_sql.test
@@ -0,0 +1,2699 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create table ignore 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
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'f', '2008-07-01 10:21:39'),
+ (2, 'g', '2000-02-01 00:00:00'),
+ (3, 'j', '2007-05-04 20:03:11'),
+ (4, 'i', '2003-10-30 05:01:03'),
+ (5, 'h', '2001-10-31 23:59:59');
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+IGNORE SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ IGNORE SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ IGNORE SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create table ignore 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
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+REPLACE SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ REPLACE SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ REPLACE INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ REPLACE SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create no index table
+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_TABLES3;
+ echo CHILD2_1_CREATE_TABLES3;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES3;
+ --enable_warnings
+ 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 ta_l_no_idx;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l_no_idx
+MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1
+SELECT a, b, c FROM tb_l;
+if ($MASTER_1_NEEDPK)
+{
+ --error ER_REQUIRES_PRIMARY_KEY
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l_no_idx (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1;
+ INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_NEEDPK)
+{
+ if ($MASTER_1_MERGE)
+ {
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l_no_idx (
+ a INT,
+ b CHAR(1),
+ c DATETIME
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1;
+ INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l;
+ }
+ if (!$MASTER_1_MERGE)
+ {
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ }
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES3;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a;
+
+--echo
+--echo select table
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table shared mode
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+LOCK IN SHARE MODE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table for update
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+FOR UPDATE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table join
+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, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b
+WHERE a.a = b.a ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table straight_join
+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 STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')
+FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_small_result
+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 SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_big_result
+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 SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_buffer_result
+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 SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_cache
+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 SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_no_cache
+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 SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_calc_found_rows
+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 SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a LIMIT 4;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT found_rows();
+
+--echo
+--echo select high_priority
+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 HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select distinct
+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 DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select count
+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 count(*) FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table join not use index
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
+EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select using pushdown
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.b = 'g' ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select using index and pushdown
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo insert
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert select
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert select a
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert low_priority
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert high_priority
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e',
+'2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert ignore
+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
+INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert update (insert)
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert update (update)
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace
+--connection master_1
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+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
+REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace select
+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
+REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace select a
+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
+REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace low_priority
+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
+REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g',
+'2009-03-03 03:03:03');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59');
+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
+UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update select
+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
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM
+tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update select a
+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
+UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM
+tb_l ORDER BY a LIMIT 1);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update join
+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
+UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update join a
+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
+UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE
+a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update low_priority
+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
+UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update ignore
+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
+UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update pushdown
+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
+update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update index pushdown
+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
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete all
+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
+DELETE FROM ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete select
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete select a
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete join
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete low_priority
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE LOW_PRIORITY FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete ignore
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE IGNORE FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete quick
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE QUICK FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE b = 'e';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete index pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a > 0 AND b = 'e';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo truncate
+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
+TRUNCATE TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/basic_sql_part.test b/storage/vp/mysql-test/vp/spider/t/basic_sql_part.test
new file mode 100644
index 00000000000..e1638642ab7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/basic_sql_part.test
@@ -0,0 +1,571 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'f', '2008-07-01 10:21:39'),
+ (2, 'g', '2000-02-01 00:00:00'),
+ (3, 'j', '2007-05-04 20:03:11'),
+ (4, 'i', '2003-10-30 05:01:03'),
+ (5, 'h', '2001-10-31 23:59:59');
+
+--echo
+--echo create table with partition and select test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ if ($MASTER_1_MERGE)
+ {
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l2 (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ }
+ if (!$MASTER_1_MERGE)
+ {
+ eval CREATE TABLE ta_l2 (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ }
+ --enable_query_log
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo select partition using pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+ a.b = 'g' ORDER BY a.a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo select partition using index pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+ a.a > 0 AND a.b = 'g' ORDER BY a.a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo update partition pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo update partition index pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo delete partition pushdown
+if ($HAVE_PARTITION)
+{
+ TRUNCATE TABLE ta_l2;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ DELETE FROM ta_l2 WHERE b = 'g';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo delete partition index pushdown
+if ($HAVE_PARTITION)
+{
+ TRUNCATE TABLE ta_l2;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/connect_child2_1.inc b/storage/vp/mysql-test/vp/spider/t/connect_child2_1.inc
new file mode 100644
index 00000000000..cd9b0c9ca9b
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child2_1.inc
@@ -0,0 +1 @@
+--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_child2_2.inc b/storage/vp/mysql-test/vp/spider/t/connect_child2_2.inc
new file mode 100644
index 00000000000..e145f66b630
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child2_2.inc
@@ -0,0 +1 @@
+--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_child2_3.inc b/storage/vp/mysql-test/vp/spider/t/connect_child2_3.inc
new file mode 100644
index 00000000000..d356348d8ea
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child2_3.inc
@@ -0,0 +1 @@
+--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_child3_1.inc b/storage/vp/mysql-test/vp/spider/t/connect_child3_1.inc
new file mode 100644
index 00000000000..03e5c188c89
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child3_1.inc
@@ -0,0 +1 @@
+--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_child3_2.inc b/storage/vp/mysql-test/vp/spider/t/connect_child3_2.inc
new file mode 100644
index 00000000000..d62a7ada824
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child3_2.inc
@@ -0,0 +1 @@
+--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_child3_3.inc b/storage/vp/mysql-test/vp/spider/t/connect_child3_3.inc
new file mode 100644
index 00000000000..fb49f5bfdac
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_child3_3.inc
@@ -0,0 +1 @@
+--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_master_1.inc b/storage/vp/mysql-test/vp/spider/t/connect_master_1.inc
new file mode 100644
index 00000000000..0c129ce5775
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_master_1.inc
@@ -0,0 +1 @@
+--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/connect_slave1_1.inc b/storage/vp/mysql-test/vp/spider/t/connect_slave1_1.inc
new file mode 100644
index 00000000000..45a822743e0
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/connect_slave1_1.inc
@@ -0,0 +1 @@
+--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/spider/t/direct_aggregate.test b/storage/vp/mysql-test/vp/spider/t/direct_aggregate.test
new file mode 100644
index 00000000000..d65f4c5a624
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/direct_aggregate.test
@@ -0,0 +1,179 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo direct_aggregating 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
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT COUNT(*) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MAX(a) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MIN(a) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MAX(a) FROM ta_l WHERE a < 5;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MIN(a) FROM ta_l WHERE a > 1;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/direct_aggregate_part.test b/storage/vp/mysql-test/vp/spider/t/direct_aggregate_part.test
new file mode 100644
index 00000000000..aebf210c745
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/direct_aggregate_part.test
@@ -0,0 +1,192 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT COUNT(*) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MAX(a) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MIN(a) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MAX(a) FROM ta_l2 WHERE a < 5;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MIN(a) FROM ta_l2 WHERE a > 1;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/direct_update.test b/storage/vp/mysql-test/vp/spider/t/direct_update.test
new file mode 100644
index 00000000000..e0901062201
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/direct_update.test
@@ -0,0 +1,198 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo direct_updating 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
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update all rows with function
+UPDATE ta_l SET c = ADDDATE(c, 1);
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by primary key
+UPDATE ta_l SET b = 'x' WHERE a = 3;
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by a column without index
+UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by primary key with order and limit
+UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by primary key with order and limit
+DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by a column without index
+DELETE FROM ta_l WHERE b = 'c';
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by primary key
+DELETE FROM ta_l WHERE a = 3;
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/direct_update_part.test b/storage/vp/mysql-test/vp/spider/t/direct_update_part.test
new file mode 100644
index 00000000000..95e2e2ab0d5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/direct_update_part.test
@@ -0,0 +1,211 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update all rows with function
+ UPDATE ta_l2 SET c = ADDDATE(c, 1);
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by primary key
+ UPDATE ta_l2 SET b = 'x' WHERE a = 3;
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by a column without index
+ UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by primary key with order and limit
+ UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by primary key with order and limit
+ DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by a column without index
+ DELETE FROM ta_l2 WHERE b = 'c';
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by primary key
+ DELETE FROM ta_l2 WHERE a = 3;
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/fulltext.test b/storage/vp/mysql-test/vp/spider/t/fulltext.test
new file mode 100644
index 00000000000..4c2462b8d84
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/fulltext.test
@@ -0,0 +1,181 @@
+# This test tests for fulltext searching
+if (!$USE_FULLTEXT_TEST)
+{
+ skip Please set 'USE_FULLTEXT_TEST=1' if you want to test for fulltext searching;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_FT_TABLES;
+ echo CHILD2_1_CREATE_FT_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_FT_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_FT_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ft_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ft_l (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_FT_2_1;
+eval CREATE TABLE ft_l (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_FT_2_1;
+--enable_query_log
+INSERT INTO ft_l (a,b,c,d) VALUES
+(1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+(2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+(3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+(4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+(5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+
+--echo
+--echo fulltext search
+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, b, c, d from ft_l where match(b) against('fedc');
+select a, b, c, d from ft_l where match(c) against('hgfe');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/fulltext_part.test b/storage/vp/mysql-test/vp/spider/t/fulltext_part.test
new file mode 100644
index 00000000000..e78fda1aafe
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/fulltext_part.test
@@ -0,0 +1,195 @@
+# This test tests for fulltext searching
+if (!$USE_FULLTEXT_TEST)
+{
+ skip Please set 'USE_FULLTEXT_TEST=1' if you want to test for fulltext searching;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_FT_TABLES;
+ echo CHILD2_2_CREATE_FT_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_FT_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_FT_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_FT_TABLES2;
+ echo CHILD2_1_CREATE_FT_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_FT_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_FT_TABLES2;
+ 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 ft_l2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_FT_P_2_1;
+ eval CREATE TABLE ft_l2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_FT_P_2_1;
+ INSERT INTO ft_l2 (a,b,c,d) VALUES
+ (1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+ (2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+ (3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+ (4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+ (5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+ --enable_query_log
+ select a, b, c, d from ft_l2 where match(b) against('fedc');
+ select a, b, c, d from ft_l2 where match(c) against('hgfe');
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_FT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_FT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/function.test b/storage/vp/mysql-test/vp/spider/t/function.test
new file mode 100644
index 00000000000..ec2eeab9c94
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/function.test
@@ -0,0 +1,253 @@
+# This test tests for using functions
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo in()
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TEXT_PK_TABLES1;
+ echo CHILD2_1_CREATE_TEXT_PK_TABLES1;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TEXT_PK_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TEXT_PK_TABLES1;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1;
+eval CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1;
+--enable_query_log
+insert into t1 values ('1');
+insert into t1 select a + 1 from t1;
+insert into t1 select a + 2 from t1;
+insert into t1 select a + 4 from t1;
+insert into t1 select a + 8 from t1;
+insert into t1 select a + 16 from t1;
+insert into t1 select a + 32 from t1;
+insert into t1 select a + 64 from t1;
+insert into t1 select a + 128 from t1;
+insert into t1 select a + 256 from t1;
+insert into t1 select a + 512 from t1;
+flush tables;
+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 from t1 where a in ('15', '120');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo date_sub()
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/geometry.test b/storage/vp/mysql-test/vp/spider/t/geometry.test
new file mode 100644
index 00000000000..d0ae07ed78f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/geometry.test
@@ -0,0 +1,192 @@
+# This test tests for geometry
+if (!$USE_GEOMETRY_TEST)
+{
+ skip Please set 'USE_GEOMETRY_TEST=1' if you want to test for geometry;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_GM_TABLES;
+ echo CHILD2_1_CREATE_GM_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_GM_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_GM_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS gm_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1;
+eval CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_GM_2_1;
+--enable_query_log
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+--echo
+--echo geometry search
+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 AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/geometry_part.test b/storage/vp/mysql-test/vp/spider/t/geometry_part.test
new file mode 100644
index 00000000000..12fc169c000
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/geometry_part.test
@@ -0,0 +1,206 @@
+# This test tests for geometry
+if (!$USE_GEOMETRY_TEST)
+{
+ skip Please set 'USE_GEOMETRY_TEST=1' if you want to test for geometry;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_GM_TABLES;
+ echo CHILD2_2_CREATE_GM_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_GM_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_GM_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_GM_TABLES2;
+ echo CHILD2_1_CREATE_GM_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_GM_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_GM_TABLES2;
+ 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 gm_l2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_GM_P_2_1;
+ eval CREATE TABLE gm_l2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_GM_P_2_1;
+ INSERT INTO gm_l2 (a,b,c) VALUES
+ ( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+ ( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+ ( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+ ( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+ ( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+ ( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+ ( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+ ( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+ ( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+ (10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+ (11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+ (12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+ --enable_query_log
+ SELECT AsText(b) FROM gm_l2 WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_GM_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_GM_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/ha.test b/storage/vp/mysql-test/vp/spider/t/ha.test
new file mode 100644
index 00000000000..c12930e4aed
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/ha.test
@@ -0,0 +1,878 @@
+# This test tests for ha features
+if ($USE_HA_TEST)
+{
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source ha_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+ CREATE DATABASE auto_test_remote3;
+ USE auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ --connection child2_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ SELECT 1;
+ --connection child3_2
+ SELECT 1;
+ --connection child3_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--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;
+ }
+ --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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo fail-over 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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_HA_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_HA_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_CHECK_HA_STATUS;
+--error 12511
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+eval $MASTER_1_CHECK_HA_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo recovery 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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_HA_CREATE_TABLES;
+ }
+ eval $CHILD2_2_HA_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
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_RECOVERY_STATUS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_COPY_TABLES_2_1;
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_OK_STATUS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+DROP TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+eval $MASTER_1_CHANGE_HA_MON;
+
+--echo
+--echo active standby test
+--echo create table test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--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;
+ }
+ --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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo fail-over 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;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_HA_AS_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_HA_AS_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_CHECK_HA_STATUS;
+--error 12511
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+eval $MASTER_1_CHECK_HA_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo recovery test
+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_HA_AS_CREATE_TABLES;
+ }
+ eval $CHILD2_1_HA_AS_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_OK_STATUS_AS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+DROP TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+eval $MASTER_1_CHANGE_HA_MON;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+}
+--disable_query_log
+--disable_result_log
+--source ha_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+}
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/ha_part.test b/storage/vp/mysql-test/vp/spider/t/ha_part.test
new file mode 100644
index 00000000000..72ddcfd1f10
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/ha_part.test
@@ -0,0 +1,1017 @@
+# This test tests for ha features
+if ($USE_HA_TEST)
+{
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source ha_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source ha_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+ CREATE DATABASE auto_test_remote3;
+ USE auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ --connection child2_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ SELECT 1;
+ --connection child3_2
+ SELECT 1;
+ --connection child3_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+if ($HAVE_PARTITION)
+{
+ --echo
+ --echo create table with partition test
+ 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_TABLES2;
+ echo CHILD2_1_CREATE_TABLES;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ eval $CHILD2_1_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_DROP_TABLES;
+ echo CHILD2_3_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_3_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_P_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_P_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_P_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+ --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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo fail-over 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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_HA_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_HA_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_CHECK_HA_STATUS;
+ --error 12511
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+ eval $MASTER_1_CHECK_HA_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo recovery 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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_HA_CREATE_TABLES;
+ }
+ eval $CHILD2_3_HA_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_COPY_TABLES_P_2_1;
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_OK_STATUS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30'),
+ (9, 'h', '2011-05-05 22:32:10');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ DROP TABLE ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+if ($HAVE_PARTITION)
+{
+ --echo
+ --echo create table with partition test
+ 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_TABLES2;
+ echo CHILD2_1_CREATE_TABLES;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ eval $CHILD2_1_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_DROP_TABLES;
+ echo CHILD2_3_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_3_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+ --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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo fail-over test
+ 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_HA_AS_DROP_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_HA_AS_DROP_TABLES2;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_CHECK_HA_STATUS;
+ --error 12511
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+ eval $MASTER_1_CHECK_HA_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo recovery test
+ 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_HA_AS_CREATE_TABLES2;
+ }
+ eval $CHILD2_1_HA_AS_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_OK_STATUS_AS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30'),
+ (9, 'h', '2011-05-05 22:32:10');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ DROP TABLE ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+}
+--disable_query_log
+--disable_result_log
+--source ha_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+}
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/ha_test_deinit.inc b/storage/vp/mysql-test/vp/spider/t/ha_test_deinit.inc
new file mode 100644
index 00000000000..53d0409d066
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/ha_test_deinit.inc
@@ -0,0 +1,30 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/ha_deinit_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/ha_deinit_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/ha_deinit_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/ha_deinit_child2_3.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/ha_deinit_child3_1.inc
+ --echo child3_2
+ --connection child3_2
+ --source ../include/ha_deinit_child3_2.inc
+ --echo child3_3
+ --connection child3_3
+ --source ../include/ha_deinit_child3_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/ha_test_init.inc b/storage/vp/mysql-test/vp/spider/t/ha_test_init.inc
new file mode 100644
index 00000000000..70576ab16dc
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/ha_test_init.inc
@@ -0,0 +1,30 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/ha_init_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/ha_init_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/ha_init_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/ha_init_child2_3.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/ha_init_child3_1.inc
+ --echo child3_2
+ --connection child3_2
+ --source ../include/ha_init_child3_2.inc
+ --echo child3_3
+ --connection child3_3
+ --source ../include/ha_init_child3_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/handler.test b/storage/vp/mysql-test/vp/spider/t/handler.test
new file mode 100644
index 00000000000..378fd4c10af
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/handler.test
@@ -0,0 +1,188 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo handler 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
+HANDLER ta_l OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ FIRST LIMIT 2;
+HANDLER a READ NEXT LIMIT 2;
+HANDLER a READ NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+HANDLER a READ FIRST WHERE b = 'c';
+HANDLER a CLOSE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/handler_part.test b/storage/vp/mysql-test/vp/spider/t/handler_part.test
new file mode 100644
index 00000000000..fa94a0ffe5a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/handler_part.test
@@ -0,0 +1,201 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo handler with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ HANDLER ta_l2 OPEN a;
+ HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` LAST LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ FIRST LIMIT 2;
+ HANDLER a READ NEXT LIMIT 2;
+ HANDLER a READ NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+ HANDLER a READ FIRST WHERE b = 'c';
+ HANDLER a CLOSE;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/spider/t/have_engine.inc b/storage/vp/mysql-test/vp/spider/t/have_engine.inc
new file mode 100644
index 00000000000..64bef7499cb
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/have_engine.inc
@@ -0,0 +1,7 @@
+if (!`SELECT count(*) FROM information_schema.engines WHERE
+ (support = 'YES' OR support = 'DEFAULT') AND
+ engine = '$TEST_ENGINE_TYPE'`)
+{
+ SELECT engine, support FROM information_schema.engines;
+ --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine"
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/have_func.inc b/storage/vp/mysql-test/vp/spider/t/have_func.inc
new file mode 100644
index 00000000000..e0823e73fc8
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/have_func.inc
@@ -0,0 +1,5 @@
+if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`)
+{
+ SELECT name FROM mysql.func;
+ --let $SKIP_REASON= "Need $TEST_FUNC_NAME function"
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/have_partition.inc b/storage/vp/mysql-test/vp/spider/t/have_partition.inc
new file mode 100644
index 00000000000..b6e699475db
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/have_partition.inc
@@ -0,0 +1,7 @@
+let $HAVE_PARTITION= 0;
+if (`SELECT count(*) FROM information_schema.plugins WHERE
+ plugin_status = 'ACTIVE' AND
+ plugin_name = 'partition'`)
+{
+ let $HAVE_PARTITION= 1;
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/have_plugin.inc b/storage/vp/mysql-test/vp/spider/t/have_plugin.inc
new file mode 100644
index 00000000000..316ede9ec46
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/have_plugin.inc
@@ -0,0 +1,5 @@
+if (!`SELECT count(*) FROM information_schema.plugins WHERE plugin_name = '$TEST_PLUGIN_NAME'`)
+{
+ SELECT plugin_name FROM information_schema.plugins;
+ --let $SKIP_REASON= "Need $TEST_PLUGIN_NAME plugin"
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/have_trigger.inc b/storage/vp/mysql-test/vp/spider/t/have_trigger.inc
new file mode 100644
index 00000000000..32de484b388
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/have_trigger.inc
@@ -0,0 +1,2 @@
+let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables
+ WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`;
diff --git a/storage/vp/mysql-test/vp/spider/t/hs_test_deinit.inc b/storage/vp/mysql-test/vp/spider/t/hs_test_deinit.inc
new file mode 100644
index 00000000000..7ec2e981fd2
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/hs_test_deinit.inc
@@ -0,0 +1,17 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/hs_deinit_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/hs_deinit_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/hs_deinit_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/hs_deinit_child2_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/hs_test_init.inc b/storage/vp/mysql-test/vp/spider/t/hs_test_init.inc
new file mode 100644
index 00000000000..831bf479524
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/hs_test_init.inc
@@ -0,0 +1,17 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/hs_init_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/hs_init_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/hs_init_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/hs_init_child2_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/item_insert_value.test b/storage/vp/mysql-test/vp/spider/t/item_insert_value.test
new file mode 100644
index 00000000000..114b8df20bd
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/item_insert_value.test
@@ -0,0 +1,154 @@
+--source ../include/item_insert_value_init.inc
+
+--echo
+--echo drop and create databases
+--connection master_1
+set @save_spider_direct_dup_insert= @@spider_direct_dup_insert;
+set spider_direct_dup_insert= 1;
+--disable_warnings
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SET @old_log_output = @@global.log_output;
+ SET GLOBAL log_output = 'TABLE,FILE';
+ }
+}
+--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
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tbl_a;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE `tbl_a` (
+ `id` bigint(20) NOT NULL,
+ `id_2` bigint(20) NOT NULL,
+ `id_3` bigint(20) NOT NULL,
+ `id_4` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) MASTER_1_ENGINE VP_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE `tbl_a` (
+ `id` bigint(20) NOT NULL,
+ `id_2` bigint(20) NOT NULL,
+ `id_3` bigint(20) NOT NULL,
+ `id_4` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) $MASTER_1_ENGINE $VP_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+
+--echo
+--echo insert 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
+insert into tbl_a (id, id_2, id_3, id_4) VALUES (1, 2, 3, 4), (2, 3, 4, 5);
+insert into tbl_a (id, id_2, id_3, id_4) VALUES (1, 3, 4, 5), (2, 4, 5, 6) ON DUPLICATE KEY UPDATE id_4 = VALUES(id_4);
+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
+set spider_direct_dup_insert= @save_spider_direct_dup_insert;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SET GLOBAL log_output = @old_log_output;
+ }
+}
+--enable_warnings
+--source ../include/item_insert_value_deinit.inc
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/slave_test_deinit.inc b/storage/vp/mysql-test/vp/spider/t/slave_test_deinit.inc
new file mode 100644
index 00000000000..e9d99b7a960
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/slave_test_deinit.inc
@@ -0,0 +1,6 @@
+# get connection and exist engine test
+--echo for slave1_1
+--connection slave1_1
+STOP SLAVE;
+--source ../include/deinit_slave1_1.inc
+--disconnect slave1_1
diff --git a/storage/vp/mysql-test/vp/spider/t/slave_test_init.inc b/storage/vp/mysql-test/vp/spider/t/slave_test_init.inc
new file mode 100644
index 00000000000..739d88970c5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/slave_test_init.inc
@@ -0,0 +1,44 @@
+# get connection and exist engine test
+--echo for slave1_1
+--source connect_slave1_1.inc
+--connection slave1_1
+SET SESSION sql_log_bin= 0;
+--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id`
+--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE
+--source have_partition.inc
+--source have_trigger.inc
+--source ../include/init_slave1_1.inc
+--source have_engine.inc
+--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS`
+if (!$SLAVE1_1_SLAVE_STATUS)
+{
+ eval CHANGE MASTER TO
+ MASTER_HOST = '127.0.0.1',
+ MASTER_USER = 'root',
+ MASTER_PASSWORD = '',
+ MASTER_PORT = $MASTER_1_MYPORT
+ ;
+}
+START SLAVE;
+--connection master_1
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--connection slave1_1
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child2_2
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child2_3
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child3_2
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child3_3
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/spider3_fixes.test b/storage/vp/mysql-test/vp/spider/t/spider3_fixes.test
new file mode 100644
index 00000000000..13fa6f5fa39
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/spider3_fixes.test
@@ -0,0 +1,292 @@
+# This test tests for Spider 3.0's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo 3.1
+--echo auto_increment
+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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+if ($USE_REPLICATION)
+{
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ --connection master_1
+}
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t2 ORDER BY id;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t2 ORDER BY id;
+SET INSERT_ID=5000;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/spider3_fixes_part.test b/storage/vp/mysql-test/vp/spider/t/spider3_fixes_part.test
new file mode 100644
index 00000000000..3288c490a46
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/spider3_fixes_part.test
@@ -0,0 +1,345 @@
+# This test tests for Spider 3.0's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source slave_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo auto_increment with partition
+if ($HAVE_PARTITION)
+{
+ 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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_INCREMENT_TABLES1;
+ echo CHILD2_2_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+ if ($USE_REPLICATION)
+ {
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ --connection master_1
+ }
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t2 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t2 ORDER BY id;
+ TRUNCATE TABLE t1;
+ TRUNCATE TABLE t2;
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ INSERT INTO t2 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t2 ORDER BY id;
+ SET INSERT_ID=5000;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ INSERT INTO t1 (id) VALUES (10000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t2 (id) VALUES (1000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/spider_fixes.test b/storage/vp/mysql-test/vp/spider/t/spider_fixes.test
new file mode 100644
index 00000000000..04e806fb612
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/spider_fixes.test
@@ -0,0 +1,1419 @@
+# This test tests for Spider's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+--echo
+--echo 2.13
+--echo select table with "order by desc" and "<"
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a < 5 ORDER BY a DESC LIMIT 3;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table with "order by desc" and "<="
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a <= 5 ORDER BY a DESC LIMIT 3;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.14
+--echo update table with range scan and split_read
+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
+UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo 2.15
+--echo select table with range scan
+TRUNCATE TABLE ta_l;
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+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_TABLES6;
+ echo CHILD2_1_CREATE_TABLES6;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES6;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES6;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a int(11) NOT NULL DEFAULT '0',
+ b char(1) DEFAULT NULL,
+ c datetime DEFAULT NULL,
+ PRIMARY KEY (a, b, c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1;
+eval CREATE TABLE ta_l (
+ a int(11) NOT NULL DEFAULT '0',
+ b char(1) DEFAULT NULL,
+ c datetime DEFAULT NULL,
+ PRIMARY KEY (a, b, c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+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, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c'
+AND c = '2001-12-31 23:59:59';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND b <= 'd' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND b < 'e' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1
+AND b >= 'b' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1
+AND b >= 'b' AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.16
+--echo auto_increment insert with trigger
+if ($HAVE_TRIGGER)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES4;
+ echo CHILD2_1_CREATE_TABLES4;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES4;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES4;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_query_log
+ echo CREATE TABLE ta_l_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1;
+ eval CREATE TABLE ta_l_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1;
+ echo CREATE TABLE tc_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+ eval CREATE TABLE tc_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+ --enable_query_log
+ --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;
+ 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;
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ INSERT INTO ta_l_auto_inc (a, b, c) VALUES
+ (NULL, 's', '2008-12-31 20:59:59');
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES4;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a;
+}
+
+--echo
+--echo 2.17
+--echo engine-condition-pushdown with "or" and joining
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.23
+--echo index merge
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ 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 ta_l_int (
+ 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 ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+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, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.24
+--echo index scan update without PK
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l_int;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+if ($MASTER_1_NEEDPK)
+{
+ --error ER_REQUIRES_PRIMARY_KEY
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ 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;
+}
+if (!$MASTER_1_NEEDPK)
+{
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+}
+--enable_query_log
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3);
+INSERT INTO ta_l_int (a, b, c) VALUES (18, 2, 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;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+UPDATE ta_l_int SET c = 4 WHERE b = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+
+
+--echo
+--echo 2.25
+--echo direct order limit
+--connection master_1
+eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS;
+SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3;
+eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS;
+
+
+--echo
+--echo 2.26
+--echo lock tables
+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_LOCK_TABLES1;
+ echo CHILD2_1_DROP_LOCK_TABLES2;
+ echo CHILD2_1_CREATE_LOCK_TABLES1;
+ echo CHILD2_1_CREATE_LOCK_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_LOCK_TABLES1;
+ eval $CHILD2_1_DROP_LOCK_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_LOCK_TABLES1;
+ eval $CHILD2_1_CREATE_LOCK_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_LOCK_TABLES1;
+ echo CHILD2_2_DROP_LOCK_TABLES2;
+ echo CHILD2_2_CREATE_LOCK_TABLES1;
+ echo CHILD2_2_CREATE_LOCK_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_LOCK_TABLES1;
+ eval $CHILD2_2_DROP_LOCK_TABLES2;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_LOCK_TABLES1;
+ eval $CHILD2_2_CREATE_LOCK_TABLES2;
+ 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 t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1;
+echo CREATE TABLE t2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2;
+eval CREATE TABLE t2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2;
+--enable_query_log
+LOCK TABLES t1 READ, t2 READ;
+UNLOCK TABLES;
+
+
+--echo
+--echo auto_increment
+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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+if ($USE_REPLICATION)
+{
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ --connection master_1
+}
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo read only
+let $MASTER_1_ENGINE_IS_SPIDER=
+ `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR
+ '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`;
+if ($MASTER_1_ENGINE_IS_SPIDER)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1;
+ --let $MIN_VAL= `SELECT MIN(id) FROM t1`
+ --enable_query_log
+ SELECT id FROM t1 ORDER BY id;
+ --error 12518
+ INSERT INTO t1 (id) VALUES (1);
+ --error 12518
+ eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL;
+ --error 12518
+ eval DELETE FROM t1 WHERE id = $MIN_VAL;
+ --error 12518
+ DELETE FROM t1;
+ --error 12518
+ TRUNCATE t1;
+}
+if (!$MASTER_1_ENGINE_IS_SPIDER)
+{
+ --echo skipped
+}
+
+
+--echo
+--echo 2.27
+--echo error mode
+if ($MASTER_1_ENGINE_IS_SPIDER)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1;
+ --enable_query_log
+ SELECT id FROM t1 ORDER BY id;
+ INSERT INTO t1 (id) VALUES (1);
+ DELETE FROM t1;
+ TRUNCATE t1;
+}
+if (!$MASTER_1_ENGINE_IS_SPIDER)
+{
+ --echo skipped
+}
+
+
+--echo
+--echo 3.0
+--echo is null
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TEXT_KEY_TABLES1;
+ echo CHILD2_1_CREATE_TEXT_KEY_TABLES1;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TEXT_KEY_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1;
+eval CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1;
+--enable_query_log
+insert into t1 values (null, null, '2048');
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a + 32, b + 32, c + 32 from t1;
+insert into t1 select a + 64, b + 64, c + 64 from t1;
+insert into t1 select a + 128, b + 128, c + 128 from t1;
+insert into t1 select a + 256, b + 256, c + 256 from t1;
+insert into t1 select a + 512, b + 512, c + 512 from t1;
+flush tables;
+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 from t1 where a is null order by a limit 30;
+select b from t1 where b is null order by b limit 30;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo direct_order_limit
+--connection master_1
+TRUNCATE TABLE t1;
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a, b + 32, c + 32 from t1;
+insert into t1 select a, b + 64, c + 64 from t1;
+insert into t1 select a, b + 128, c + 128 from t1;
+flush tables;
+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, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5;
+select a, c from t1 where a = '10' order by b desc limit 5;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/spider_fixes_part.test b/storage/vp/mysql-test/vp/spider/t/spider_fixes_part.test
new file mode 100644
index 00000000000..ef5a8026c02
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/spider_fixes_part.test
@@ -0,0 +1,645 @@
+# This test tests for Spider's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source slave_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo 2.17
+--echo partition with sort
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
+ ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo 2.23
+--echo partition update with moving partition
+if ($HAVE_PARTITION)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
+ UPDATE ta_l2 SET a = 4 WHERE a = 3;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo index merge with partition
+if ($HAVE_PARTITION)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l_int;
+ --enable_warnings
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_2_DROP_TABLES5;
+ echo CHILD2_2_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES5;
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_query_log
+ echo CREATE TABLE ta_l_int (
+ 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_COMMENT3_P_2_1;
+ eval CREATE TABLE ta_l_int (
+ 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_COMMENT3_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, b, c FROM ta_l_int force index(primary, idx1, idx2)
+ WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+
+--echo
+--echo 2.26
+--echo auto_increment with partition
+if ($HAVE_PARTITION)
+{
+ 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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_INCREMENT_TABLES1;
+ echo CHILD2_2_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+ if ($USE_REPLICATION)
+ {
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ --connection master_1
+ }
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ SET INSERT_ID=5000;
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (10000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (1000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/spider/t/test_deinit.inc b/storage/vp/mysql-test/vp/spider/t/test_deinit.inc
new file mode 100644
index 00000000000..989bde26d3c
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/test_deinit.inc
@@ -0,0 +1,37 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/deinit_master_1.inc
+--disconnect master_1
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/deinit_child2_1.inc
+ --disconnect child2_1
+ --echo child2_2
+ --connection child2_2
+ --source ../include/deinit_child2_2.inc
+ --disconnect child2_2
+ --echo child2_3
+ --connection child2_3
+ --source ../include/deinit_child2_3.inc
+ --disconnect child2_3
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/deinit_child3_1.inc
+ --disconnect child3_1
+ --echo child3_2
+ --connection child3_2
+ --source ../include/deinit_child3_2.inc
+ --disconnect child3_2
+ --echo child3_3
+ --connection child3_3
+ --source ../include/deinit_child3_3.inc
+ --disconnect child3_3
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/test_init.inc b/storage/vp/mysql-test/vp/spider/t/test_init.inc
new file mode 100644
index 00000000000..f2cd6c0269f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/test_init.inc
@@ -0,0 +1,74 @@
+# get connection and exist engine test
+--echo for master_1
+--source connect_master_1.inc
+--connection master_1
+CALL mtr.add_suppression("unknown variable");
+SET SESSION sql_log_bin= 0;
+--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id`
+--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE
+--source have_partition.inc
+--source have_trigger.inc
+--source ../include/init_master_1.inc
+--source have_engine.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --source connect_child2_1.inc
+ --connection child2_1
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE
+ --source ../include/init_child2_1.inc
+ --source have_engine.inc
+ --echo child2_2
+ --source connect_child2_2.inc
+ --connection child2_2
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE
+ --source ../include/init_child2_2.inc
+ --source have_engine.inc
+ --echo child2_3
+ --source connect_child2_3.inc
+ --connection child2_3
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE
+ --source ../include/init_child2_3.inc
+ --source have_engine.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --source connect_child3_1.inc
+ --connection child3_1
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE
+ --source ../include/init_child3_1.inc
+ --source have_engine.inc
+ --echo child3_2
+ --source connect_child3_2.inc
+ --connection child3_2
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE
+ --source ../include/init_child3_2.inc
+ --source have_engine.inc
+ --echo child3_3
+ --source connect_child3_3.inc
+ --connection child3_3
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE
+ --source ../include/init_child3_3.inc
+ --source have_engine.inc
+}
diff --git a/storage/vp/mysql-test/vp/spider/t/vp_fixes.test b/storage/vp/mysql-test/vp/spider/t/vp_fixes.test
new file mode 100644
index 00000000000..90380227040
--- /dev/null
+++ b/storage/vp/mysql-test/vp/spider/t/vp_fixes.test
@@ -0,0 +1,335 @@
+# This test tests for VP's bug fixes
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+--echo
+--echo 0.9
+--echo create different primary key table
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT AUTO_INCREMENT,
+ c INT DEFAULT 11,
+ PRIMARY KEY(b)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+eval CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT AUTO_INCREMENT,
+ c INT DEFAULT 11,
+ PRIMARY KEY(b)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+--enable_query_log
+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
+--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)`
+if ($MASTER_1_IS_VP)
+{
+ --error 14514
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+}
+if (!$MASTER_1_IS_VP)
+{
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ --disable_query_log
+ --disable_result_log
+ TRUNCATE TABLE ta_l_int;
+ --enable_query_log
+ --enable_result_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES5;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo create un-correspond primary key table
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l_int;
+--enable_warnings
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT DEFAULT 12,
+ c INT DEFAULT 11,
+ PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+eval CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT DEFAULT 12,
+ c INT DEFAULT 11,
+ PRIMARY KEY(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+--enable_query_log
+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;
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($MASTER_1_IS_VP)
+{
+ --error 14514
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+}
+if (!$MASTER_1_IS_VP)
+{
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ --disable_query_log
+ --disable_result_log
+ TRUNCATE TABLE ta_l_int;
+ --enable_query_log
+ --enable_result_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES5;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/suite.opt b/storage/vp/mysql-test/vp/suite.opt
new file mode 100644
index 00000000000..fece48adaed
--- /dev/null
+++ b/storage/vp/mysql-test/vp/suite.opt
@@ -0,0 +1,2 @@
+--loose-innodb
+--loose-partition
diff --git a/storage/vp/mysql-test/vp/suite.pm b/storage/vp/mysql-test/vp/suite.pm
new file mode 100644
index 00000000000..6ddc6e0dddb
--- /dev/null
+++ b/storage/vp/mysql-test/vp/suite.pm
@@ -0,0 +1,11 @@
+package My::Suite::Vp;
+
+@ISA = qw(My::Suite);
+
+return "No Vp engine" unless $ENV{HA_VP_SO};
+return "Not run for embedded server" if $::opt_embedded_server;
+
+sub is_default { 1 }
+
+bless { };
+
diff --git a/storage/vp/mysql-test/vp/t/basic_sql.test b/storage/vp/mysql-test/vp/t/basic_sql.test
new file mode 100644
index 00000000000..5bb040047fc
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/basic_sql.test
@@ -0,0 +1,2699 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create table ignore 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
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'f', '2008-07-01 10:21:39'),
+ (2, 'g', '2000-02-01 00:00:00'),
+ (3, 'j', '2007-05-04 20:03:11'),
+ (4, 'i', '2003-10-30 05:01:03'),
+ (5, 'h', '2001-10-31 23:59:59');
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+IGNORE SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ IGNORE SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ INSERT IGNORE INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ IGNORE SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create table ignore 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
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
+REPLACE SELECT a, b, c FROM tb_l;
+if ($MASTER_1_MERGE)
+{
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ REPLACE SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+ REPLACE INTO ta_l SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_MERGE)
+{
+ eval CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1
+ REPLACE SELECT a, b, c FROM tb_l;
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo create no index table
+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_TABLES3;
+ echo CHILD2_1_CREATE_TABLES3;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES3;
+ --enable_warnings
+ 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 ta_l_no_idx;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l_no_idx
+MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1
+SELECT a, b, c FROM tb_l;
+if ($MASTER_1_NEEDPK)
+{
+ --error ER_REQUIRES_PRIMARY_KEY
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l_no_idx (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1;
+ INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l;
+}
+if (!$MASTER_1_NEEDPK)
+{
+ if ($MASTER_1_MERGE)
+ {
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l_no_idx (
+ a INT,
+ b CHAR(1),
+ c DATETIME
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1;
+ INSERT INTO ta_l_no_idx SELECT a, b, c FROM tb_l;
+ }
+ if (!$MASTER_1_MERGE)
+ {
+ eval CREATE TABLE ta_l_no_idx
+ $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT2_2_1
+ SELECT a, b, c FROM tb_l;
+ }
+}
+--enable_query_log
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES3;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l_no_idx ORDER BY a;
+
+--echo
+--echo select table
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table shared mode
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+LOCK IN SHARE MODE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table for update
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a
+FOR UPDATE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table join
+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, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a, tb_l b
+WHERE a.a = b.a ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table straight_join
+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 STRAIGHT_JOIN a.a, a.b, date_format(b.c, '%Y-%m-%d %H:%i:%s')
+FROM ta_l a, tb_l b WHERE a.a = b.a ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_small_result
+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 SQL_SMALL_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_big_result
+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 SQL_BIG_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_buffer_result
+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 SQL_BUFFER_RESULT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_cache
+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 SQL_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_no_cache
+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 SQL_NO_CACHE a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select sql_calc_found_rows
+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 SQL_CALC_FOUND_ROWS a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a LIMIT 4;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT found_rows();
+
+--echo
+--echo select high_priority
+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 HIGH_PRIORITY a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select distinct
+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 DISTINCT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select count
+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 count(*) FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table join not use index
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE
+EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select using pushdown
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.b = 'g' ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select using index and pushdown
+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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l a WHERE
+a.a > 0 AND a.b = 'g' ORDER BY a.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo insert
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert select
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert select a
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert low_priority
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT LOW_PRIORITY INTO ta_l (a, b, c) values (2, 'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert high_priority
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT HIGH_PRIORITY INTO ta_l (a, b, c) VALUES (2, 'e',
+'2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert ignore
+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
+INSERT IGNORE INTO ta_l (a, b, c) VALUES (2, 'd', '2009-02-02 01:01:01');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert update (insert)
+--connection master_1
+TRUNCATE TABLE ta_l;
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo insert update (update)
+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
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59') ON DUPLICATE
+KEY UPDATE b = 'f', c = '2005-08-08 11:11:11';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace
+--connection master_1
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (2, 'e', '2008-01-01 23:59:59');
+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
+REPLACE INTO ta_l (a, b, c) VALUES (2, 'f', '2008-02-02 02:02:02');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace select
+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
+REPLACE INTO ta_l (a, b, c) SELECT a, b, c FROM tb_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace select a
+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
+REPLACE INTO ta_l (a, b, c) VALUES ((SELECT a FROM tb_l ORDER BY a LIMIT 1),
+'e', '2008-01-01 23:59:59');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo replace low_priority
+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
+REPLACE LOW_PRIORITY INTO ta_l (a, b, c) VALUES (3, 'g',
+'2009-03-03 03:03:03');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59');
+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
+UPDATE ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update select
+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
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a IN (SELECT a FROM
+tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update select a
+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
+UPDATE ta_l SET b = 'h', c = '2010-04-04 04:04:04' WHERE a = (SELECT a FROM
+tb_l ORDER BY a LIMIT 1);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update join
+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
+UPDATE ta_l a, tb_l b SET a.b = b.b, a.c = b.c WHERE a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update join a
+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
+UPDATE ta_l a, tb_l b SET a.b = 'g', a.c = '2009-03-03 03:03:03' WHERE
+a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update low_priority
+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
+UPDATE LOW_PRIORITY ta_l SET b = 'f', c = '2008-02-02 02:02:02' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update ignore
+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
+UPDATE IGNORE ta_l SET a = 1, b = 'g', c = '2009-03-03 03:03:03' WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update pushdown
+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
+update ta_l set b = 'j', c = '2009-03-03 03:03:03' where b = 'f';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo update index pushdown
+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
+UPDATE ta_l SET b = 'g', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'j';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete all
+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
+DELETE FROM ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete select
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a IN (SELECT a FROM tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete select a
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a = (SELECT a FROM tb_l ORDER BY a LIMIT 1);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete join
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE a FROM ta_l a, (SELECT a FROM tb_l ORDER BY a) b WHERE a.a = b.a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete low_priority
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE LOW_PRIORITY FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete ignore
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE IGNORE FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete quick
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE QUICK FROM ta_l WHERE a = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE b = 'e';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo delete index pushdown
+TRUNCATE TABLE ta_l;
+INSERT INTO ta_l (a, b, c) VALUES (1, 'e', '2008-01-01 23:59:59'),
+(2, 'e', '2008-01-01 23:59:59'), (3, 'e', '2008-01-01 23:59:59'),
+(4, 'e', '2008-01-01 23:59:59'), (5, 'e', '2008-01-01 23:59:59'),
+(6, 'e', '2008-01-01 23:59:59'), (7, 'e', '2008-01-01 23:59:59'),
+(8, 'e', '2008-01-01 23:59:59'), (9, 'e', '2008-01-01 23:59:59'),
+(10, 'j', '2008-01-01 23:59:59');
+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
+DELETE FROM ta_l WHERE a > 0 AND b = 'e';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo truncate
+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
+TRUNCATE TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/basic_sql_part.test b/storage/vp/mysql-test/vp/t/basic_sql_part.test
new file mode 100644
index 00000000000..e1638642ab7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/basic_sql_part.test
@@ -0,0 +1,571 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'f', '2008-07-01 10:21:39'),
+ (2, 'g', '2000-02-01 00:00:00'),
+ (3, 'j', '2007-05-04 20:03:11'),
+ (4, 'i', '2003-10-30 05:01:03'),
+ (5, 'h', '2001-10-31 23:59:59');
+
+--echo
+--echo create table with partition and select test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ if ($MASTER_1_MERGE)
+ {
+ --error ER_WRONG_OBJECT
+ eval CREATE TABLE ta_l2 (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ }
+ if (!$MASTER_1_MERGE)
+ {
+ eval CREATE TABLE ta_l2 (
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1
+ SELECT a, b, c FROM tb_l;
+ }
+ --enable_query_log
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo select partition using pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+ a.b = 'g' ORDER BY a.a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo select partition using index pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 a WHERE
+ a.a > 0 AND a.b = 'g' ORDER BY a.a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo update partition pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ UPDATE ta_l2 SET b = 'e', c = '2009-03-03 03:03:03' WHERE b = 'j';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo update partition index pushdown
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ UPDATE ta_l2 SET b = 'j', c = '2009-03-03 03:03:03' WHERE a > 0 AND b = 'e';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo delete partition pushdown
+if ($HAVE_PARTITION)
+{
+ TRUNCATE TABLE ta_l2;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ DELETE FROM ta_l2 WHERE b = 'g';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--echo
+--echo delete partition index pushdown
+if ($HAVE_PARTITION)
+{
+ TRUNCATE TABLE ta_l2;
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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
+ DELETE FROM ta_l2 WHERE a > 0 AND b = 'g';
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+}
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/connect_child2_1.inc b/storage/vp/mysql-test/vp/t/connect_child2_1.inc
new file mode 100644
index 00000000000..cd9b0c9ca9b
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child2_1.inc
@@ -0,0 +1 @@
+--connect (child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_child2_2.inc b/storage/vp/mysql-test/vp/t/connect_child2_2.inc
new file mode 100644
index 00000000000..e145f66b630
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child2_2.inc
@@ -0,0 +1 @@
+--connect (child2_2, localhost, root, , , $CHILD2_2_MYPORT, $CHILD2_2_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_child2_3.inc b/storage/vp/mysql-test/vp/t/connect_child2_3.inc
new file mode 100644
index 00000000000..d356348d8ea
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child2_3.inc
@@ -0,0 +1 @@
+--connect (child2_3, localhost, root, , , $CHILD2_3_MYPORT, $CHILD2_3_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_child3_1.inc b/storage/vp/mysql-test/vp/t/connect_child3_1.inc
new file mode 100644
index 00000000000..03e5c188c89
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child3_1.inc
@@ -0,0 +1 @@
+--connect (child3_1, localhost, root, , , $CHILD3_1_MYPORT, $CHILD3_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_child3_2.inc b/storage/vp/mysql-test/vp/t/connect_child3_2.inc
new file mode 100644
index 00000000000..d62a7ada824
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child3_2.inc
@@ -0,0 +1 @@
+--connect (child3_2, localhost, root, , , $CHILD3_2_MYPORT, $CHILD3_2_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_child3_3.inc b/storage/vp/mysql-test/vp/t/connect_child3_3.inc
new file mode 100644
index 00000000000..fb49f5bfdac
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_child3_3.inc
@@ -0,0 +1 @@
+--connect (child3_3, localhost, root, , , $CHILD3_3_MYPORT, $CHILD3_3_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_master_1.inc b/storage/vp/mysql-test/vp/t/connect_master_1.inc
new file mode 100644
index 00000000000..0c129ce5775
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_master_1.inc
@@ -0,0 +1 @@
+--connect (master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/connect_slave1_1.inc b/storage/vp/mysql-test/vp/t/connect_slave1_1.inc
new file mode 100644
index 00000000000..45a822743e0
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/connect_slave1_1.inc
@@ -0,0 +1 @@
+--connect (slave1_1, localhost, root, , , $SLAVE1_1_MYPORT, $SLAVE1_1_MYSOCK)
diff --git a/storage/vp/mysql-test/vp/t/direct_aggregate.test b/storage/vp/mysql-test/vp/t/direct_aggregate.test
new file mode 100644
index 00000000000..d65f4c5a624
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/direct_aggregate.test
@@ -0,0 +1,179 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo direct_aggregating 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
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT COUNT(*) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MAX(a) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MIN(a) FROM ta_l;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MAX(a) FROM ta_l WHERE a < 5;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+SELECT MIN(a) FROM ta_l WHERE a > 1;
+eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/direct_aggregate_part.test b/storage/vp/mysql-test/vp/t/direct_aggregate_part.test
new file mode 100644
index 00000000000..aebf210c745
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/direct_aggregate_part.test
@@ -0,0 +1,192 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT COUNT(*) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MAX(a) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MIN(a) FROM ta_l2;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MAX(a) FROM ta_l2 WHERE a < 5;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ SELECT MIN(a) FROM ta_l2 WHERE a > 1;
+ eval $MASTER_1_CHECK_DIRECT_AGGREGATE_STATUS;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/direct_update.test b/storage/vp/mysql-test/vp/t/direct_update.test
new file mode 100644
index 00000000000..e0901062201
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/direct_update.test
@@ -0,0 +1,198 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo direct_updating 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
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update all rows with function
+UPDATE ta_l SET c = ADDDATE(c, 1);
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by primary key
+UPDATE ta_l SET b = 'x' WHERE a = 3;
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by a column without index
+UPDATE ta_l SET c = '2011-10-17' WHERE b = 'x';
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo update by primary key with order and limit
+UPDATE ta_l SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by primary key with order and limit
+DELETE FROM ta_l WHERE a < 4 ORDER BY c LIMIT 1;
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by a column without index
+DELETE FROM ta_l WHERE b = 'c';
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+--echo delete by primary key
+DELETE FROM ta_l WHERE a = 3;
+eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/direct_update_part.test b/storage/vp/mysql-test/vp/t/direct_update_part.test
new file mode 100644
index 00000000000..95e2e2ab0d5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/direct_update_part.test
@@ -0,0 +1,211 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update all rows with function
+ UPDATE ta_l2 SET c = ADDDATE(c, 1);
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by primary key
+ UPDATE ta_l2 SET b = 'x' WHERE a = 3;
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by a column without index
+ UPDATE ta_l2 SET c = '2011-10-17' WHERE b = 'x';
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo update by primary key with order and limit
+ UPDATE ta_l2 SET c = ADDDATE(c, 1) WHERE a < 4 ORDER BY b DESC LIMIT 1;
+ eval $MASTER_1_CHECK_DIRECT_UPDATE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by primary key with order and limit
+ DELETE FROM ta_l2 WHERE a < 4 ORDER BY c LIMIT 1;
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by a column without index
+ DELETE FROM ta_l2 WHERE b = 'c';
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ --echo delete by primary key
+ DELETE FROM ta_l2 WHERE a = 3;
+ eval $MASTER_1_CHECK_DIRECT_DELETE_STATUS;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/fulltext.test b/storage/vp/mysql-test/vp/t/fulltext.test
new file mode 100644
index 00000000000..4c2462b8d84
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/fulltext.test
@@ -0,0 +1,181 @@
+# This test tests for fulltext searching
+if (!$USE_FULLTEXT_TEST)
+{
+ skip Please set 'USE_FULLTEXT_TEST=1' if you want to test for fulltext searching;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_FT_TABLES;
+ echo CHILD2_1_CREATE_FT_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_FT_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_FT_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ft_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ft_l (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_FT_2_1;
+eval CREATE TABLE ft_l (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_FT_2_1;
+--enable_query_log
+INSERT INTO ft_l (a,b,c,d) VALUES
+(1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+(2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+(3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+(4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+(5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+
+--echo
+--echo fulltext search
+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, b, c, d from ft_l where match(b) against('fedc');
+select a, b, c, d from ft_l where match(c) against('hgfe');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/fulltext_part.test b/storage/vp/mysql-test/vp/t/fulltext_part.test
new file mode 100644
index 00000000000..e78fda1aafe
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/fulltext_part.test
@@ -0,0 +1,195 @@
+# This test tests for fulltext searching
+if (!$USE_FULLTEXT_TEST)
+{
+ skip Please set 'USE_FULLTEXT_TEST=1' if you want to test for fulltext searching;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_FT_TABLES;
+ echo CHILD2_2_CREATE_FT_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_FT_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_FT_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_FT_TABLES2;
+ echo CHILD2_1_CREATE_FT_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_FT_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_FT_TABLES2;
+ 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 ft_l2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_FT_P_2_1;
+ eval CREATE TABLE ft_l2 (
+ a INT DEFAULT 0,
+ b TEXT,
+ c TEXT,
+ d TEXT,
+ PRIMARY KEY(a),
+ FULLTEXT INDEX ft_idx1(b),
+ FULLTEXT INDEX ft_idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_FT_P_2_1;
+ INSERT INTO ft_l2 (a,b,c,d) VALUES
+ (1,'aaaa abcd dcba','bbbb bcde edcb','cccc cdef fedc'),
+ (2,'bbbb bcde edcb','cccc cdef fedc','dddd defg gfed'),
+ (3,'cccc cdef fedc','dddd defg gfed','eeee efgh hgfe'),
+ (4,'dddd defg gfed','eeee efgh hgfe','ffff fghi ihgf'),
+ (5,'eeee efgh hgfe','ffff fghi ihgf','gggg ghij jihg');
+ --enable_query_log
+ select a, b, c, d from ft_l2 where match(b) against('fedc');
+ select a, b, c, d from ft_l2 where match(c) against('hgfe');
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_FT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_FT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/function.test b/storage/vp/mysql-test/vp/t/function.test
new file mode 100644
index 00000000000..ec2eeab9c94
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/function.test
@@ -0,0 +1,253 @@
+# This test tests for using functions
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo in()
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TEXT_PK_TABLES1;
+ echo CHILD2_1_CREATE_TEXT_PK_TABLES1;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TEXT_PK_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TEXT_PK_TABLES1;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET3 MASTER_1_COMMENT_TEXT_PK1_1;
+eval CREATE TABLE t1 (
+ a VARCHAR(255),
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET3 $MASTER_1_COMMENT_TEXT_PK1_1;
+--enable_query_log
+insert into t1 values ('1');
+insert into t1 select a + 1 from t1;
+insert into t1 select a + 2 from t1;
+insert into t1 select a + 4 from t1;
+insert into t1 select a + 8 from t1;
+insert into t1 select a + 16 from t1;
+insert into t1 select a + 32 from t1;
+insert into t1 select a + 64 from t1;
+insert into t1 select a + 128 from t1;
+insert into t1 select a + 256 from t1;
+insert into t1 select a + 512 from t1;
+flush tables;
+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 from t1 where a in ('15', '120');
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo date_sub()
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 YEAR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 QUARTER);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MONTH);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 WEEK);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 DAY);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 HOUR);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_SUB(c, INTERVAL 1 MINUTE);
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+UPDATE ta_l SET c = DATE_ADD(c, INTERVAL 1 SECOND);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/geometry.test b/storage/vp/mysql-test/vp/t/geometry.test
new file mode 100644
index 00000000000..d0ae07ed78f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/geometry.test
@@ -0,0 +1,192 @@
+# This test tests for geometry
+if (!$USE_GEOMETRY_TEST)
+{
+ skip Please set 'USE_GEOMETRY_TEST=1' if you want to test for geometry;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_GM_TABLES;
+ echo CHILD2_1_CREATE_GM_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_GM_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_GM_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS gm_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1;
+eval CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_GM_2_1;
+--enable_query_log
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+--echo
+--echo geometry search
+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 AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/geometry_normal.test b/storage/vp/mysql-test/vp/t/geometry_normal.test
new file mode 100644
index 00000000000..0b7884ef1a7
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/geometry_normal.test
@@ -0,0 +1,81 @@
+# This test tests for geometry
+if (!$USE_GEOMETRY_TEST)
+{
+ skip Please set 'USE_GEOMETRY_TEST=1' if you want to test for geometry;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+SELECT 1;
+
+--echo
+--echo create table and insert
+--disable_warnings
+DROP TABLE IF EXISTS gm_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) ENGINE=MyISAM MASTER_1_CHARSET MASTER_1_COMMENT_GM_2_1;
+eval CREATE TABLE gm_l (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+) ENGINE=MyISAM $MASTER_1_CHARSET $MASTER_1_COMMENT_GM_2_1;
+--enable_query_log
+INSERT INTO gm_l (a,b,c) VALUES
+( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+(10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+(11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+(12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+
+--echo
+--echo geometry search
+SELECT AsText(b) FROM gm_l WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+SELECT AsText(c) FROM gm_l WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+SELECT AsText(c) FROM gm_l WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+
+--echo
+--echo deinit
+--disable_warnings
+DROP DATABASE IF EXISTS auto_test_local;
+--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/vp/mysql-test/vp/t/geometry_part.test b/storage/vp/mysql-test/vp/t/geometry_part.test
new file mode 100644
index 00000000000..12fc169c000
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/geometry_part.test
@@ -0,0 +1,206 @@
+# This test tests for geometry
+if (!$USE_GEOMETRY_TEST)
+{
+ skip Please set 'USE_GEOMETRY_TEST=1' if you want to test for geometry;
+}
+
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_GM_TABLES;
+ echo CHILD2_2_CREATE_GM_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_GM_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_GM_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_GM_TABLES2;
+ echo CHILD2_1_CREATE_GM_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_GM_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_GM_TABLES2;
+ 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 gm_l2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_GM_P_2_1;
+ eval CREATE TABLE gm_l2 (
+ a INT DEFAULT 0,
+ b GEOMETRY NOT NULL,
+ c GEOMETRY NOT NULL,
+ PRIMARY KEY(a),
+ SPATIAL INDEX sp_idx1(b),
+ SPATIAL INDEX sp_idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_GM_P_2_1;
+ INSERT INTO gm_l2 (a,b,c) VALUES
+ ( 1, GeomFromText('Point(30000 15000)'), GeomFromText('Point(80000 15000)')),
+ ( 2, GeomFromText('Point(30000 16000)'), GeomFromText('Point(80000 16000)')),
+ ( 3, GeomFromText('Point(40000 15000)'), GeomFromText('Point(70000 15000)')),
+ ( 4, GeomFromText('Point(40000 16000)'), GeomFromText('Point(70000 16000)')),
+ ( 5, GeomFromText('Point(50000 15000)'), GeomFromText('Point(60000 15000)')),
+ ( 6, GeomFromText('Point(50000 16000)'), GeomFromText('Point(60000 16000)')),
+ ( 7, GeomFromText('Point(60000 15000)'), GeomFromText('Point(50000 15000)')),
+ ( 8, GeomFromText('Point(60000 16000)'), GeomFromText('Point(50000 16000)')),
+ ( 9, GeomFromText('Point(70000 15000)'), GeomFromText('Point(40000 15000)')),
+ (10, GeomFromText('Point(70000 16000)'), GeomFromText('Point(40000 16000)')),
+ (11, GeomFromText('Point(80000 15000)'), GeomFromText('Point(30000 15000)')),
+ (12, GeomFromText('Point(80000 16000)'), GeomFromText('Point(30000 16000)'));
+ --enable_query_log
+ SELECT AsText(b) FROM gm_l2 WHERE MBRContains(GeomFromText('Polygon((40000 15000,41000 15000,41000 16000,40000 16000,40000 15000))'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRContains(GeomFromText('Point(40000 15000)'),c);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRWithin(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRDisjoint(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBREqual(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRIntersects(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBROverlaps(GeomFromText('Point(40000 15000)'),b);
+ SELECT AsText(c) FROM gm_l2 WHERE MBRTouches(GeomFromText('Point(40000 15000)'),b);
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_GM_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_GM_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/ha.test b/storage/vp/mysql-test/vp/t/ha.test
new file mode 100644
index 00000000000..c12930e4aed
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/ha.test
@@ -0,0 +1,878 @@
+# This test tests for ha features
+if ($USE_HA_TEST)
+{
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source ha_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+ CREATE DATABASE auto_test_remote3;
+ USE auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ --connection child2_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ SELECT 1;
+ --connection child3_2
+ SELECT 1;
+ --connection child3_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--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;
+ }
+ --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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo fail-over 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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_HA_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_HA_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_CHECK_HA_STATUS;
+--error 12511
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+eval $MASTER_1_CHECK_HA_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo recovery 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;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_HA_CREATE_TABLES;
+ }
+ eval $CHILD2_2_HA_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
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_RECOVERY_STATUS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_RECOVERY_STATUS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_COPY_TABLES_2_1;
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_OK_STATUS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+DROP TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+eval $MASTER_1_CHANGE_HA_MON;
+
+--echo
+--echo active standby test
+--echo create table test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_AS_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_AS_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_AS_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--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;
+ }
+ --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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo fail-over 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;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_HA_AS_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_HA_AS_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_CHECK_HA_STATUS;
+--error 12511
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+eval $MASTER_1_CHECK_LINK_STATUS;
+eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+eval $MASTER_1_CHECK_HA_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo recovery test
+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_HA_AS_CREATE_TABLES;
+ }
+ eval $CHILD2_1_HA_AS_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_AS_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+eval $MASTER_1_SET_OK_STATUS_AS_2_1;
+eval $MASTER_1_CHECK_LINK_STATUS;
+INSERT INTO ta_l (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30');
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+DROP TABLE ta_l;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+eval $MASTER_1_CHANGE_HA_MON;
+
+--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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+}
+--disable_query_log
+--disable_result_log
+--source ha_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+}
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/ha_part.test b/storage/vp/mysql-test/vp/t/ha_part.test
new file mode 100644
index 00000000000..72ddcfd1f10
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/ha_part.test
@@ -0,0 +1,1017 @@
+# This test tests for ha features
+if ($USE_HA_TEST)
+{
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source ha_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source ha_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+ CREATE DATABASE auto_test_remote3;
+ USE auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ --connection child2_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+if ($USE_CHILD_GROUP3)
+{
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ SELECT 1;
+ --connection child3_2
+ SELECT 1;
+ --connection child3_3
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+if ($HAVE_PARTITION)
+{
+ --echo
+ --echo create table with partition test
+ 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_TABLES2;
+ echo CHILD2_1_CREATE_TABLES;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ eval $CHILD2_1_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_DROP_TABLES;
+ echo CHILD2_3_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_3_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_P_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_P_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_P_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+ --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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo fail-over 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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_HA_DROP_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_HA_DROP_TABLES;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_CHECK_HA_STATUS;
+ --error 12511
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+ eval $MASTER_1_CHECK_HA_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo recovery 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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_HA_CREATE_TABLES;
+ }
+ eval $CHILD2_3_HA_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_RECOVERY_STATUS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_COPY_TABLES_P_2_1;
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_OK_STATUS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30'),
+ (9, 'h', '2011-05-05 22:32:10');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ DROP TABLE ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+if ($HAVE_PARTITION)
+{
+ --echo
+ --echo create table with partition test
+ 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_TABLES2;
+ echo CHILD2_1_CREATE_TABLES;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ eval $CHILD2_1_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_3_DROP_TABLES;
+ echo CHILD2_3_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_3_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_3_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
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_1_CREATE_TABLES_HA_AS_P_2_1;
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_2_CREATE_TABLES_HA_AS_P_2_1;
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ eval $CHILD3_3_CREATE_TABLES_HA_AS_P_2_1;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_HA_AS_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_HA_AS_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+ --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;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo fail-over test
+ 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_HA_AS_DROP_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_HA_AS_DROP_TABLES2;
+ --enable_warnings
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_CHECK_HA_STATUS;
+ --error 12511
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ eval $MASTER_1_CHECK_LINK_FAILED_LOG;
+ eval $MASTER_1_CHECK_HA_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (6, 'e', '2011-05-05 20:04:05');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ eval $CHILD3_1_CHECK_LINK_FAILED_LOG;
+ --connection child3_2
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ eval $CHILD3_2_CHECK_LINK_FAILED_LOG;
+ --connection child3_3
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ eval $CHILD3_3_CHECK_LINK_FAILED_LOG;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+
+ --echo
+ --echo recovery test
+ 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_HA_AS_CREATE_TABLES2;
+ }
+ eval $CHILD2_1_HA_AS_CREATE_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ eval $CHILD3_1_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_1_CHECK_LINK_STATUS;
+ --connection child3_2
+ eval $CHILD3_2_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_2_CHECK_LINK_STATUS;
+ --connection child3_3
+ eval $CHILD3_3_SET_OK_STATUS_AS_P_2_1;
+ eval $CHILD3_3_CHECK_LINK_STATUS;
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ eval $MASTER_1_SET_OK_STATUS_AS_P_2_1;
+ eval $MASTER_1_CHECK_LINK_STATUS;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (8, 'g', '2011-05-05 21:33:30'),
+ (9, 'h', '2011-05-05 22:32:10');
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 ORDER BY a;
+ DROP TABLE ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ eval $CHILD2_1_SELECT_TABLES2;
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_3
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_3_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ if ($USE_CHILD_GROUP3)
+ {
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child3_1
+ --disable_warnings
+ eval $CHILD3_1_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_2
+ --disable_warnings
+ eval $CHILD3_2_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ --connection child3_3
+ --disable_warnings
+ eval $CHILD3_3_DROP_TABLES_HA_P_2_1;
+ --enable_warnings
+ if (!$OUTPUT_CHILD_GROUP3)
+ {
+ --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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ --connection child2_3
+ DROP DATABASE IF EXISTS auto_test_remote3;
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_2
+ DROP DATABASE IF EXISTS auto_test_local;
+ --connection child3_3
+ DROP DATABASE IF EXISTS auto_test_local;
+}
+--disable_query_log
+--disable_result_log
+--source ha_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+}
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/ha_test_deinit.inc b/storage/vp/mysql-test/vp/t/ha_test_deinit.inc
new file mode 100644
index 00000000000..53d0409d066
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/ha_test_deinit.inc
@@ -0,0 +1,30 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/ha_deinit_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/ha_deinit_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/ha_deinit_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/ha_deinit_child2_3.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/ha_deinit_child3_1.inc
+ --echo child3_2
+ --connection child3_2
+ --source ../include/ha_deinit_child3_2.inc
+ --echo child3_3
+ --connection child3_3
+ --source ../include/ha_deinit_child3_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/t/ha_test_init.inc b/storage/vp/mysql-test/vp/t/ha_test_init.inc
new file mode 100644
index 00000000000..70576ab16dc
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/ha_test_init.inc
@@ -0,0 +1,30 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/ha_init_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/ha_init_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/ha_init_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/ha_init_child2_3.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/ha_init_child3_1.inc
+ --echo child3_2
+ --connection child3_2
+ --source ../include/ha_init_child3_2.inc
+ --echo child3_3
+ --connection child3_3
+ --source ../include/ha_init_child3_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/t/handler.test b/storage/vp/mysql-test/vp/t/handler.test
new file mode 100644
index 00000000000..378fd4c10af
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/handler.test
@@ -0,0 +1,188 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo create table select test
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES;
+ echo CHILD2_1_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo handler 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
+HANDLER ta_l OPEN a;
+HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` LAST LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ `PRIMARY` PREV LIMIT 2;
+HANDLER a READ FIRST LIMIT 2;
+HANDLER a READ NEXT LIMIT 2;
+HANDLER a READ NEXT LIMIT 2;
+HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+HANDLER a READ FIRST WHERE b = 'c';
+HANDLER a CLOSE;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/handler_part.test b/storage/vp/mysql-test/vp/t/handler_part.test
new file mode 100644
index 00000000000..fa94a0ffe5a
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/handler_part.test
@@ -0,0 +1,201 @@
+# This test tests by executing basic SQL
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo handler with partition test
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+ INSERT INTO ta_l2 (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+ --enable_query_log
+ HANDLER ta_l2 OPEN a;
+ HANDLER a READ `PRIMARY` >= (2) LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` <= (4) LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` FIRST LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` LAST LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ `PRIMARY` PREV LIMIT 2;
+ HANDLER a READ FIRST LIMIT 2;
+ HANDLER a READ NEXT LIMIT 2;
+ HANDLER a READ NEXT LIMIT 2;
+ HANDLER a READ `PRIMARY` > (1) WHERE b = 'd';
+ HANDLER a READ FIRST WHERE b = 'c';
+ HANDLER a CLOSE;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/mysql-test/vp/t/have_engine.inc b/storage/vp/mysql-test/vp/t/have_engine.inc
new file mode 100644
index 00000000000..64bef7499cb
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/have_engine.inc
@@ -0,0 +1,7 @@
+if (!`SELECT count(*) FROM information_schema.engines WHERE
+ (support = 'YES' OR support = 'DEFAULT') AND
+ engine = '$TEST_ENGINE_TYPE'`)
+{
+ SELECT engine, support FROM information_schema.engines;
+ --let $SKIP_REASON= "Need $TEST_ENGINE_TYPE engine"
+}
diff --git a/storage/vp/mysql-test/vp/t/have_func.inc b/storage/vp/mysql-test/vp/t/have_func.inc
new file mode 100644
index 00000000000..e0823e73fc8
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/have_func.inc
@@ -0,0 +1,5 @@
+if (!`SELECT count(*) FROM mysql.func WHERE name = '$TEST_FUNC_NAME'`)
+{
+ SELECT name FROM mysql.func;
+ --let $SKIP_REASON= "Need $TEST_FUNC_NAME function"
+}
diff --git a/storage/vp/mysql-test/vp/t/have_partition.inc b/storage/vp/mysql-test/vp/t/have_partition.inc
new file mode 100644
index 00000000000..b6e699475db
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/have_partition.inc
@@ -0,0 +1,7 @@
+let $HAVE_PARTITION= 0;
+if (`SELECT count(*) FROM information_schema.plugins WHERE
+ plugin_status = 'ACTIVE' AND
+ plugin_name = 'partition'`)
+{
+ let $HAVE_PARTITION= 1;
+}
diff --git a/storage/vp/mysql-test/vp/t/have_plugin.inc b/storage/vp/mysql-test/vp/t/have_plugin.inc
new file mode 100644
index 00000000000..316ede9ec46
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/have_plugin.inc
@@ -0,0 +1,5 @@
+if (!`SELECT count(*) FROM information_schema.plugins WHERE plugin_name = '$TEST_PLUGIN_NAME'`)
+{
+ SELECT plugin_name FROM information_schema.plugins;
+ --let $SKIP_REASON= "Need $TEST_PLUGIN_NAME plugin"
+}
diff --git a/storage/vp/mysql-test/vp/t/have_trigger.inc b/storage/vp/mysql-test/vp/t/have_trigger.inc
new file mode 100644
index 00000000000..32de484b388
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/have_trigger.inc
@@ -0,0 +1,2 @@
+let $HAVE_TRIGGER= `SELECT COUNT(*) FROM information_schema.tables
+ WHERE TABLE_SCHEMA = 'information_schema' AND TABLE_NAME = 'TRIGGERS'`;
diff --git a/storage/vp/mysql-test/vp/t/hs_test_deinit.inc b/storage/vp/mysql-test/vp/t/hs_test_deinit.inc
new file mode 100644
index 00000000000..7ec2e981fd2
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/hs_test_deinit.inc
@@ -0,0 +1,17 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/hs_deinit_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/hs_deinit_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/hs_deinit_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/hs_deinit_child2_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/t/hs_test_init.inc b/storage/vp/mysql-test/vp/t/hs_test_init.inc
new file mode 100644
index 00000000000..831bf479524
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/hs_test_init.inc
@@ -0,0 +1,17 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/hs_init_master_1.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/hs_init_child2_1.inc
+ --echo child2_2
+ --connection child2_2
+ --source ../include/hs_init_child2_2.inc
+ --echo child2_3
+ --connection child2_3
+ --source ../include/hs_init_child2_3.inc
+}
diff --git a/storage/vp/mysql-test/vp/t/slave_test_deinit.inc b/storage/vp/mysql-test/vp/t/slave_test_deinit.inc
new file mode 100644
index 00000000000..e9d99b7a960
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/slave_test_deinit.inc
@@ -0,0 +1,6 @@
+# get connection and exist engine test
+--echo for slave1_1
+--connection slave1_1
+STOP SLAVE;
+--source ../include/deinit_slave1_1.inc
+--disconnect slave1_1
diff --git a/storage/vp/mysql-test/vp/t/slave_test_init.inc b/storage/vp/mysql-test/vp/t/slave_test_init.inc
new file mode 100644
index 00000000000..739d88970c5
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/slave_test_init.inc
@@ -0,0 +1,44 @@
+# get connection and exist engine test
+--echo for slave1_1
+--source connect_slave1_1.inc
+--connection slave1_1
+SET SESSION sql_log_bin= 0;
+--let $SLAVE1_1_SERVER_ID=`SELECT @@global.server_id`
+--let $TEST_ENGINE_TYPE= $SLAVE1_1_ENGINE_TYPE
+--source have_partition.inc
+--source have_trigger.inc
+--source ../include/init_slave1_1.inc
+--source have_engine.inc
+--let $SLAVE1_1_SLAVE_STATUS=`SHOW SLAVE STATUS`
+if (!$SLAVE1_1_SLAVE_STATUS)
+{
+ eval CHANGE MASTER TO
+ MASTER_HOST = '127.0.0.1',
+ MASTER_USER = 'root',
+ MASTER_PASSWORD = '',
+ MASTER_PORT = $MASTER_1_MYPORT
+ ;
+}
+START SLAVE;
+--connection master_1
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--connection slave1_1
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child2_2
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child2_3
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+}
+if ($USE_CHILD_GROUP3)
+{
+ --connection child3_1
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child3_2
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+ --connection child3_3
+ call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+}
diff --git a/storage/vp/mysql-test/vp/t/spider3_fixes.test b/storage/vp/mysql-test/vp/t/spider3_fixes.test
new file mode 100644
index 00000000000..13fa6f5fa39
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/spider3_fixes.test
@@ -0,0 +1,292 @@
+# This test tests for Spider 3.0's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo 3.1
+--echo auto_increment
+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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+if ($USE_REPLICATION)
+{
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ --connection master_1
+}
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t2 ORDER BY id;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+INSERT INTO t2 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t2 ORDER BY id;
+SET INSERT_ID=5000;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+--disable_query_log
+echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+--enable_query_log
+INSERT INTO t2 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t2 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t2;
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/spider3_fixes_part.test b/storage/vp/mysql-test/vp/t/spider3_fixes_part.test
new file mode 100644
index 00000000000..3288c490a46
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/spider3_fixes_part.test
@@ -0,0 +1,345 @@
+# This test tests for Spider 3.0's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source slave_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo auto_increment with partition
+if ($HAVE_PARTITION)
+{
+ 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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_INCREMENT_TABLES1;
+ echo CHILD2_2_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+ if ($USE_REPLICATION)
+ {
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1, t2;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ echo CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ --connection master_1
+ }
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t2 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t2 ORDER BY id;
+ TRUNCATE TABLE t1;
+ TRUNCATE TABLE t2;
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ INSERT INTO t2 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t2 ORDER BY id;
+ SET INSERT_ID=5000;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET3;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ --disable_query_log
+ echo MASTER_1_AUTO_INCREMENT_OFFSET4;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
+ --enable_query_log
+ INSERT INTO t2 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ INSERT INTO t1 (id) VALUES (10000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t2 (id) VALUES (1000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t2;
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/spider_fixes.test b/storage/vp/mysql-test/vp/t/spider_fixes.test
new file mode 100644
index 00000000000..04e806fb612
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/spider_fixes.test
@@ -0,0 +1,1419 @@
+# This test tests for Spider's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+--echo
+--echo 2.13
+--echo select table with "order by desc" and "<"
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a < 5 ORDER BY a DESC LIMIT 3;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo select table with "order by desc" and "<="
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l
+WHERE a <= 5 ORDER BY a DESC LIMIT 3;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.14
+--echo update table with range scan and split_read
+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
+UPDATE ta_l SET c = '2000-02-02 00:00:00' WHERE a > 1;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l ORDER BY a;
+
+--echo
+--echo 2.15
+--echo select table with range scan
+TRUNCATE TABLE ta_l;
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+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_TABLES6;
+ echo CHILD2_1_CREATE_TABLES6;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES6;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES6;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l (
+ a int(11) NOT NULL DEFAULT '0',
+ b char(1) DEFAULT NULL,
+ c datetime DEFAULT NULL,
+ PRIMARY KEY (a, b, c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1;
+eval CREATE TABLE ta_l (
+ a int(11) NOT NULL DEFAULT '0',
+ b char(1) DEFAULT NULL,
+ c datetime DEFAULT NULL,
+ PRIMARY KEY (a, b, c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT5_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+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, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a >= 4 AND b = 'd'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a > 4 AND b = 'c'
+AND c = '2001-12-31 23:59:59';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b <= 'd'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b < 'e'
+AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND b = 'b'
+AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b >= 'b'
+AND b <= 'd' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a = 4 AND b > 'b'
+AND b < 'e' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a <= 4 AND a >= 1
+AND b >= 'b' AND c = '2003-11-30 05:01:03';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l FORCE INDEX(PRIMARY) WHERE a < 4 AND a > 1
+AND b >= 'b' AND c = '2000-01-01 00:00:00';
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.16
+--echo auto_increment insert with trigger
+if ($HAVE_TRIGGER)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES4;
+ echo CHILD2_1_CREATE_TABLES4;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES4;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES4;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_query_log
+ echo CREATE TABLE ta_l_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1;
+ eval CREATE TABLE ta_l_auto_inc (
+ a INT AUTO_INCREMENT,
+ b CHAR(1) DEFAULT 'c',
+ c DATETIME DEFAULT '1999-10-10 10:10:10',
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT3_2_1;
+ echo CREATE TABLE tc_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+ eval CREATE TABLE tc_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+ --enable_query_log
+ --eval CREATE TRIGGER ins_ta_l_auto_inc AFTER INSERT ON ta_l_auto_inc FOR EACH ROW BEGIN INSERT INTO tc_l (a, b, c) VALUES (NEW.a, NEW.b, NEW.c); END;
+ 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;
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ INSERT INTO ta_l_auto_inc (a, b, c) VALUES
+ (NULL, 's', '2008-12-31 20:59:59');
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES4;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM tc_l ORDER BY a;
+}
+
+--echo
+--echo 2.17
+--echo engine-condition-pushdown with "or" and joining
+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, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l WHERE a = 1 OR a IN (SELECT a FROM tb_l);
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.23
+--echo index merge
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ 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 ta_l_int (
+ 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 ta_l_int (a, b, c) VALUES (1, 2, 3);
+INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+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, b, c FROM ta_l_int force index(primary, idx1, idx2)
+WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo
+--echo 2.24
+--echo index scan update without PK
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l_int;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+if ($MASTER_1_NEEDPK)
+{
+ --error ER_REQUIRES_PRIMARY_KEY
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ 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;
+}
+if (!$MASTER_1_NEEDPK)
+{
+ eval CREATE TABLE ta_l_int (
+ a INT NOT NULL,
+ b INT DEFAULT 10,
+ c INT DEFAULT 11,
+ KEY idx1(b),
+ KEY idx2(c)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+}
+--enable_query_log
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+INSERT INTO ta_l_int (a, b, c) VALUES (0, 2, 3);
+INSERT INTO ta_l_int (a, b, c) VALUES (18, 2, 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;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+UPDATE ta_l_int SET c = 4 WHERE b = 2;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+SELECT a, b, c FROM ta_l_int ORDER BY a;
+
+
+--echo
+--echo 2.25
+--echo direct order limit
+--connection master_1
+eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS;
+SELECT a, b, c FROM ta_l_int ORDER BY a LIMIT 3;
+eval $MASTER_1_CHECK_DIRECT_ORDER_LIMIT_STATUS;
+
+
+--echo
+--echo 2.26
+--echo lock tables
+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_LOCK_TABLES1;
+ echo CHILD2_1_DROP_LOCK_TABLES2;
+ echo CHILD2_1_CREATE_LOCK_TABLES1;
+ echo CHILD2_1_CREATE_LOCK_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_LOCK_TABLES1;
+ eval $CHILD2_1_DROP_LOCK_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_LOCK_TABLES1;
+ eval $CHILD2_1_CREATE_LOCK_TABLES2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_LOCK_TABLES1;
+ echo CHILD2_2_DROP_LOCK_TABLES2;
+ echo CHILD2_2_CREATE_LOCK_TABLES1;
+ echo CHILD2_2_CREATE_LOCK_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_LOCK_TABLES1;
+ eval $CHILD2_2_DROP_LOCK_TABLES2;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_LOCK_TABLES1;
+ eval $CHILD2_2_CREATE_LOCK_TABLES2;
+ 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 t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK1;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK1;
+echo CREATE TABLE t2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_LOCK2;
+eval CREATE TABLE t2 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_LOCK2;
+--enable_query_log
+LOCK TABLES t1 READ, t2 READ;
+UNLOCK TABLES;
+
+
+--echo
+--echo auto_increment
+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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
+echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
+eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+if ($USE_REPLICATION)
+{
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
+ --connection master_1
+}
+--enable_query_log
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (null);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 () VALUES (),(),(),();
+SELECT LAST_INSERT_ID();
+SELECT id FROM t1 ORDER BY id;
+SET INSERT_ID=5000;
+INSERT INTO t1 () VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (10000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+INSERT INTO t1 (id) VALUES (1000);
+SELECT LAST_INSERT_ID();
+SELECT MAX(id) FROM t1;
+if ($USE_REPLICATION)
+{
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo read only
+let $MASTER_1_ENGINE_IS_SPIDER=
+ `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'Spider' OR
+ '$MASTER_1_HIDDEN_ENGINE_TYPE' = 'Spider', 1, 0)`;
+if ($MASTER_1_ENGINE_IS_SPIDER)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_READONLY1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_READONLY1_1;
+ --let $MIN_VAL= `SELECT MIN(id) FROM t1`
+ --enable_query_log
+ SELECT id FROM t1 ORDER BY id;
+ --error 12518
+ INSERT INTO t1 (id) VALUES (1);
+ --error 12518
+ eval UPDATE t1 SET id = 4 WHERE id = $MIN_VAL;
+ --error 12518
+ eval DELETE FROM t1 WHERE id = $MIN_VAL;
+ --error 12518
+ DELETE FROM t1;
+ --error 12518
+ TRUNCATE t1;
+}
+if (!$MASTER_1_ENGINE_IS_SPIDER)
+{
+ --echo skipped
+}
+
+
+--echo
+--echo 2.27
+--echo error mode
+if ($MASTER_1_ENGINE_IS_SPIDER)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_ERROR_MODE1_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_ERROR_MODE1_1;
+ --enable_query_log
+ SELECT id FROM t1 ORDER BY id;
+ INSERT INTO t1 (id) VALUES (1);
+ DELETE FROM t1;
+ TRUNCATE t1;
+}
+if (!$MASTER_1_ENGINE_IS_SPIDER)
+{
+ --echo skipped
+}
+
+
+--echo
+--echo 3.0
+--echo is null
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TEXT_KEY_TABLES1;
+ echo CHILD2_1_CREATE_TEXT_KEY_TABLES1;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TEXT_KEY_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TEXT_KEY_TABLES1;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_TEXT_KEY1_1;
+eval CREATE TABLE t1 (
+ a VARCHAR(255),
+ b VARCHAR(255),
+ c VARCHAR(255),
+ KEY idx1(a,b),
+ KEY idx2(b),
+ PRIMARY KEY(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_TEXT_KEY1_1;
+--enable_query_log
+insert into t1 values (null, null, '2048');
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a + 32, b + 32, c + 32 from t1;
+insert into t1 select a + 64, b + 64, c + 64 from t1;
+insert into t1 select a + 128, b + 128, c + 128 from t1;
+insert into t1 select a + 256, b + 256, c + 256 from t1;
+insert into t1 select a + 512, b + 512, c + 512 from t1;
+flush tables;
+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 from t1 where a is null order by a limit 30;
+select b from t1 where b is null order by b limit 30;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+
+--echo
+--echo direct_order_limit
+--connection master_1
+TRUNCATE TABLE t1;
+insert into t1 values ('1', '1', '1');
+insert into t1 select a + 1, b + 1, c + 1 from t1;
+insert into t1 select a + 2, b + 2, c + 2 from t1;
+insert into t1 select a + 4, b + 4, c + 4 from t1;
+insert into t1 select a + 8, b + 8, c + 8 from t1;
+insert into t1 select a + 16, b + 16, c + 16 from t1;
+insert into t1 select a, b + 32, c + 32 from t1;
+insert into t1 select a, b + 64, c + 64 from t1;
+insert into t1 select a, b + 128, c + 128 from t1;
+flush tables;
+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, b, c from t1 where a = '10' and b <> '100' order by c desc limit 5;
+select a, c from t1 where a = '10' order by b desc limit 5;
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TEXT_PK_TABLES1;
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/spider_fixes_part.test b/storage/vp/mysql-test/vp/t/spider_fixes_part.test
new file mode 100644
index 00000000000..ef5a8026c02
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/spider_fixes_part.test
@@ -0,0 +1,645 @@
+# This test tests for Spider's bug fixes
+source include/have_log_bin.inc;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--source slave_test_init.inc
+--enable_result_log
+--enable_query_log
+if (!$HAVE_PARTITION)
+{
+ --disable_query_log
+ --disable_result_log
+ --source slave_test_deinit.inc
+ --source test_deinit.inc
+ --enable_result_log
+ --enable_query_log
+ --enable_warnings
+ skip Test requires partitioning;
+}
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_REPLICATION)
+{
+ --connection slave1_1
+ DROP DATABASE IF EXISTS auto_test_local;
+ CREATE DATABASE auto_test_local;
+ USE auto_test_local;
+}
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ SELECT 1;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo 2.17
+--echo partition with sort
+if ($HAVE_PARTITION)
+{
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2 WHERE a > 1
+ ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo
+--echo 2.23
+--echo partition update with moving partition
+if ($HAVE_PARTITION)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l2;
+ --enable_warnings
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_TABLES;
+ echo CHILD2_2_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_DROP_TABLES2;
+ echo CHILD2_1_CREATE_TABLES2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES2;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES2;
+ 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 ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
+ eval CREATE TABLE ta_l2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+ ) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l2 (a, b, c) VALUES (3, 'B', '2010-09-26 00:00:00');
+ UPDATE ta_l2 SET a = 4 WHERE a = 3;
+ SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_l2;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_2_SELECT_TABLES;
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %';
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %';
+ }
+ eval $CHILD2_1_SELECT_TABLES2;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+--echo index merge with partition
+if ($HAVE_PARTITION)
+{
+ --connection master_1
+ --disable_warnings
+ DROP TABLE IF EXISTS ta_l_int;
+ --enable_warnings
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_2_DROP_TABLES5;
+ echo CHILD2_2_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_TABLES5;
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ --disable_query_log
+ echo CREATE TABLE ta_l_int (
+ 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_COMMENT3_P_2_1;
+ eval CREATE TABLE ta_l_int (
+ 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_COMMENT3_P_2_1;
+ --enable_query_log
+ INSERT INTO ta_l_int (a, b, c) VALUES (1, 2, 3);
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 1, b + 1, c + 1 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 2, b + 2, c + 2 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 4, b + 4, c + 4 FROM ta_l_int;
+ INSERT INTO ta_l_int (a, b, c) SELECT a + 8, b + 8, c + 8 FROM ta_l_int;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_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, b, c FROM ta_l_int force index(primary, idx1, idx2)
+ WHERE a = 5 OR b = 5 OR c = 5 ORDER BY a;
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+}
+
+
+--echo
+--echo 2.26
+--echo auto_increment with partition
+if ($HAVE_PARTITION)
+{
+ 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_INCREMENT_TABLES1;
+ echo CHILD2_1_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ --connection child2_2
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_DROP_INCREMENT_TABLES1;
+ echo CHILD2_2_CREATE_INCREMENT_TABLES1;
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ }
+ --disable_warnings
+ eval $CHILD2_2_DROP_INCREMENT_TABLES1;
+ --enable_warnings
+ eval $CHILD2_2_CREATE_INCREMENT_TABLES1;
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT2;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET2;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+ }
+ --connection master_1
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ --disable_query_log
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_P_1;
+ echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ echo MASTER_1_AUTO_INCREMENT_OFFSET2;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1;
+ eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
+ eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
+ if ($USE_REPLICATION)
+ {
+ SET SESSION sql_log_bin= 1;
+ --connection slave1_1
+ --disable_warnings
+ DROP TABLE IF EXISTS t1;
+ --enable_warnings
+ echo CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ eval CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ ) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_P_1;
+ --connection master_1
+ }
+ --enable_query_log
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (null);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 () VALUES (),(),(),();
+ SELECT LAST_INSERT_ID();
+ SELECT id FROM t1 ORDER BY id;
+ SET INSERT_ID=5000;
+ INSERT INTO t1 () VALUES ();
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (10000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ INSERT INTO t1 (id) VALUES (1000);
+ SELECT LAST_INSERT_ID();
+ SELECT MAX(id) FROM t1;
+ if ($USE_REPLICATION)
+ {
+ save_master_pos;
+ --connection slave1_1
+ sync_with_master;
+ SELECT id FROM t1 ORDER BY id;
+ --connection master_1
+ --disable_query_log
+ SET SESSION sql_log_bin= 0;
+ --enable_query_log
+ }
+ if ($USE_CHILD_GROUP2)
+ {
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ --connection child2_2
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_2_SELECT_INCREMENT_TABLES1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ echo CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ echo CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ }
+ eval $CHILD2_2_AUTO_INCREMENT_INCREMENT1;
+ eval $CHILD2_2_AUTO_INCREMENT_OFFSET1;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ 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_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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--disable_query_log
+--disable_result_log
+--source slave_test_deinit.inc
+--source test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--echo
+--echo end of test
diff --git a/storage/vp/mysql-test/vp/t/test_deinit.inc b/storage/vp/mysql-test/vp/t/test_deinit.inc
new file mode 100644
index 00000000000..989bde26d3c
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/test_deinit.inc
@@ -0,0 +1,37 @@
+# get connection and exist engine test
+--echo for master_1
+--connection master_1
+--source ../include/deinit_master_1.inc
+--disconnect master_1
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --connection child2_1
+ --source ../include/deinit_child2_1.inc
+ --disconnect child2_1
+ --echo child2_2
+ --connection child2_2
+ --source ../include/deinit_child2_2.inc
+ --disconnect child2_2
+ --echo child2_3
+ --connection child2_3
+ --source ../include/deinit_child2_3.inc
+ --disconnect child2_3
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --connection child3_1
+ --source ../include/deinit_child3_1.inc
+ --disconnect child3_1
+ --echo child3_2
+ --connection child3_2
+ --source ../include/deinit_child3_2.inc
+ --disconnect child3_2
+ --echo child3_3
+ --connection child3_3
+ --source ../include/deinit_child3_3.inc
+ --disconnect child3_3
+}
diff --git a/storage/vp/mysql-test/vp/t/test_init.inc b/storage/vp/mysql-test/vp/t/test_init.inc
new file mode 100644
index 00000000000..f2cd6c0269f
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/test_init.inc
@@ -0,0 +1,74 @@
+# get connection and exist engine test
+--echo for master_1
+--source connect_master_1.inc
+--connection master_1
+CALL mtr.add_suppression("unknown variable");
+SET SESSION sql_log_bin= 0;
+--let $MASTER_1_SERVER_ID=`SELECT @@global.server_id`
+--let $TEST_ENGINE_TYPE= $MASTER_1_ENGINE_TYPE
+--source have_partition.inc
+--source have_trigger.inc
+--source ../include/init_master_1.inc
+--source have_engine.inc
+--echo for child2
+if ($USE_CHILD_GROUP2)
+{
+ --echo child2_1
+ --source connect_child2_1.inc
+ --connection child2_1
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_1_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_1_ENGINE_TYPE
+ --source ../include/init_child2_1.inc
+ --source have_engine.inc
+ --echo child2_2
+ --source connect_child2_2.inc
+ --connection child2_2
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_2_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_2_ENGINE_TYPE
+ --source ../include/init_child2_2.inc
+ --source have_engine.inc
+ --echo child2_3
+ --source connect_child2_3.inc
+ --connection child2_3
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD2_3_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD2_3_ENGINE_TYPE
+ --source ../include/init_child2_3.inc
+ --source have_engine.inc
+}
+--echo for child3
+if ($USE_CHILD_GROUP3)
+{
+ --echo child3_1
+ --source connect_child3_1.inc
+ --connection child3_1
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_1_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_1_ENGINE_TYPE
+ --source ../include/init_child3_1.inc
+ --source have_engine.inc
+ --echo child3_2
+ --source connect_child3_2.inc
+ --connection child3_2
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_2_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_2_ENGINE_TYPE
+ --source ../include/init_child3_2.inc
+ --source have_engine.inc
+ --echo child3_3
+ --source connect_child3_3.inc
+ --connection child3_3
+ CALL mtr.add_suppression("unknown variable *");
+ SET SESSION sql_log_bin= 0;
+ --let $CHILD3_3_SERVER_ID=`SELECT @@global.server_id`
+ --let $TEST_ENGINE_TYPE= $CHILD3_3_ENGINE_TYPE
+ --source ../include/init_child3_3.inc
+ --source have_engine.inc
+}
diff --git a/storage/vp/mysql-test/vp/t/vp_fixes.test b/storage/vp/mysql-test/vp/t/vp_fixes.test
new file mode 100644
index 00000000000..90380227040
--- /dev/null
+++ b/storage/vp/mysql-test/vp/t/vp_fixes.test
@@ -0,0 +1,335 @@
+# This test tests for VP's bug fixes
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo drop and create databases
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+if ($USE_CHILD_GROUP2)
+{
+ --connection child2_1
+ DROP DATABASE IF EXISTS auto_test_remote;
+ CREATE DATABASE auto_test_remote;
+ USE auto_test_remote;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+ CREATE DATABASE auto_test_remote2;
+ USE auto_test_remote2;
+}
+--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;
+ --connection child2_2
+ 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_CREATE_TABLES;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES;
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ }
+ if ($USE_GENERAL_LOG)
+ {
+ TRUNCATE TABLE mysql.general_log;
+ }
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS tb_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tb_l (a, b, c) VALUES
+ (1, 'a', '2008-08-01 10:21:39'),
+ (2, 'b', '2000-01-01 00:00:00'),
+ (3, 'e', '2007-06-04 20:03:11'),
+ (4, 'd', '2003-11-30 05:01:03'),
+ (5, 'c', '2001-12-31 23:59:59');
+--disable_warnings
+DROP TABLE IF EXISTS ta_l;
+--enable_warnings
+--disable_query_log
+echo CREATE TABLE ta_l (
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
+eval CREATE TABLE ta_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+--enable_query_log
+INSERT INTO ta_l SELECT a, b, c FROM tb_l;
+
+--echo
+--echo 0.9
+--echo create different primary key table
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT AUTO_INCREMENT,
+ c INT DEFAULT 11,
+ PRIMARY KEY(b)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+eval CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT AUTO_INCREMENT,
+ c INT DEFAULT 11,
+ PRIMARY KEY(b)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+--enable_query_log
+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
+--let $MASTER_1_IS_VP= `SELECT IF('$MASTER_1_ENGINE_TYPE' = 'VP', 1, 0)`
+if ($MASTER_1_IS_VP)
+{
+ --error 14514
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+}
+if (!$MASTER_1_IS_VP)
+{
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ --disable_query_log
+ --disable_result_log
+ TRUNCATE TABLE ta_l_int;
+ --enable_query_log
+ --enable_result_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES5;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+
+--echo create un-correspond primary key table
+--connection master_1
+--disable_warnings
+DROP TABLE IF EXISTS ta_l_int;
+--enable_warnings
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_result_log
+ }
+ --disable_query_log
+ --connection child2_1
+ if ($OUTPUT_CHILD_GROUP2)
+ {
+ echo CHILD2_1_DROP_TABLES5;
+ echo CHILD2_1_CREATE_TABLES5;
+ }
+ --disable_warnings
+ eval $CHILD2_1_DROP_TABLES5;
+ --enable_warnings
+ eval $CHILD2_1_CREATE_TABLES5;
+ --enable_query_log
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_result_log
+ }
+}
+--connection master_1
+--disable_query_log
+echo CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT DEFAULT 12,
+ c INT DEFAULT 11,
+ PRIMARY KEY(c)
+) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT4_2_1;
+eval CREATE TABLE ta_l_int (
+ a INT DEFAULT 10,
+ b INT DEFAULT 12,
+ c INT DEFAULT 11,
+ PRIMARY KEY(c)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT4_2_1;
+--enable_query_log
+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;
+ }
+ eval $CHILD2_1_SELECT_TABLES;
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --enable_query_log
+ --enable_result_log
+ }
+}
+--connection master_1
+if ($MASTER_1_IS_VP)
+{
+ --error 14514
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+}
+if (!$MASTER_1_IS_VP)
+{
+ INSERT INTO ta_l_int (a, b, c) VALUES (2, NULL, 3);
+ --disable_query_log
+ --disable_result_log
+ TRUNCATE TABLE ta_l_int;
+ --enable_query_log
+ --enable_result_log
+}
+if ($USE_CHILD_GROUP2)
+{
+ if (!$OUTPUT_CHILD_GROUP2)
+ {
+ --disable_query_log
+ --disable_result_log
+ }
+ --connection child2_1
+ if ($USE_GENERAL_LOG)
+ {
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %';
+ }
+ eval $CHILD2_1_SELECT_TABLES5;
+ 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;
+ --connection child2_2
+ DROP DATABASE IF EXISTS auto_test_remote2;
+}
+--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/vp/scripts/install_vp.sql b/storage/vp/scripts/install_vp.sql
new file mode 100644
index 00000000000..f0c6b06e7bc
--- /dev/null
+++ b/storage/vp/scripts/install_vp.sql
@@ -0,0 +1,46 @@
+# Copyright (C) 2010 Kentoku Shiba
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+# This SQL script creates system tables for SPIDER
+# or fixes incompatibilities if ones already exist.
+
+-- Install a plugin and UDFs
+drop procedure if exists mysql.vp_plugin_installer;
+delimiter //
+create procedure mysql.vp_plugin_installer()
+begin
+ set @win_plugin := IF(@@version_compile_os like 'Win%', 1, 0);
+ set @have_vp_plugin := 0;
+ select @have_vp_plugin := 1 from INFORMATION_SCHEMA.plugins where PLUGIN_NAME = 'VP';
+ if @have_vp_plugin = 0 then
+ if @win_plugin = 0 then
+ install plugin vp soname 'ha_vp.so';
+ else
+ install plugin vp soname 'ha_vp.dll';
+ end if;
+ end if;
+ set @have_vp_copy_tables_udf := 0;
+ select @have_vp_copy_tables_udf := 1 from mysql.func where name = 'vp_copy_tables';
+ if @have_vp_copy_tables_udf = 0 then
+ if @win_plugin = 0 then
+ create function vp_copy_tables returns int soname 'ha_vp.so';
+ else
+ create function vp_copy_tables returns int soname 'ha_vp.dll';
+ end if;
+ end if;
+end;//
+delimiter ;
+call mysql.vp_plugin_installer;
+drop procedure mysql.vp_plugin_installer;
diff --git a/storage/vp/vp_copy_tables.cc b/storage/vp/vp_copy_tables.cc
new file mode 100644
index 00000000000..c616f7cb325
--- /dev/null
+++ b/storage/vp/vp_copy_tables.cc
@@ -0,0 +1,1141 @@
+/* Copyright (C) 2009-2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MYSQL_SERVER 1
+#include <my_global.h>
+#include "mysql_version.h"
+#include "vp_environ.h"
+#if MYSQL_VERSION_ID < 50500
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#else
+#include "sql_priv.h"
+#include "probes_mysql.h"
+#include "sql_class.h"
+#include "key.h"
+#include "sql_base.h"
+#include "transaction.h"
+#include "sql_select.h"
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#include "ha_partition.h"
+#endif
+#include "vp_err.h"
+#include "vp_param.h"
+#include "vp_include.h"
+#include "ha_vp.h"
+#include "vp_table.h"
+#include "vp_copy_tables.h"
+#include "vp_udf.h"
+
+extern handlerton *vp_hton_ptr;
+extern handlerton *vp_partition_hton_ptr;
+
+int vp_udf_copy_tables_create_table_list(
+ VP_COPY_TABLES *copy_tables,
+ char *vp_table_name,
+ uint vp_table_name_length,
+ char *src_table_name_list,
+ uint src_table_name_list_length,
+ char *dst_table_name_list,
+ uint dst_table_name_list_length
+) {
+ int roop_count, roop_count2, length;
+ char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *tmp_name_ptr;
+ DBUG_ENTER("vp_udf_copy_tables_create_table_list");
+
+ if (!vp_table_name_length)
+ {
+ my_printf_error(ER_VP_BLANK_UDF_ARGUMENT_NUM,
+ ER_VP_BLANK_UDF_ARGUMENT_STR, MYF(0), 1);
+ DBUG_RETURN(ER_VP_BLANK_UDF_ARGUMENT_NUM);
+ }
+
+ for (roop_count2 = 0; roop_count2 < 2; roop_count2++)
+ {
+ if (roop_count2 == 0)
+ tmp_ptr = src_table_name_list;
+ else
+ tmp_ptr = dst_table_name_list;
+
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ if (*tmp_ptr)
+ copy_tables->table_count[roop_count2] = 1;
+ else {
+ copy_tables->table_count[roop_count2] = 0;
+ my_printf_error(ER_VP_BLANK_UDF_ARGUMENT_NUM,
+ ER_VP_BLANK_UDF_ARGUMENT_STR, MYF(0), roop_count2 + 2);
+ DBUG_RETURN(ER_VP_BLANK_UDF_ARGUMENT_NUM);
+ }
+
+ while (TRUE)
+ {
+ if ((tmp_ptr2 = strchr(tmp_ptr, ' ')))
+ {
+ copy_tables->table_count[roop_count2]++;
+ tmp_ptr = tmp_ptr2 + 1;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ } else
+ break;
+ }
+ }
+
+ if (!(copy_tables->db_names[0] = (char**)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &copy_tables->db_names[0], sizeof(char*) * copy_tables->table_count[0],
+ &copy_tables->db_names[1], sizeof(char*) * copy_tables->table_count[1],
+ &copy_tables->db_names_length[0],
+ sizeof(uint) * copy_tables->table_count[0],
+ &copy_tables->db_names_length[1],
+ sizeof(uint) * copy_tables->table_count[1],
+ &copy_tables->table_names[0],
+ sizeof(char*) * copy_tables->table_count[0],
+ &copy_tables->table_names[1],
+ sizeof(char*) * copy_tables->table_count[1],
+ &copy_tables->table_names_length[0],
+ sizeof(uint) * copy_tables->table_count[0],
+ &copy_tables->table_names_length[1],
+ sizeof(uint) * copy_tables->table_count[1],
+ &copy_tables->table_idx[0],
+ sizeof(uint) * copy_tables->table_count[0],
+ &copy_tables->table_idx[1],
+ sizeof(uint) * copy_tables->table_count[1],
+ &tmp_name_ptr, sizeof(char) * (
+ vp_table_name_length + copy_tables->default_database_length + 2 +
+ src_table_name_list_length +
+ copy_tables->default_database_length * copy_tables->table_count[0] +
+ 2 * copy_tables->table_count[0] +
+ dst_table_name_list_length +
+ copy_tables->default_database_length * copy_tables->table_count[1] +
+ 2 * copy_tables->table_count[1] +
+ (copy_tables->table_name_prefix_length +
+ copy_tables->table_name_suffix_length) *
+ (copy_tables->table_count[0] + copy_tables->table_count[1])
+ ),
+ NullS))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+
+ copy_tables->vp_db_name = tmp_name_ptr;
+ if ((tmp_ptr3 = strchr(vp_table_name, '.')))
+ {
+ /* exist database name */
+ *tmp_ptr3 = '\0';
+ length = strlen(vp_table_name);
+ memcpy(tmp_name_ptr, vp_table_name, length + 1);
+ copy_tables->vp_db_name_length = length;
+ tmp_name_ptr += length + 1;
+ tmp_ptr3++;
+ } else {
+ memcpy(tmp_name_ptr, copy_tables->default_database,
+ copy_tables->default_database_length + 1);
+ copy_tables->vp_db_name_length = copy_tables->default_database_length;
+ tmp_name_ptr += copy_tables->default_database_length + 1;
+ tmp_ptr3 = vp_table_name;
+ length = -1;
+ }
+ copy_tables->vp_table_name = tmp_name_ptr;
+ length = vp_table_name_length - length - 1;
+ memcpy(tmp_name_ptr, tmp_ptr3, length + 1);
+ copy_tables->vp_table_name_length = length;
+ tmp_name_ptr += length + 1;
+
+ DBUG_PRINT("info",("vp vp_db=%s", copy_tables->vp_db_name));
+ DBUG_PRINT("info",("vp vp_table_name=%s", copy_tables->vp_table_name));
+
+ for (roop_count2 = 0; roop_count2 < 2; roop_count2++)
+ {
+ if (roop_count2 == 0)
+ tmp_ptr = src_table_name_list;
+ else
+ tmp_ptr = dst_table_name_list;
+
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ roop_count = 0;
+ while (TRUE)
+ {
+ if ((tmp_ptr2 = strchr(tmp_ptr, ' ')))
+ *tmp_ptr2 = '\0';
+
+ copy_tables->db_names[roop_count2][roop_count] = tmp_name_ptr;
+
+ if ((tmp_ptr3 = strchr(tmp_ptr, '.')))
+ {
+ /* exist database name */
+ *tmp_ptr3 = '\0';
+ length = strlen(tmp_ptr);
+ memcpy(tmp_name_ptr, tmp_ptr, length + 1);
+ copy_tables->db_names_length[roop_count2][roop_count] = length;
+ tmp_name_ptr += length + 1;
+ tmp_ptr = tmp_ptr3 + 1;
+ } else {
+ memcpy(tmp_name_ptr, copy_tables->default_database,
+ copy_tables->default_database_length + 1);
+ copy_tables->db_names_length[roop_count2][roop_count] =
+ copy_tables->default_database_length;
+ tmp_name_ptr += copy_tables->default_database_length + 1;
+ }
+
+ copy_tables->table_names[roop_count2][roop_count] = tmp_name_ptr;
+ memcpy(tmp_name_ptr, copy_tables->table_name_prefix,
+ copy_tables->table_name_prefix_length);
+ tmp_name_ptr += copy_tables->table_name_prefix_length;
+ length = strlen(tmp_ptr);
+ memcpy(tmp_name_ptr, tmp_ptr, length);
+ tmp_name_ptr += length;
+ memcpy(tmp_name_ptr, copy_tables->table_name_suffix,
+ copy_tables->table_name_suffix_length + 1);
+ tmp_name_ptr += copy_tables->table_name_suffix_length + 1;
+ copy_tables->table_names_length[roop_count2][roop_count] =
+ copy_tables->table_name_prefix_length + length +
+ copy_tables->table_name_suffix_length;
+
+ DBUG_PRINT("info",("vp db=%s",
+ copy_tables->db_names[roop_count2][roop_count]));
+ DBUG_PRINT("info",("vp table_name=%s",
+ copy_tables->table_names[roop_count2][roop_count]));
+
+ if (!tmp_ptr2)
+ break;
+ tmp_ptr = tmp_ptr2 + 1;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ roop_count++;
+ }
+ }
+ DBUG_RETURN(0);
+}
+
+int vp_udf_parse_copy_tables_param(
+ VP_COPY_TABLES *copy_tables,
+ char *param,
+ int param_length
+) {
+ int error_num = 0;
+ char *param_string = NULL;
+ char *sprit_ptr[2];
+ char *tmp_ptr, *tmp_ptr2, *start_ptr;
+ int title_length;
+ VP_PARAM_STRING_PARSE param_string_parse;
+ DBUG_ENTER("vp_udf_parse_copy_tables_param");
+ copy_tables->bulk_insert_interval = -1;
+ copy_tables->bulk_insert_rows = -1;
+ copy_tables->suppress_autoinc = -1;
+
+ if (param_length == 0)
+ goto set_default;
+ DBUG_PRINT("info",("vp create param_string string"));
+ if (
+ !(param_string = vp_create_string(
+ param,
+ param_length))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error_alloc_param_string;
+ }
+ DBUG_PRINT("info",("vp param_string=%s", param_string));
+
+ sprit_ptr[0] = param_string;
+ param_string_parse.init(param_string, ER_VP_INVALID_UDF_PARAM_NUM);
+ while (sprit_ptr[0])
+ {
+ if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
+ {
+ *sprit_ptr[1] = '\0';
+ sprit_ptr[1]++;
+ }
+ tmp_ptr = sprit_ptr[0];
+ sprit_ptr[0] = sprit_ptr[1];
+ while (*tmp_ptr == ' ' || *tmp_ptr == '\r' ||
+ *tmp_ptr == '\n' || *tmp_ptr == '\t')
+ tmp_ptr++;
+
+ if (*tmp_ptr == '\0')
+ continue;
+
+ title_length = 0;
+ start_ptr = tmp_ptr;
+ while (*start_ptr != ' ' && *start_ptr != '\'' &&
+ *start_ptr != '"' && *start_ptr != '\0' &&
+ *start_ptr != '\r' && *start_ptr != '\n' &&
+ *start_ptr != '\t')
+ {
+ title_length++;
+ start_ptr++;
+ }
+ param_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
+
+ switch (title_length)
+ {
+ case 0:
+ error_num = param_string_parse.print_param_error();
+ if (error_num)
+ goto error;
+ continue;
+ case 3:
+ VP_PARAM_INT(copy_tables, "bii", bulk_insert_interval, 0);
+ VP_PARAM_LONGLONG(copy_tables, "bir", bulk_insert_rows, 1);
+ VP_PARAM_STR(copy_tables, "ddb", default_database);
+ VP_PARAM_INT_WITH_MAX(copy_tables, "sai", suppress_autoinc, 0, 1);
+ VP_PARAM_STR(copy_tables, "tnp", table_name_prefix);
+ VP_PARAM_STR(copy_tables, "tns", table_name_suffix);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 16:
+ VP_PARAM_LONGLONG(copy_tables, "bulk_insert_rows", bulk_insert_rows,
+ 1);
+ VP_PARAM_STR(copy_tables, "default_database", default_database);
+ VP_PARAM_INT_WITH_MAX(copy_tables, "suppress_autoinc",
+ suppress_autoinc, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 17:
+ VP_PARAM_STR(copy_tables, "table_name_prefix", table_name_prefix);
+ VP_PARAM_STR(copy_tables, "table_name_suffix", table_name_suffix);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 20:
+ VP_PARAM_INT(copy_tables, "bulk_insert_interval", bulk_insert_interval,
+ 0);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ default:
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ }
+
+ /* Verify that the remainder of the parameter value is whitespace */
+ if ((error_num = param_string_parse.has_extra_parameter_values()))
+ goto error;
+ }
+
+set_default:
+ if ((error_num = vp_udf_set_copy_tables_param_default(
+ copy_tables
+ )))
+ goto error;
+
+ if (param_string)
+ vp_my_free(param_string, MYF(0));
+ DBUG_RETURN(0);
+
+error:
+ if (param_string)
+ vp_my_free(param_string, MYF(0));
+error_alloc_param_string:
+ DBUG_RETURN(error_num);
+}
+
+int vp_udf_set_copy_tables_param_default(
+ VP_COPY_TABLES *copy_tables
+) {
+ DBUG_ENTER("vp_udf_set_copy_tables_param_default");
+
+ if (!copy_tables->default_database)
+ {
+ DBUG_PRINT("info",("vp create default default_database"));
+ copy_tables->default_database_length = VP_THD_db_length(copy_tables->thd);
+ if (
+ !(copy_tables->default_database = vp_create_string(
+ VP_THD_db_str(copy_tables->thd),
+ copy_tables->default_database_length))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!copy_tables->table_name_prefix)
+ {
+ DBUG_PRINT("info",("vp create default table_name_prefix"));
+ copy_tables->table_name_prefix_length = 0;
+ if (
+ !(copy_tables->table_name_prefix = vp_create_string(
+ "",
+ copy_tables->table_name_prefix_length))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!copy_tables->table_name_suffix)
+ {
+ DBUG_PRINT("info",("vp create default table_name_suffix"));
+ copy_tables->table_name_suffix_length = 0;
+ if (
+ !(copy_tables->table_name_suffix = vp_create_string(
+ "",
+ copy_tables->table_name_suffix_length))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (copy_tables->bulk_insert_interval == -1)
+ copy_tables->bulk_insert_interval = 10;
+ if (copy_tables->bulk_insert_rows == -1)
+ copy_tables->bulk_insert_rows = 100;
+ if (copy_tables->suppress_autoinc == -1)
+ copy_tables->suppress_autoinc = 0;
+ DBUG_RETURN(0);
+}
+
+void vp_udf_free_copy_tables_alloc(
+ VP_COPY_TABLES *copy_tables
+) {
+ DBUG_ENTER("vp_udf_free_copy_tables_alloc");
+ if (copy_tables->db_names[0])
+ vp_my_free(copy_tables->db_names[0], MYF(0));
+ if (copy_tables->default_database)
+ vp_my_free(copy_tables->default_database, MYF(0));
+ if (copy_tables->table_name_prefix)
+ vp_my_free(copy_tables->table_name_prefix, MYF(0));
+ if (copy_tables->table_name_suffix)
+ vp_my_free(copy_tables->table_name_suffix, MYF(0));
+ vp_my_free(copy_tables, MYF(0));
+ DBUG_VOID_RETURN;
+}
+
+long long vp_copy_tables_body(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *is_null,
+ char *error
+) {
+ int error_num, roop_count, roop_count2, roop_count3;
+ VP_COPY_TABLES *copy_tables = NULL;
+ THD *thd = current_thd;
+ TABLE_LIST *table_list;
+ uint db_name_length, table_name_length;
+ char *db_name, *table_name;
+ int part_idx = -1, tmp_idx;
+ ha_vp *vp_table = NULL;
+ TABLE *table;
+ VP_SHARE *share;
+ TABLE_LIST *part_tables;
+ uchar *src_bitmap = NULL, *dst_bitmap, *cpy_clm_bitmap,
+ *select_ignore = NULL, *select_ignore_with_lock = NULL,
+ *update_ignore = NULL;
+ uchar start_key[MAX_KEY_LENGTH], end_key[MAX_KEY_LENGTH];
+ key_range start_key_range, end_key_range;
+ KEY *key_info, *saved_key_info;
+ KEY_PART_INFO *key_part, *saved_key_part;
+ longlong bulk_insert_rows;
+ int bulk_insert_interval;
+ ulong table_def_version;
+ bool restart = FALSE;
+#if MYSQL_VERSION_ID < 50500
+#else
+ uint flags = (
+ MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |
+ MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |
+ MYSQL_OPEN_IGNORE_FLUSH |
+ MYSQL_LOCK_IGNORE_TIMEOUT |
+#ifdef VP_USE_OPEN_SKIP_TEMPORARY
+ MYSQL_OPEN_SKIP_TEMPORARY |
+#endif
+ MYSQL_OPEN_GET_NEW_TABLE
+ );
+#endif
+ Reprepare_observer *reprepare_observer_backup;
+
+ DBUG_ENTER("vp_copy_tables_body");
+ if (
+ thd->open_tables != 0 ||
+ thd->temporary_tables != 0 ||
+ thd->handler_tables_hash.records != 0 ||
+ thd->derived_tables != 0 ||
+ thd->lock != 0 ||
+#if MYSQL_VERSION_ID < 50500
+ thd->locked_tables != 0 ||
+ thd->prelocked_mode != NON_PRELOCKED ||
+#else
+ thd->locked_tables_list.locked_tables() ||
+ thd->locked_tables_mode != LTM_NONE ||
+#endif
+ thd->m_reprepare_observer != NULL
+ ) {
+ my_printf_error(ER_VP_UDF_CANT_USE_IF_OPEN_TABLE_NUM,
+ ER_VP_UDF_CANT_USE_IF_OPEN_TABLE_STR, MYF(0));
+ goto error;
+ }
+
+ if (!(copy_tables = (VP_COPY_TABLES *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &copy_tables, sizeof(VP_COPY_TABLES),
+ NullS))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
+ copy_tables->thd = thd;
+
+ if (args->arg_count == 4)
+ {
+ if (vp_udf_parse_copy_tables_param(
+ copy_tables,
+ args->args[3] ? args->args[3] : (char *) "",
+ args->args[3] ? args->lengths[3] : 0
+ ))
+ goto error;
+ } else {
+ if (vp_udf_parse_copy_tables_param(
+ copy_tables,
+ (char *) "",
+ 0
+ ))
+ goto error;
+ }
+ if (vp_udf_copy_tables_create_table_list(
+ copy_tables,
+ args->args[0],
+ args->lengths[0],
+ args->args[1] ? args->args[1] : (char *) "",
+ args->args[1] ? args->lengths[1] : 0,
+ args->args[2] ? args->args[2] : (char *) "",
+ args->args[2] ? args->lengths[2] : 0
+ ))
+ goto error;
+
+ table_list = &copy_tables->vp_table_list;
+ VP_TABLE_LIST_db_str(table_list) = copy_tables->vp_db_name;
+ VP_TABLE_LIST_db_length(table_list) = copy_tables->vp_db_name_length;
+ VP_TABLE_LIST_alias_str(table_list) =
+ VP_TABLE_LIST_table_name_str(table_list) = copy_tables->vp_table_name;
+#ifdef VP_TABLE_LIST_ALIAS_HAS_LENGTH
+ VP_TABLE_LIST_alias_length(table_list) =
+#endif
+ VP_TABLE_LIST_table_name_length(table_list) =
+ copy_tables->vp_table_name_length;
+ table_list->lock_type = TL_WRITE;
+
+ reprepare_observer_backup = thd->m_reprepare_observer;
+ thd->m_reprepare_observer = NULL;
+#if MYSQL_VERSION_ID < 50500
+ if (open_and_lock_tables(thd, table_list))
+#else
+ table_list->mdl_request.init(
+ MDL_key::TABLE,
+ VP_TABLE_LIST_db_str(table_list),
+ VP_TABLE_LIST_table_name_str(table_list),
+ MDL_SHARED_WRITE,
+ MDL_TRANSACTION
+ );
+ if (open_and_lock_tables(thd, table_list, FALSE, flags))
+#endif
+ {
+ thd->m_reprepare_observer = reprepare_observer_backup;
+ my_printf_error(ER_VP_UDF_CANT_OPEN_TABLE_NUM,
+ ER_VP_UDF_CANT_OPEN_TABLE_STR, MYF(0));
+ goto error;
+ }
+ thd->m_reprepare_observer = reprepare_observer_backup;
+
+change_table_version:
+ if (!(
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef PARTITION_HAS_GET_CHILD_HANDLERS
+ (table_list->table->file->ht == vp_partition_hton_ptr &&
+ vp_get_default_part_db_type_from_partition(table_list->table->s) ==
+ vp_hton_ptr) ||
+#endif
+#endif
+ table_list->table->file->ht == vp_hton_ptr
+ )) {
+ my_printf_error(ER_VP_UDF_IS_NOT_VP_TABLE_NUM,
+ ER_VP_UDF_IS_NOT_VP_TABLE_STR, MYF(0));
+ goto error;
+ }
+
+ db_name_length = copy_tables->db_names_length[0][0];
+ table_name_length = copy_tables->table_names_length[0][0];
+ db_name = copy_tables->db_names[0][0];
+ table_name = copy_tables->table_names[0][0];
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef PARTITION_HAS_GET_CHILD_HANDLERS
+ if (table_list->table->file->ht == vp_partition_hton_ptr)
+ {
+ ha_vp **vp_table_ptr = (ha_vp **)
+ ((ha_partition *) table_list->table->file)->get_child_handlers();
+ for (roop_count = 0; vp_table_ptr[roop_count]; roop_count++)
+ {
+ vp_table = vp_table_ptr[roop_count];
+ share = vp_table->share;
+ part_tables = vp_table->part_tables;
+ for (roop_count2 = 0; roop_count2 < share->table_count; roop_count2++)
+ {
+ if (
+ VP_TABLE_LIST_db_length(&part_tables[roop_count2]) ==
+ db_name_length &&
+ VP_TABLE_LIST_table_name_length(&part_tables[roop_count2]) ==
+ table_name_length &&
+ !memcmp(VP_TABLE_LIST_db_str(&part_tables[roop_count2]), db_name,
+ db_name_length) &&
+ !memcmp(VP_TABLE_LIST_table_name_str(&part_tables[roop_count2]),
+ table_name, table_name_length)
+ ) {
+ part_idx = roop_count;
+ copy_tables->table_idx[0][0] = roop_count2;
+ break;
+ }
+ }
+ if (part_idx >= 0)
+ break;
+ }
+ if (part_idx == -1)
+ {
+ my_printf_error(ER_VP_UDF_CANT_FIND_TABLE_NUM,
+ ER_VP_UDF_CANT_FIND_TABLE_STR, MYF(0), db_name, table_name);
+ goto error;
+ }
+ } else {
+#endif
+#endif
+ table = table_list->table;
+ vp_table = (ha_vp *) table->file;
+ share = vp_table->share;
+ part_tables = vp_table->part_tables;
+ for (roop_count2 = 0; roop_count2 < share->table_count; roop_count2++)
+ {
+ if (
+ VP_TABLE_LIST_db_length(&part_tables[roop_count2]) == db_name_length &&
+ VP_TABLE_LIST_table_name_length(&part_tables[roop_count2]) ==
+ table_name_length &&
+ !memcmp(VP_TABLE_LIST_db_str(&part_tables[roop_count2]), db_name,
+ db_name_length) &&
+ !memcmp(VP_TABLE_LIST_table_name_str(&part_tables[roop_count2]),
+ table_name, table_name_length)
+ ) {
+ copy_tables->table_idx[0][0] = roop_count2;
+ break;
+ }
+ }
+ if (roop_count2 == share->table_count)
+ {
+ my_printf_error(ER_VP_UDF_CANT_FIND_TABLE_NUM,
+ ER_VP_UDF_CANT_FIND_TABLE_STR, MYF(0), db_name, table_name);
+ goto error;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef PARTITION_HAS_GET_CHILD_HANDLERS
+ }
+#endif
+#endif
+ table_def_version = table_list->table->s->get_table_def_version();
+ if (!share->zero_record_update_mode)
+ {
+ my_printf_error(ER_VP_UDF_MUST_SET_ZRU_NUM,
+ ER_VP_UDF_MUST_SET_ZRU_STR, MYF(0), db_name, table_name);
+ goto error;
+ }
+
+ for (roop_count = 0; roop_count < 2; roop_count++)
+ {
+ for (roop_count2 = 0; roop_count2 < copy_tables->table_count[roop_count];
+ roop_count2++)
+ {
+ if (roop_count == 0 && roop_count2 == 0)
+ continue;
+
+ db_name_length = copy_tables->db_names_length[roop_count][roop_count2];
+ table_name_length =
+ copy_tables->table_names_length[roop_count][roop_count2];
+ db_name = copy_tables->db_names[roop_count][roop_count2];
+ table_name = copy_tables->table_names[roop_count][roop_count2];
+ for (roop_count3 = 0; roop_count3 < share->table_count; roop_count3++)
+ {
+ if (
+ VP_TABLE_LIST_db_length(&part_tables[roop_count3]) ==
+ db_name_length &&
+ VP_TABLE_LIST_table_name_length(&part_tables[roop_count3]) ==
+ table_name_length &&
+ !memcmp(VP_TABLE_LIST_db_str(&part_tables[roop_count3]), db_name,
+ db_name_length) &&
+ !memcmp(VP_TABLE_LIST_table_name_str(&part_tables[roop_count3]),
+ table_name, table_name_length)
+ ) {
+ copy_tables->table_idx[roop_count][roop_count2] = roop_count3;
+ break;
+ }
+ }
+ if (roop_count3 == share->table_count)
+ {
+ my_printf_error(ER_VP_UDF_CANT_FIND_TABLE_NUM,
+ ER_VP_UDF_CANT_FIND_TABLE_STR, MYF(0), db_name, table_name);
+ goto error;
+ }
+ }
+ }
+
+ key_info = &table_list->table->key_info[
+ table_list->table->s->primary_key];
+ if (!(src_bitmap = (uchar *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &src_bitmap, sizeof(uchar) * share->use_tables_size,
+ &dst_bitmap, sizeof(uchar) * share->use_tables_size,
+ &cpy_clm_bitmap, sizeof(uchar) * share->bitmap_size,
+ &saved_key_info, sizeof(KEY),
+ &saved_key_part,
+ sizeof(KEY_PART_INFO) * vp_user_defined_key_parts(key_info),
+ NullS))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
+ for (roop_count = 0; roop_count < copy_tables->table_count[0]; roop_count++)
+ {
+ vp_set_bit(src_bitmap, copy_tables->table_idx[0][roop_count]);
+ }
+ for (roop_count = 0; roop_count < copy_tables->table_count[1]; roop_count++)
+ {
+ vp_set_bit(dst_bitmap, copy_tables->table_idx[1][roop_count]);
+ }
+ for (roop_count = 0; roop_count < share->use_tables_size; roop_count++)
+ {
+ if (src_bitmap[roop_count] & dst_bitmap[roop_count])
+ {
+ my_printf_error(ER_VP_UDF_FIND_SAME_TABLE_NUM,
+ ER_VP_UDF_FIND_SAME_TABLE_STR, MYF(0));
+ goto error;
+ }
+ src_bitmap[roop_count] = ~src_bitmap[roop_count];
+ dst_bitmap[roop_count] = ~dst_bitmap[roop_count];
+ }
+ for (roop_count = 0; roop_count < copy_tables->table_count[1]; roop_count++)
+ {
+ tmp_idx = copy_tables->table_idx[1][roop_count];
+ for (roop_count2 = 0; roop_count2 < share->bitmap_size; roop_count2++)
+ {
+ cpy_clm_bitmap[roop_count2] |= share->correspond_columns_bit[
+ (tmp_idx * share->bitmap_size) + roop_count2];
+ }
+ }
+ select_ignore = vp_table->select_ignore;
+ vp_table->select_ignore = src_bitmap;
+ select_ignore_with_lock = vp_table->select_ignore_with_lock;
+ vp_table->select_ignore_with_lock = src_bitmap;
+ update_ignore = vp_table->update_ignore;
+ vp_table->update_ignore = dst_bitmap;
+ memset((uchar *) table_list->table->read_set->bitmap, 0,
+ sizeof(uchar) * share->bitmap_size);
+ memset((uchar *) table_list->table->write_set->bitmap, 0,
+ sizeof(uchar) * share->bitmap_size);
+
+ memcpy(saved_key_info, key_info, sizeof(KEY));
+ key_part = key_info->key_part;
+ for (roop_count = 0; roop_count < (int) vp_user_defined_key_parts(key_info);
+ roop_count++)
+ {
+ memcpy(saved_key_part, key_part, sizeof(KEY_PART_INFO));
+ vp_set_bit(table_list->table->read_set->bitmap,
+ key_part[roop_count].field->field_index);
+ }
+
+ if (!restart)
+ {
+ DBUG_PRINT("info",("vp get PK max"));
+ if (
+ (error_num = vp_table->extra(HA_EXTRA_KEYREAD)) ||
+ (error_num = vp_table->ha_index_init(table_list->table->s->primary_key,
+ TRUE))
+ ) {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ goto error;
+ }
+ if ((error_num = vp_table->index_last(table_list->table->record[0])))
+ {
+ if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ vp_table->ha_index_end();
+ goto error;
+ }
+ /* no data */
+ vp_table->ha_index_end();
+ vp_table->extra(HA_EXTRA_NO_KEYREAD);
+ goto end;
+ }
+ key_copy(
+ end_key,
+ table_list->table->record[0],
+ key_info,
+ key_info->key_length);
+ vp_table->ha_index_end();
+ vp_table->extra(HA_EXTRA_NO_KEYREAD);
+
+ DBUG_PRINT("info",("vp get PK min"));
+ if (
+ (error_num = vp_table->extra(HA_EXTRA_KEYREAD)) ||
+ (error_num = vp_table->ha_index_init(table_list->table->s->primary_key,
+ TRUE))
+ ) {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ goto error;
+ }
+ if ((error_num = vp_table->index_first(table_list->table->record[0])))
+ {
+ if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ vp_table->ha_index_end();
+ goto error;
+ }
+ /* no data */
+ vp_table->ha_index_end();
+ vp_table->extra(HA_EXTRA_NO_KEYREAD);
+ goto end;
+ }
+ key_copy(
+ start_key,
+ table_list->table->record[0],
+ key_info,
+ key_info->key_length);
+ vp_table->ha_index_end();
+ vp_table->extra(HA_EXTRA_NO_KEYREAD);
+ }
+
+ if (!restart)
+ {
+ DBUG_PRINT("info",("vp create initial range"));
+ start_key_range.keypart_map = make_prev_keypart_map(
+ vp_user_defined_key_parts(key_info));
+ start_key_range.flag = HA_READ_KEY_OR_NEXT;
+ start_key_range.length = vp_user_defined_key_parts(key_info);
+ start_key_range.key = start_key;
+ end_key_range.keypart_map = make_prev_keypart_map(
+ vp_user_defined_key_parts(key_info));
+ end_key_range.flag = HA_READ_KEY_OR_PREV;
+ end_key_range.length = vp_user_defined_key_parts(key_info);
+ end_key_range.key = end_key;
+
+ goto first_close;
+ }
+ while (TRUE)
+ {
+ key_info = &table_list->table->key_info[
+ table_list->table->s->primary_key];
+ key_part = key_info->key_part;
+
+ memcpy((uchar *) table_list->table->read_set->bitmap, cpy_clm_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+ memcpy((uchar *) table_list->table->write_set->bitmap, cpy_clm_bitmap,
+ sizeof(uchar) * share->bitmap_size);
+
+ DBUG_PRINT("info",("vp search init"));
+ bulk_insert_rows = vp_param_udf_ct_bulk_insert_rows(
+ copy_tables->bulk_insert_rows);
+ if (
+ (error_num = vp_table->ha_index_init(table_list->table->s->primary_key,
+ TRUE))
+ ) {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ goto error;
+ }
+ if ((error_num = vp_table->read_range_first(
+ &start_key_range, &end_key_range, FALSE, TRUE)))
+ {
+ if (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ vp_table->ha_index_end();
+ goto error;
+ }
+ /* no data */
+ vp_table->ha_index_end();
+ goto end;
+ }
+
+ DBUG_PRINT("info",("vp insert init"));
+ if ((error_num = vp_table->extra(HA_EXTRA_IGNORE_DUP_KEY)))
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ goto error;
+ }
+ if (!copy_tables->suppress_autoinc)
+ {
+ table_list->table->next_number_field =
+ table_list->table->found_next_number_field;
+ table_list->table->auto_increment_field_not_null = TRUE;
+ } else
+ vp_table->suppress_autoinc = TRUE;
+ vp_table->ha_start_bulk_insert(bulk_insert_rows);
+
+ roop_count = 0;
+ while (TRUE)
+ {
+ DBUG_PRINT("info",("vp insert"));
+ if ((error_num = vp_table->ha_write_row(table_list->table->record[0])))
+ {
+ if (vp_table->is_fatal_error(error_num, HA_CHECK_DUP))
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ break;
+ } else
+ error_num = 0;
+ }
+
+ roop_count++;
+ if (roop_count >= bulk_insert_rows)
+ break;
+
+ DBUG_PRINT("info",("vp search next"));
+ if ((error_num = vp_table->read_range_next()))
+ {
+ if (error_num != HA_ERR_KEY_NOT_FOUND &&
+ error_num != HA_ERR_END_OF_FILE)
+ {
+ DBUG_PRINT("info",("vp error_num=%d", error_num));
+ vp_table->print_error(error_num, MYF(0));
+ break;
+ }
+ /* no data */
+ bulk_insert_rows = 0;
+ break;
+ }
+ }
+
+ vp_table->ha_end_bulk_insert();
+ vp_table->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+ vp_table->ha_release_auto_increment();
+ table_list->table->next_number_field = NULL;
+ table_list->table->auto_increment_field_not_null = FALSE;
+ vp_table->suppress_autoinc = FALSE;
+ vp_table->ha_index_end();
+ if (!bulk_insert_rows)
+ goto end;
+ if (error_num)
+ goto error;
+
+ key_copy(
+ start_key,
+ table_list->table->record[0],
+ key_info,
+ key_info->key_length);
+ start_key_range.flag = HA_READ_AFTER_KEY;
+
+first_close:
+ vp_table->select_ignore = select_ignore;
+ vp_table->select_ignore_with_lock = select_ignore_with_lock;
+ vp_table->update_ignore = update_ignore;
+ select_ignore = NULL;
+ select_ignore_with_lock = NULL;
+ update_ignore = NULL;
+#if MYSQL_VERSION_ID < 50500
+ ha_autocommit_or_rollback(thd, 0);
+#else
+ (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd));
+#endif
+ close_thread_tables(thd);
+ table_list->table = NULL;
+
+ DBUG_PRINT("info",("vp sleep"));
+ bulk_insert_interval = vp_param_udf_ct_bulk_insert_interval(
+ copy_tables->bulk_insert_interval);
+ my_sleep(bulk_insert_interval);
+
+ DBUG_PRINT("info",("vp wakeup"));
+ reprepare_observer_backup = thd->m_reprepare_observer;
+ thd->m_reprepare_observer = NULL;
+#if MYSQL_VERSION_ID < 50500
+ if (open_and_lock_tables(thd, table_list))
+#else
+ table_list->table = NULL;
+ table_list->next_global = NULL;
+ table_list->lock_type = TL_WRITE;
+ table_list->mdl_request.init(
+ MDL_key::TABLE,
+ VP_TABLE_LIST_db_str(table_list),
+ VP_TABLE_LIST_table_name_str(table_list),
+ MDL_SHARED_WRITE,
+ MDL_TRANSACTION
+ );
+ if (open_and_lock_tables(thd, table_list, FALSE, flags))
+#endif
+ {
+ thd->m_reprepare_observer = reprepare_observer_backup;
+ my_printf_error(ER_VP_UDF_CANT_OPEN_TABLE_NUM,
+ ER_VP_UDF_CANT_OPEN_TABLE_STR, MYF(0));
+ goto error;
+ }
+ thd->m_reprepare_observer = reprepare_observer_backup;
+ if (table_def_version != table_list->table->s->get_table_def_version())
+ {
+ key_info = &table_list->table->key_info[
+ table_list->table->s->primary_key];
+ if (
+ key_info->key_length != saved_key_info->key_length ||
+ key_info->flags != saved_key_info->flags ||
+ vp_user_defined_key_parts(key_info) !=
+ vp_user_defined_key_parts(saved_key_info) ||
+#ifdef VP_KEY_HAS_EXTRA_LENGTH
+ key_info->extra_length != saved_key_info->extra_length ||
+#endif
+ key_info->usable_key_parts != saved_key_info->usable_key_parts ||
+ key_info->block_size != saved_key_info->block_size ||
+ key_info->algorithm != saved_key_info->algorithm
+ ) {
+ my_printf_error(ER_VP_UDF_FIND_CHANGE_TABLE_NUM,
+ ER_VP_UDF_FIND_CHANGE_TABLE_STR, MYF(0));
+ goto error;
+ }
+ key_part = key_info->key_part;
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(key_info);
+ roop_count++)
+ {
+ if (
+ key_part->offset != saved_key_part->offset ||
+ key_part->null_offset != saved_key_part->null_offset ||
+ key_part->length != saved_key_part->length ||
+ key_part->store_length != saved_key_part->store_length ||
+ key_part->key_type != saved_key_part->key_type ||
+ key_part->fieldnr != saved_key_part->fieldnr ||
+ key_part->key_part_flag != saved_key_part->key_part_flag ||
+ key_part->type != saved_key_part->type ||
+ key_part->null_bit != saved_key_part->null_bit
+ ) {
+ my_printf_error(ER_VP_UDF_FIND_CHANGE_TABLE_NUM,
+ ER_VP_UDF_FIND_CHANGE_TABLE_STR, MYF(0));
+ goto error;
+ }
+ }
+ DBUG_PRINT("info",("vp restart"));
+ restart = TRUE;
+ part_idx = -1;
+ vp_my_free(src_bitmap, MYF(0));
+ src_bitmap = NULL;
+ goto change_table_version;
+ }
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef PARTITION_HAS_GET_CHILD_HANDLERS
+ if (table_list->table->file->ht == vp_partition_hton_ptr)
+ {
+ ha_vp **vp_table_ptr = (ha_vp **)
+ ((ha_partition *) table_list->table->file)->get_child_handlers();
+ vp_table = vp_table_ptr[part_idx];
+ share = vp_table->share;
+ part_tables = vp_table->part_tables;
+ } else {
+#endif
+#endif
+ vp_table = (ha_vp *) table_list->table->file;
+ share = vp_table->share;
+ part_tables = vp_table->part_tables;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef PARTITION_HAS_GET_CHILD_HANDLERS
+ }
+#endif
+#endif
+ select_ignore = vp_table->select_ignore;
+ vp_table->select_ignore = src_bitmap;
+ select_ignore_with_lock = vp_table->select_ignore_with_lock;
+ vp_table->select_ignore_with_lock = src_bitmap;
+ update_ignore = vp_table->update_ignore;
+ vp_table->update_ignore = dst_bitmap;
+ }
+
+end:
+ if (select_ignore)
+ vp_table->select_ignore = select_ignore;
+ if (select_ignore_with_lock)
+ vp_table->select_ignore_with_lock = select_ignore_with_lock;
+ if (update_ignore)
+ vp_table->update_ignore = update_ignore;
+#if MYSQL_VERSION_ID < 50500
+ ha_autocommit_or_rollback(thd, 0);
+#else
+ (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd));
+#endif
+ close_thread_tables(thd);
+ if (src_bitmap)
+ vp_my_free(src_bitmap, MYF(0));
+ if (copy_tables)
+ vp_udf_free_copy_tables_alloc(copy_tables);
+ DBUG_RETURN(1);
+
+error:
+ if (select_ignore)
+ vp_table->select_ignore = select_ignore;
+ if (select_ignore_with_lock)
+ vp_table->select_ignore_with_lock = select_ignore_with_lock;
+ if (update_ignore)
+ vp_table->update_ignore = update_ignore;
+#if MYSQL_VERSION_ID < 50500
+ ha_autocommit_or_rollback(thd, 0);
+#else
+ (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd));
+#endif
+ close_thread_tables(thd);
+ if (src_bitmap)
+ vp_my_free(src_bitmap, MYF(0));
+ if (copy_tables)
+ vp_udf_free_copy_tables_alloc(copy_tables);
+ *error = 1;
+ DBUG_RETURN(0);
+}
+
+my_bool vp_copy_tables_init_body(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *message
+) {
+ DBUG_ENTER("vp_copy_tables_init_body");
+ if (args->arg_count != 3 && args->arg_count != 4)
+ {
+ strcpy(message, "vp_copy_tables() requires 3 or 4 arguments");
+ goto error;
+ }
+ if (
+ args->arg_type[0] != STRING_RESULT ||
+ args->arg_type[1] != STRING_RESULT ||
+ args->arg_type[2] != STRING_RESULT ||
+ (
+ args->arg_count == 4 &&
+ args->arg_type[3] != STRING_RESULT
+ )
+ ) {
+ strcpy(message, "vp_copy_tables() requires string arguments");
+ goto error;
+ }
+ DBUG_RETURN(FALSE);
+
+error:
+ DBUG_RETURN(TRUE);
+}
+
+void vp_copy_tables_deinit_body(
+ UDF_INIT *initid
+) {
+ DBUG_ENTER("vp_copy_tables_deinit_body");
+ DBUG_VOID_RETURN;
+}
diff --git a/storage/vp/vp_copy_tables.h b/storage/vp/vp_copy_tables.h
new file mode 100644
index 00000000000..6c4de6452b8
--- /dev/null
+++ b/storage/vp/vp_copy_tables.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 2009-2014 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+typedef struct st_vp_copy_tables
+{
+ THD *thd;
+ char *vp_db_name;
+ uint vp_db_name_length;
+ char *vp_table_name;
+ uint vp_table_name_length;
+ TABLE_LIST vp_table_list;
+
+ int table_count[2];
+ char **db_names[2];
+ uint *db_names_length[2];
+ char **table_names[2];
+ uint *table_names_length[2];
+ int *table_idx[2];
+
+ int bulk_insert_interval;
+ longlong bulk_insert_rows;
+ int suppress_autoinc;
+
+ char *default_database;
+ char *table_name_prefix;
+ char *table_name_suffix;
+
+ uint default_database_length;
+ uint table_name_prefix_length;
+ uint table_name_suffix_length;
+} VP_COPY_TABLES;
+
+int vp_udf_copy_tables_create_table_list(
+ VP_COPY_TABLES *copy_tables,
+ char *vp_table_name,
+ uint vp_table_name_length,
+ char *src_table_name_list,
+ uint src_table_name_list_length,
+ char *dst_table_name_list,
+ uint dst_table_name_list_length
+);
+
+int vp_udf_parse_copy_tables_param(
+ VP_COPY_TABLES *copy_tables,
+ char *param,
+ int param_length
+);
+
+int vp_udf_set_copy_tables_param_default(
+ VP_COPY_TABLES *copy_tables
+);
+
+void vp_udf_free_copy_tables_alloc(
+ VP_COPY_TABLES *copy_tables
+);
diff --git a/storage/vp/vp_environ.h b/storage/vp/vp_environ.h
new file mode 100644
index 00000000000..d3a86f41d10
--- /dev/null
+++ b/storage/vp/vp_environ.h
@@ -0,0 +1,66 @@
+/* Copyright (C) 2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ Define functionality offered by MySQL or MariaDB
+*/
+
+#ifndef VP_ENVIRON_INCLUDED
+#define VP_ENVIRON_INCLUDED
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
+#define VP_HANDLER_START_BULK_INSERT_HAS_FLAGS
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100203
+#define HANDLER_HAS_TOP_TABLE_FIELDS
+#define PARTITION_HAS_EXTRA_ATTACH_CHILDREN
+#define PARTITION_HAS_GET_CHILD_HANDLERS
+#define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100204
+#define VP_FIELD_BLOB_GET_PTR_RETURNS_UCHAR_PTR
+#define HANDLER_HAS_DIRECT_UPDATE_ROWS
+#define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
+#define HANDLER_HAS_PRUNE_PARTITIONS_FOR_CHILD
+#define HANDLER_HAS_GET_NEXT_GLOBAL_FOR_CHILD
+#define HANDLER_HAS_CHECK_AND_SET_BITMAP_FOR_UPDATE
+#else
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+#define HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
+#endif
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100211
+#define HANDLER_HAS_DIRECT_AGGREGATE
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100300
+#define VP_UPDATE_ROW_HAS_CONST_NEW_DATA
+#define VP_PARTITION_HAS_CONNECTION_STRING
+#define VP_REGISTER_QUERY_CACHE_TABLE_HAS_CONST_TABLE_KEY
+#define VP_END_BULK_UPDATE_RETURNS_INT
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100309
+#define VP_MDEV_16246
+#define VP_alter_table_operations alter_table_operations
+#else
+#define VP_alter_table_operations uint
+#endif
+
+#endif /* VP_ENVIRON_INCLUDED */
diff --git a/storage/vp/vp_err.h b/storage/vp/vp_err.h
new file mode 100644
index 00000000000..f856cde96e5
--- /dev/null
+++ b/storage/vp/vp_err.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 2009-2014 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define ER_VP_INVALID_TABLE_INFO_NUM 14501
+#define ER_VP_INVALID_TABLE_INFO_STR "The table info '%-.64s' is invalid"
+#define ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM 14502
+#define ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR "The table info '%-.64s' for %s is too long"
+#define ER_VP_INVALID_UDF_PARAM_NUM 14503
+#define ER_VP_INVALID_UDF_PARAM_STR "The UDF parameter '%-.64s' is invalid"
+#define ER_VP_BLANK_UDF_ARGUMENT_NUM 14504
+#define ER_VP_BLANK_UDF_ARGUMENT_STR "The UDF no.%d argument can't be blank"
+#define ER_VP_TBL_NUM_OUT_OF_RANGE_NUM 14505
+#define ER_VP_TBL_NUM_OUT_OF_RANGE_STR "Table index %d is out of range"
+#define ER_VP_CANT_CORRESPOND_TABLE_NUM 14511
+#define ER_VP_CANT_CORRESPOND_TABLE_STR "Can't correspond table '%s'"
+#define ER_VP_CANT_CORRESPOND_COLUMN_NUM 14512
+#define ER_VP_CANT_CORRESPOND_COLUMN_STR "Can't correspond column '%s'"
+#define ER_VP_CANT_CORRESPOND_KEY_NUM 14513
+#define ER_VP_CANT_CORRESPOND_KEY_STR "Can't correspond key '%d'"
+#define ER_VP_CANT_CORRESPOND_PK_NUM 14514
+#define ER_VP_CANT_CORRESPOND_PK_STR "Can't correspond PK '%s'"
+#define ER_VP_CANT_CORRESPOND_AUTO_INC_NUM 14515
+#define ER_VP_CANT_CORRESPOND_AUTO_INC_STR "Can't correspond auto_increment column '%s'"
+#define ER_VP_DIFFERENT_COLUMN_TYPE_NUM 14516
+#define ER_VP_DIFFERENT_COLUMN_TYPE_STR "Different column type '%s'.'%s'"
+#define ER_VP_IGNORED_CORRESPOND_KEY_NUM 14517
+#define ER_VP_IGNORED_CORRESPOND_KEY_STR "Key no.%d is on ignored tables"
+#define ER_VP_IGNORED_CORRESPOND_COLUMN_NUM 14518
+#define ER_VP_IGNORED_CORRESPOND_COLUMN_STR "Some columns are on ignored tables"
+#define ER_VP_UDF_CANT_USE_IF_OPEN_TABLE_NUM 14521
+#define ER_VP_UDF_CANT_USE_IF_OPEN_TABLE_STR "This UDF can't execute if other tables are opened"
+#define ER_VP_UDF_CANT_OPEN_TABLE_NUM 14521
+#define ER_VP_UDF_CANT_OPEN_TABLE_STR "Can't open tables"
+#define ER_VP_UDF_IS_NOT_VP_TABLE_NUM 14522
+#define ER_VP_UDF_IS_NOT_VP_TABLE_STR "Target table(argument 1) is not Vertical Partitioning table"
+#define ER_VP_UDF_CANT_FIND_TABLE_NUM 14523
+#define ER_VP_UDF_CANT_FIND_TABLE_STR "Can't find child table '%s.%s' in VP table"
+#define ER_VP_UDF_FIND_SAME_TABLE_NUM 14524
+#define ER_VP_UDF_FIND_SAME_TABLE_STR "Can't use same table at source and destination"
+#define ER_VP_UDF_FIND_CHANGE_TABLE_NUM 14525
+#define ER_VP_UDF_FIND_CHANGE_TABLE_STR "Change table definition during this executing"
+#define ER_VP_UDF_MUST_SET_ZRU_NUM 14526
+#define ER_VP_UDF_MUST_SET_ZRU_STR "You must set zero_record_update_mode = 1 for table '%s.%s'"
+
+#define ER_VP_COND_SKIP_NUM 14551
+
+#define ER_VP_UNKNOWN_STR "unknown"
+#define ER_VP_UNKNOWN_LEN (sizeof(ER_VP_UNKNOWN_STR) - 1)
diff --git a/storage/vp/vp_include.h b/storage/vp/vp_include.h
new file mode 100644
index 00000000000..58c22ace62c
--- /dev/null
+++ b/storage/vp/vp_include.h
@@ -0,0 +1,434 @@
+/* Copyright (C) 2009-2016 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define VP_DETAIL_VERSION "1.1.14"
+#define VP_HEX_VERSION 0x0101
+
+#if MYSQL_VERSION_ID < 50500
+#define vp_my_free(A,B) my_free(A,B)
+#else
+#define vp_my_free(A,B) my_free(A)
+#ifdef pthread_mutex_t
+#undef pthread_mutex_t
+#endif
+#define pthread_mutex_t mysql_mutex_t
+#ifdef pthread_mutex_lock
+#undef pthread_mutex_lock
+#endif
+#define pthread_mutex_lock mysql_mutex_lock
+#ifdef pthread_mutex_trylock
+#undef pthread_mutex_trylock
+#endif
+#define pthread_mutex_trylock mysql_mutex_trylock
+#ifdef pthread_mutex_unlock
+#undef pthread_mutex_unlock
+#endif
+#define pthread_mutex_unlock mysql_mutex_unlock
+#ifdef pthread_mutex_destroy
+#undef pthread_mutex_destroy
+#endif
+#define pthread_mutex_destroy mysql_mutex_destroy
+#ifdef pthread_cond_t
+#undef pthread_cond_t
+#endif
+#define pthread_cond_t mysql_cond_t
+#ifdef pthread_cond_wait
+#undef pthread_cond_wait
+#endif
+#define pthread_cond_wait mysql_cond_wait
+#ifdef pthread_cond_signal
+#undef pthread_cond_signal
+#endif
+#define pthread_cond_signal mysql_cond_signal
+#ifdef pthread_cond_broadcast
+#undef pthread_cond_broadcast
+#endif
+#define pthread_cond_broadcast mysql_cond_broadcast
+#ifdef pthread_cond_destroy
+#undef pthread_cond_destroy
+#endif
+#define pthread_cond_destroy mysql_cond_destroy
+#define my_sprintf(A,B) sprintf B
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100306
+#define VP_THD_db_str(A) (A)->db.str
+#define VP_THD_db_length(A) (A)->db.length
+#define VP_TABLE_LIST_db_str(A) (A)->db.str
+#define VP_TABLE_LIST_db_length(A) (A)->db.length
+#define VP_TABLE_LIST_table_name_str(A) (A)->table_name.str
+#define VP_TABLE_LIST_table_name_length(A) (A)->table_name.length
+#define VP_TABLE_LIST_alias_str(A) (A)->alias.str
+#define VP_TABLE_LIST_alias_length(A) (A)->alias.length
+#define VP_TABLE_LIST_ALIAS_HAS_LENGTH
+#define VP_field_name_str(A) (A)->field_name.str
+#define VP_field_name_length(A) (A)->field_name.length
+#define VP_item_name_str(A) (A)->name.str
+#define VP_item_name_length(A) (A)->name.length
+#else
+#define VP_THD_db_str(A) (A)->db
+#define VP_THD_db_length(A) (A)->db_length
+#define VP_TABLE_LIST_db_str(A) (A)->db
+#define VP_TABLE_LIST_db_length(A) (A)->db_length
+#define VP_TABLE_LIST_table_name_str(A) (A)->table_name
+#define VP_TABLE_LIST_table_name_length(A) (A)->table_name_length
+#define VP_TABLE_LIST_alias_str(A) (A)->alias
+#define VP_TABLE_LIST_alias_length(A) strlen((A)->alias)
+#define VP_field_name_str(A) (A)->field_name
+#define VP_field_name_length(A) strlen((A)->field_name)
+#define VP_item_name_str(A) (A)->name
+#define VP_item_name_length(A) strlen((A)->name)
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213
+#define VP_INIT_ALLOC_ROOT(A, B, C, D) \
+ init_alloc_root(A, "spider", B, C, D)
+#elif defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
+#define VP_INIT_ALLOC_ROOT(A, B, C, D) \
+ init_alloc_root(A, B, C, D)
+#else
+#define VP_INIT_ALLOC_ROOT(A, B, C, D) \
+ init_alloc_root(A, B, C)
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100209
+#define VP_create_partition_name(A,B,C,D,E,F) create_partition_name(A,B,C,D,E,F)
+#define VP_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,B,C,D,E,F)
+#else
+#define VP_create_partition_name(A,B,C,D,E,F) create_partition_name(A,C,D,E,F)
+#define VP_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,C,D,E,F)
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200
+#define VP_WITHOUT_HA_STATISTIC_INCREMENT
+#define VP_HAS_NEXT_THREAD_ID
+#define VP_set_next_thread_id(A)
+#define VP_new_THD(A) (new THD(A))
+#else
+inline void VP_set_next_thread_id(THD *A)
+{
+ pthread_mutex_lock(&LOCK_thread_count);
+ A->thread_id = (*vp_db_att_thread_id)++;
+ pthread_mutex_unlock(&LOCK_thread_count);
+}
+#define VP_new_THD(A) (new THD())
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004
+#define vp_user_defined_key_parts(A) (A)->user_defined_key_parts
+#define vp_join_table_count(A) (A)->table_count
+#define vp_get_default_part_db_type_from_partition(A) \
+ plugin_data((A)->default_part_plugin, handlerton *)
+#define LL(A) A ## LL
+#define VP_HANDLER_HAS_HA_CLOSE
+#define VP_HANDLER_HAS_COUNT_QUERY_CACHE_DEPENDANT_TABLES
+#define VP_ITEM_FUNC_HAS_XOR_FUNC
+#define VP_SUPPORT_MRR
+#else
+#define vp_user_defined_key_parts(A) (A)->key_parts
+#define vp_join_table_count(A) (A)->tables
+#define vp_get_default_part_db_type_from_partition(A) \
+ (A)->default_part_db_type
+#define VP_USE_OPEN_SKIP_TEMPORARY
+#define VP_KEY_HAS_EXTRA_LENGTH
+#define VP_HANDLER_HAS_HA_INDEX_READ_LAST_MAP
+#define VP_HANDLER_HAS_ADD_INDEX
+#define VP_HANDLER_HAS_DROP_INDEX
+#define VP_TABLE_HAS_TIMESTAMP_FIELD_TYPE
+#endif
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100009
+#define VP_TEST(A) MY_TEST(A)
+#else
+#define VP_TEST(A) test(A)
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100005
+#define VP_HAS_EXPLAIN_QUERY
+#endif
+
+#if defined(MARIADB_BASE_VERSION)
+#define VP_HANDLER_AUTO_REPAIR_HAS_ERROR
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
+#define VP_CREATE_FIELD_FIELDPTR_FIELDPTR_REQUIRES_THDPTR
+#define VP_QCACHE_INSERT_TABLE_REQUIRES_THDPTR
+#endif
+
+#define vp_set_bit(BITMAP, BIT) \
+ ((BITMAP)[(BIT) / 8] |= (1 << ((BIT) & 7)))
+#define vp_clear_bit(BITMAP, BIT) \
+ ((BITMAP)[(BIT) / 8] &= ~(1 << ((BIT) & 7)))
+#define vp_bit_is_set(BITMAP, BIT) \
+ (uint) ((BITMAP)[(BIT) / 8] & (1 << ((BIT) & 7)))
+
+#ifndef WITHOUT_VP_BG_ACCESS
+#define VP_BG_COMMAND_KILL 0
+#define VP_BG_COMMAND_SELECT 1
+#define VP_BG_COMMAND_INSERT 2
+#define VP_BG_COMMAND_UPDATE 3
+#define VP_BG_COMMAND_DELETE 4
+#define VP_BG_COMMAND_UPDATE_SELECT 5
+
+#ifndef DBUG_OFF
+#define VP_DBUG_PRINT_FIELD_VALUES(table, ptr_diff) \
+ { \
+ char buff[MAX_FIELD_WIDTH]; \
+ String str(buff, sizeof(buff), &my_charset_bin); \
+ for (uint i = 0; i < table->s->fields; ++i) \
+ { \
+ Field *field = table->field[i]; \
+ DBUG_PRINT("info", ("vp field[%u]=%p", i, field)); \
+ DBUG_PRINT("info", ("vp field[%u].ptr=%p", i, field->ptr)); \
+ DBUG_PRINT("info", ("vp field[%u].null_ptr=%p", i, field->null_ptr)); \
+ DBUG_PRINT("info", ("vp field[%u].null_bit=%u", i, field->null_bit)); \
+ field->move_field_offset(ptr_diff); \
+ if (field->is_null()) \
+ { \
+ DBUG_PRINT("info", ("vp null")); \
+ } else { \
+ DBUG_PRINT("info", ("vp not null")); \
+ field->val_str(&str); \
+ uint length = str.length(); \
+ DBUG_PRINT("info", ("vp length = %d", length)); \
+ char *value = (char *) my_alloca(length + 1); \
+ memcpy(value, str.ptr(), length); \
+ value[length] = '\0'; \
+ DBUG_PRINT("info", ("vp value = %s", value)); \
+ my_afree(value); \
+ } \
+ field->move_field_offset(-ptr_diff); \
+ } \
+ }
+#else
+#define VP_DBUG_PRINT_FIELD_VALUES(table, ptr_diff)
+#endif
+
+typedef struct st_vp_bulk_access_info VP_BULK_ACCESS_INFO;
+
+#ifdef VP_SUPPORT_MRR
+class ha_vp;
+typedef struct st_vp_key_multi_range
+{
+ uint id;
+ uchar *key[2];
+ uint length[2];
+ KEY_MULTI_RANGE key_multi_range;
+ range_id_t ptr;
+ st_vp_key_multi_range *next;
+} VP_KEY_MULTI_RANGE;
+
+typedef struct st_vp_child_key_multi_range
+{
+ VP_KEY_MULTI_RANGE *vp_key_multi_range;
+ st_vp_child_key_multi_range *next;
+} VP_CHILD_KEY_MULTI_RANGE;
+
+typedef struct st_vp_child_key_multi_range_hld
+{
+ ha_vp *vp;
+ int child_table_idx;
+ VP_CHILD_KEY_MULTI_RANGE *vp_child_key_multi_range;
+} VP_CHILD_KEY_MULTI_RANGE_HLD;
+#endif
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+typedef struct st_vp_clone_patition_handler_share
+{
+ uint use_count;
+ void **handlers;
+ my_bitmap_map *idx_read_bitmap;
+ my_bitmap_map *idx_write_bitmap;
+ bool idx_bitmap_is_set;
+} VP_CLONE_PARTITION_HANDLER_SHARE;
+
+typedef struct st_vp_patition_handler_share
+{
+ uint use_count;
+ TABLE *table;
+ void *creator;
+ void **handlers;
+ my_bitmap_map *idx_init_read_bitmap;
+ my_bitmap_map *idx_init_write_bitmap;
+ my_bitmap_map *rnd_init_read_bitmap;
+ my_bitmap_map *rnd_init_write_bitmap;
+ my_bitmap_map *idx_read_bitmap;
+ my_bitmap_map *idx_write_bitmap;
+ my_bitmap_map *rnd_read_bitmap;
+ my_bitmap_map *rnd_write_bitmap;
+ bool idx_init_flg;
+ bool rnd_init_flg;
+ bool idx_bitmap_is_set;
+ bool rnd_bitmap_is_set;
+ VP_CLONE_PARTITION_HANDLER_SHARE *clone_partition_handler_share;
+ VP_BULK_ACCESS_INFO *current_bulk_access_info;
+} VP_PARTITION_HANDLER_SHARE;
+
+typedef struct st_vp_patition_share
+{
+ char *table_name;
+ uint table_name_length;
+ uint use_count;
+ pthread_mutex_t pt_handler_mutex;
+ HASH pt_handler_hash;
+
+/*
+ volatile VP_PARTITION_HANDLER_SHARE *partition_handler_share;
+*/
+} VP_PARTITION_SHARE;
+#endif
+
+typedef struct st_vp_bg_base
+{
+ int table_idx;
+ TABLE_LIST *part_table;
+ handler *parent;
+ uchar table_key_different[MAX_KEY_LENGTH];
+ volatile uchar *table_key;
+ volatile key_part_map tgt_key_part_map;
+ volatile int key_idx;
+ volatile int record_idx;
+ volatile bool bg_init;
+ volatile bool bg_caller_sync_wait;
+ volatile int bg_command;
+ volatile int bg_error;
+ THD *bg_thd;
+ pthread_t bg_thread;
+ pthread_cond_t bg_cond;
+ pthread_mutex_t bg_mutex;
+ pthread_cond_t bg_sync_cond;
+ pthread_mutex_t bg_sync_mutex;
+} VP_BG_BASE;
+#endif
+
+typedef struct st_vp_correspond_key
+{
+ int table_idx;
+ int key_idx;
+ uchar *columns_bit;
+ st_vp_correspond_key *next;
+ uint key_parts;
+ st_vp_correspond_key *next_shortest;
+} VP_CORRESPOND_KEY;
+
+typedef struct st_vp_key
+{
+ int key_idx;
+ uchar *columns_bit;
+ VP_CORRESPOND_KEY *correspond_key;
+ VP_CORRESPOND_KEY *shortest_correspond_key;
+ st_vp_key *key_length_next;
+ st_vp_key *key_length_prev;
+} VP_KEY;
+
+typedef struct st_vp_share
+{
+ char *table_name;
+ uint table_name_length;
+ uint use_count;
+ pthread_mutex_t mutex;
+ THR_LOCK lock;
+
+ int table_count;
+ volatile bool init;
+ volatile bool reinit;
+ pthread_mutex_t init_mutex;
+ ulong *def_versions;
+ longlong additional_table_flags;
+ int bitmap_size;
+ int use_tables_size;
+ int *correspond_columns_p;
+ int *correspond_pt_columns_p;
+ int **correspond_columns_c_ptr;
+ int **uncorrespond_pt_columns_c_ptr;
+ uchar *correspond_columns_bit;
+ uchar *all_columns_bit; /* all column flags are setted */
+ VP_KEY *keys;
+ VP_KEY *largest_key;
+ VP_CORRESPOND_KEY **correspond_pk;
+ VP_CORRESPOND_KEY **correspond_keys_p_ptr;
+ bool same_all_columns;
+ uchar *need_converting;
+ uchar *same_columns;
+ uchar *need_searching;
+ uchar *need_full_col_for_update;
+ uchar *pk_in_read_index;
+ uchar *select_ignore;
+ uchar *select_ignore_with_lock;
+ uchar *cpy_clm_bitmap;
+
+ int choose_table_mode;
+ int choose_table_mode_for_lock;
+ int multi_range_mode;
+ int str_copy_mode;
+ int pk_correspond_mode;
+ int info_src_table;
+ int auto_increment_table;
+ int table_count_mode;
+ int support_table_cache;
+ int child_binlog;
+#ifndef WITHOUT_VP_BG_ACCESS
+ int bgs_mode;
+ int bgi_mode;
+ int bgu_mode;
+#endif
+ int zero_record_update_mode;
+ int allow_bulk_autoinc;
+ int allow_different_column_type;
+
+ char *tgt_default_db_name;
+ char *tgt_table_name_list;
+ char *tgt_table_name_prefix;
+ char *tgt_table_name_suffix;
+ char *choose_ignore_table_list;
+ char *choose_ignore_table_list_for_lock;
+
+ uint tgt_default_db_name_length;
+ uint tgt_table_name_list_length;
+ uint tgt_table_name_prefix_length;
+ uint tgt_table_name_suffix_length;
+ uint choose_ignore_table_list_length;
+ uint choose_ignore_table_list_for_lock_length;
+
+ char **tgt_db_name;
+ char **tgt_table_name;
+ TABLE_LIST *part_tables;
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ VP_PARTITION_SHARE *partition_share;
+#endif
+} VP_SHARE;
+
+typedef struct st_vp_key_copy
+{
+ uchar table_key_same[MAX_KEY_LENGTH];
+ uchar *table_key_different;
+ bool init;
+ key_part_map tgt_key_part_map;
+ bool mem_root_init;
+ MEM_ROOT mem_root;
+ char **ptr;
+ int *len;
+ uchar *null_flg;
+} VP_KEY_COPY;
+
+#if MYSQL_VERSION_ID < 50500
+#else
+typedef struct st_vp_child_info
+{
+ enum_table_ref_type child_table_ref_type;
+ ulong child_def_version;
+} VP_CHILD_INFO;
+#endif
diff --git a/storage/vp/vp_param.cc b/storage/vp/vp_param.cc
new file mode 100644
index 00000000000..3380604eea5
--- /dev/null
+++ b/storage/vp/vp_param.cc
@@ -0,0 +1,384 @@
+/* Copyright (C) 2009-2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MYSQL_SERVER 1
+#include <my_global.h>
+#include "mysql_version.h"
+#include "vp_environ.h"
+#if MYSQL_VERSION_ID < 50500
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#else
+#include "sql_priv.h"
+#include "probes_mysql.h"
+#include "sql_class.h"
+#include "sql_partition.h"
+#include "sql_select.h"
+#endif
+#include "vp_include.h"
+#include "ha_vp.h"
+#include "vp_table.h"
+
+static my_bool vp_support_xa;
+static MYSQL_SYSVAR_BOOL(
+ support_xa,
+ vp_support_xa,
+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+ "XA support",
+ NULL,
+ NULL,
+ TRUE
+);
+
+my_bool vp_param_support_xa()
+{
+ DBUG_ENTER("vp_param_support_xa");
+ DBUG_RETURN(vp_support_xa);
+}
+
+/*
+ -1 :use table parameter
+ 0 :minimum
+ 1 :sequential
+ */
+static MYSQL_THDVAR_INT(
+ choose_table_mode, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of choosing to access tables", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_choose_table_mode(
+ THD *thd,
+ int choose_table_mode
+) {
+ DBUG_ENTER("vp_param_choose_table_mode");
+ DBUG_RETURN(THDVAR(thd, choose_table_mode) < 0 ?
+ choose_table_mode : THDVAR(thd, choose_table_mode));
+}
+
+/*
+ -1 :use table parameter
+ 0 :minimum
+ 1 :sequential
+ */
+static MYSQL_THDVAR_INT(
+ choose_table_mode_for_lock, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of choosing to access tables for lock", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_choose_table_mode_for_lock(
+ THD *thd,
+ int choose_table_mode_for_lock
+) {
+ DBUG_ENTER("vp_param_choose_table_mode_for_lock");
+ DBUG_RETURN(THDVAR(thd, choose_table_mode_for_lock) < 0 ?
+ choose_table_mode_for_lock : THDVAR(thd, choose_table_mode_for_lock));
+}
+
+/*
+ -1 :use table parameter
+ 0 :separete range
+ 1 :multi range
+ */
+static MYSQL_THDVAR_INT(
+ multi_range_mode, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of choosing to access tables", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_multi_range_mode(
+ THD *thd,
+ int multi_range_mode
+) {
+ DBUG_ENTER("vp_param_multi_range_mode");
+ DBUG_RETURN(THDVAR(thd, multi_range_mode) < 0 ?
+ multi_range_mode : THDVAR(thd, multi_range_mode));
+}
+
+/*
+ -1 :use table parameter
+ 0 :separete range
+ 1 :multi range
+ */
+static MYSQL_THDVAR_INT(
+ child_binlog, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of choosing to access tables", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_child_binlog(
+ THD *thd,
+ int child_binlog
+) {
+ DBUG_ENTER("vp_param_child_binlog");
+ DBUG_RETURN(THDVAR(thd, child_binlog) < 0 ?
+ child_binlog : THDVAR(thd, child_binlog));
+}
+
+#ifndef WITHOUT_VP_BG_ACCESS
+/*
+ -1 :use table parameter
+ 0 :background search is disabled
+ 1 :background search is enabled
+ */
+static MYSQL_THDVAR_INT(
+ bgs_mode, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of background search", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_bgs_mode(
+ THD *thd,
+ int bgs_mode
+) {
+ DBUG_ENTER("vp_param_bgs_mode");
+ DBUG_RETURN(THDVAR(thd, bgs_mode) < 0 ?
+ bgs_mode : THDVAR(thd, bgs_mode));
+}
+
+/*
+ -1 :use table parameter
+ 0 :background insert is disabled
+ 1 :background insert is enabled
+ */
+static MYSQL_THDVAR_INT(
+ bgi_mode, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of background insert", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_bgi_mode(
+ THD *thd,
+ int bgi_mode
+) {
+ DBUG_ENTER("vp_param_bgi_mode");
+ DBUG_RETURN(THDVAR(thd, bgi_mode) < 0 ?
+ bgi_mode : THDVAR(thd, bgi_mode));
+}
+
+/*
+ -1 :use table parameter
+ 0 :background update is disabled
+ 1 :background update is enabled
+ */
+static MYSQL_THDVAR_INT(
+ bgu_mode, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of background update", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_bgu_mode(
+ THD *thd,
+ int bgu_mode
+) {
+ DBUG_ENTER("vp_param_bgu_mode");
+ DBUG_RETURN(THDVAR(thd, bgu_mode) < 0 ?
+ bgu_mode : THDVAR(thd, bgu_mode));
+}
+#endif
+
+/*
+ -1 :use table parameter
+ 0 :exchange bulk inserting to single inserting for safety
+ 1 :allow bulk inserting with auto_increment
+ */
+static MYSQL_THDVAR_INT(
+ allow_bulk_autoinc, /* name */
+ PLUGIN_VAR_RQCMDARG, /* opt */
+ "Mode of bulk inserting into table with auto_increment", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ -1, /* def */
+ -1, /* min */
+ 1, /* max */
+ 0 /* blk */
+);
+
+int vp_param_allow_bulk_autoinc(
+ THD *thd,
+ int allow_bulk_autoinc
+) {
+ DBUG_ENTER("vp_param_allow_bulk_autoinc");
+ DBUG_RETURN(THDVAR(thd, allow_bulk_autoinc) < 0 ?
+ allow_bulk_autoinc : THDVAR(thd, allow_bulk_autoinc));
+}
+
+static int vp_udf_ct_bulk_insert_interval;
+/*
+ -1 : The UDF parameter is adopted.
+ 0 or more : Milliseconds.
+ */
+static MYSQL_SYSVAR_INT(
+ udf_ct_bulk_insert_interval,
+ vp_udf_ct_bulk_insert_interval,
+ PLUGIN_VAR_RQCMDARG,
+ "The interval time between bulk insert and next bulk insert at coping",
+ NULL,
+ NULL,
+ -1,
+ -1,
+ 2147483647,
+ 0
+);
+
+int vp_param_udf_ct_bulk_insert_interval(
+ int udf_ct_bulk_insert_interval
+) {
+ DBUG_ENTER("vp_param_udf_ct_bulk_insert_interval");
+ DBUG_RETURN(vp_udf_ct_bulk_insert_interval < 0 ?
+ udf_ct_bulk_insert_interval : vp_udf_ct_bulk_insert_interval);
+}
+
+static longlong vp_udf_ct_bulk_insert_rows;
+/*
+ -1,0 : The UDF parameter is adopted.
+ 1 or more : Number of rows.
+ */
+static MYSQL_SYSVAR_LONGLONG(
+ udf_ct_bulk_insert_rows,
+ vp_udf_ct_bulk_insert_rows,
+ PLUGIN_VAR_RQCMDARG,
+ "The number of rows inserted with bulk insert of one time at coping",
+ NULL,
+ NULL,
+ -1,
+ -1,
+ 9223372036854775807LL,
+ 0
+);
+
+longlong vp_param_udf_ct_bulk_insert_rows(
+ longlong udf_ct_bulk_insert_rows
+) {
+ DBUG_ENTER("vp_param_udf_ct_bulk_insert_rows");
+ DBUG_RETURN(vp_udf_ct_bulk_insert_rows <= 0 ?
+ udf_ct_bulk_insert_rows : vp_udf_ct_bulk_insert_rows);
+}
+
+static char *vp_version = (char *) VP_DETAIL_VERSION;
+static MYSQL_SYSVAR_STR(
+ version,
+ vp_version,
+ PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
+ "The version of Vertical Partitioning",
+ NULL,
+ NULL,
+ VP_DETAIL_VERSION
+);
+
+struct st_mysql_storage_engine vp_storage_engine =
+{ MYSQL_HANDLERTON_INTERFACE_VERSION };
+
+struct st_mysql_sys_var* vp_system_variables[] = {
+ MYSQL_SYSVAR(support_xa),
+ MYSQL_SYSVAR(choose_table_mode),
+ MYSQL_SYSVAR(choose_table_mode_for_lock),
+ MYSQL_SYSVAR(multi_range_mode),
+ MYSQL_SYSVAR(child_binlog),
+#ifndef WITHOUT_VP_BG_ACCESS
+ MYSQL_SYSVAR(bgs_mode),
+ MYSQL_SYSVAR(bgi_mode),
+ MYSQL_SYSVAR(bgu_mode),
+#endif
+ MYSQL_SYSVAR(allow_bulk_autoinc),
+ MYSQL_SYSVAR(udf_ct_bulk_insert_interval),
+ MYSQL_SYSVAR(udf_ct_bulk_insert_rows),
+ MYSQL_SYSVAR(version),
+ NULL
+};
+
+mysql_declare_plugin(vp)
+{
+ MYSQL_STORAGE_ENGINE_PLUGIN,
+ &vp_storage_engine,
+ "VP",
+ "Kentoku Shiba",
+ "Vertical Partitioning Storage Engine",
+ PLUGIN_LICENSE_GPL,
+ vp_db_init,
+ vp_db_done,
+ VP_HEX_VERSION,
+ NULL,
+ vp_system_variables,
+ NULL,
+#if MYSQL_VERSION_ID >= 50600
+ 0,
+#endif
+}
+mysql_declare_plugin_end;
+
+#ifdef MARIADB_BASE_VERSION
+maria_declare_plugin(vp)
+{
+ MYSQL_STORAGE_ENGINE_PLUGIN,
+ &vp_storage_engine,
+ "VP",
+ "Kentoku Shiba",
+ "Vertical Partitioning Storage Engine",
+ PLUGIN_LICENSE_GPL,
+ vp_db_init,
+ vp_db_done,
+ VP_HEX_VERSION,
+ NULL,
+ vp_system_variables,
+ VP_DETAIL_VERSION,
+ MariaDB_PLUGIN_MATURITY_BETA
+}
+maria_declare_plugin_end;
+#endif
diff --git a/storage/vp/vp_param.h b/storage/vp/vp_param.h
new file mode 100644
index 00000000000..40b02e43487
--- /dev/null
+++ b/storage/vp/vp_param.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 2009-2014 Kentoku Shiba
+
+ This program is free software); you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation); version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY); without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program); if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+my_bool vp_param_support_xa();
+int vp_param_choose_table_mode(
+ THD *thd,
+ int choose_table_mode
+);
+int vp_param_choose_table_mode_for_lock(
+ THD *thd,
+ int choose_table_mode_for_lock
+);
+int vp_param_multi_range_mode(
+ THD *thd,
+ int multi_range_mode
+);
+int vp_param_child_binlog(
+ THD *thd,
+ int child_binlog
+);
+#ifndef WITHOUT_VP_BG_ACCESS
+int vp_param_bgs_mode(
+ THD *thd,
+ int bgs_mode
+);
+int vp_param_bgi_mode(
+ THD *thd,
+ int bgi_mode
+);
+int vp_param_bgu_mode(
+ THD *thd,
+ int bgu_mode
+);
+#endif
+int vp_param_allow_bulk_autoinc(
+ THD *thd,
+ int allow_bulk_autoinc
+);
+int vp_param_udf_ct_bulk_insert_interval(
+ int udf_ct_bulk_insert_interval
+);
+longlong vp_param_udf_ct_bulk_insert_rows(
+ longlong udf_ct_bulk_insert_rows
+);
diff --git a/storage/vp/vp_table.cc b/storage/vp/vp_table.cc
new file mode 100644
index 00000000000..e8814ef331a
--- /dev/null
+++ b/storage/vp/vp_table.cc
@@ -0,0 +1,2705 @@
+/* Copyright (C) 2009-2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MYSQL_SERVER 1
+#include <my_global.h>
+#include "mysql_version.h"
+#include "vp_environ.h"
+#if MYSQL_VERSION_ID < 50500
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#else
+#include "sql_priv.h"
+#include "probes_mysql.h"
+#include "sql_class.h"
+#include "sql_base.h"
+#include "sql_select.h"
+#endif
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#include "ha_partition.h"
+#endif
+#include "vp_err.h"
+#include "vp_param.h"
+#include "vp_include.h"
+#include "ha_vp.h"
+#include "vp_table.h"
+
+#ifndef VP_HAS_NEXT_THREAD_ID
+ulong *vp_db_att_thread_id;
+#endif
+
+handlerton *vp_hton_ptr;
+handlerton *vp_partition_hton_ptr;
+
+#ifdef HAVE_PSI_INTERFACE
+PSI_mutex_key vp_key_mutex_tbl;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+PSI_mutex_key vp_key_mutex_pt_share;
+#endif
+PSI_mutex_key vp_key_mutex_bg_sync;
+PSI_mutex_key vp_key_mutex_bg;
+PSI_mutex_key vp_key_mutex_share;
+PSI_mutex_key vp_key_mutex_share_init;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+PSI_mutex_key vp_key_mutex_pt_handler;
+#endif
+
+static PSI_mutex_info all_vp_mutexes[]=
+{
+ { &vp_key_mutex_tbl, "tbl", PSI_FLAG_GLOBAL},
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ { &vp_key_mutex_pt_share, "pt_share", PSI_FLAG_GLOBAL},
+#endif
+#ifndef WITHOUT_VP_BG_ACCESS
+ { &vp_key_mutex_bg_sync, "bg_sync", 0},
+ { &vp_key_mutex_bg, "bg", 0},
+#endif
+ { &vp_key_mutex_share, "share", 0},
+ { &vp_key_mutex_share_init, "share_init", 0},
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ { &vp_key_mutex_pt_handler, "pt_handler", 0},
+#endif
+};
+
+#ifndef WITHOUT_VP_BG_ACCESS
+PSI_cond_key vp_key_cond_bg_sync;
+PSI_cond_key vp_key_cond_bg;
+#endif
+
+static PSI_cond_info all_vp_conds[] = {
+#ifndef WITHOUT_VP_BG_ACCESS
+ {&vp_key_cond_bg_sync, "bg_sync", 0},
+ {&vp_key_cond_bg, "bg", 0},
+#endif
+};
+
+#ifndef WITHOUT_VP_BG_ACCESS
+PSI_thread_key vp_key_thd_bg;
+#endif
+
+static PSI_thread_info all_vp_threads[] = {
+#ifndef WITHOUT_VP_BG_ACCESS
+ {&vp_key_thd_bg, "bg", 0},
+#endif
+};
+#endif
+
+HASH vp_open_tables;
+pthread_mutex_t vp_tbl_mutex;
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+HASH vp_open_pt_share;
+pthread_mutex_t vp_pt_share_mutex;
+#endif
+
+#ifndef WITHOUT_VP_BG_ACCESS
+pthread_attr_t vp_pt_attr;
+#endif
+
+// for vp_open_tables
+uchar *vp_tbl_get_key(
+ VP_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+) {
+ DBUG_ENTER("vp_tbl_get_key");
+ *length = share->table_name_length;
+ DBUG_RETURN((uchar*) share->table_name);
+}
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+uchar *vp_pt_share_get_key(
+ VP_PARTITION_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+) {
+ DBUG_ENTER("vp_pt_share_get_key");
+ *length = share->table_name_length;
+ DBUG_RETURN((uchar*) share->table_name);
+}
+
+uchar *vp_pt_handler_share_get_key(
+ VP_PARTITION_HANDLER_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+) {
+ DBUG_ENTER("vp_pt_handler_share_get_key");
+ *length = sizeof(TABLE *);
+ DBUG_RETURN((uchar*) &share->table);
+}
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+static void init_vp_psi_keys()
+{
+ DBUG_ENTER("init_vp_psi_keys");
+ if (PSI_server == NULL)
+ DBUG_VOID_RETURN;
+
+ PSI_server->register_mutex("vp", all_vp_mutexes,
+ array_elements(all_vp_mutexes));
+ PSI_server->register_cond("vp", all_vp_conds,
+ array_elements(all_vp_conds));
+ PSI_server->register_thread("vp", all_vp_threads,
+ array_elements(all_vp_threads));
+ DBUG_VOID_RETURN;
+}
+#endif
+
+int vp_free_share_alloc(
+ VP_SHARE *share
+) {
+ DBUG_ENTER("vp_free_share_alloc");
+ if (share->tgt_default_db_name)
+ vp_my_free(share->tgt_default_db_name, MYF(0));
+ if (share->tgt_table_name_list)
+ vp_my_free(share->tgt_table_name_list, MYF(0));
+ if (share->tgt_table_name_prefix)
+ vp_my_free(share->tgt_table_name_prefix, MYF(0));
+ if (share->tgt_table_name_suffix)
+ vp_my_free(share->tgt_table_name_suffix, MYF(0));
+ if (share->choose_ignore_table_list)
+ vp_my_free(share->choose_ignore_table_list, MYF(0));
+ if (share->choose_ignore_table_list_for_lock)
+ vp_my_free(share->choose_ignore_table_list_for_lock, MYF(0));
+ if (share->tgt_db_name)
+ vp_my_free(share->tgt_db_name, MYF(0));
+ if (share->correspond_columns_p)
+ vp_my_free(share->correspond_columns_p, MYF(0));
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (share->partition_share)
+ vp_free_pt_share(share->partition_share);
+#endif
+ DBUG_RETURN(0);
+}
+
+/**
+ Initialize the parameter string parse information.
+
+ @param param_string Pointer to the parameter string being parsed.
+ @param error_code Error code of the error message to print when
+ an error is detected.
+*/
+
+inline void st_vp_param_string_parse::init(
+ char *param_string,
+ int error_code
+)
+{
+ DBUG_ENTER("st_vp_param_string_parse::init");
+ start_ptr = param_string;
+ end_ptr = start_ptr + strlen(start_ptr);
+
+ init_param_title();
+ init_param_value();
+
+ error_num = error_code;
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Initialize the current parameter title.
+*/
+
+inline void st_vp_param_string_parse::init_param_title()
+{
+ DBUG_ENTER("st_vp_param_string_parse::init_param_title");
+ start_title_ptr = end_title_ptr = NULL;
+ delim_title_len = 0;
+ delim_title = '\0';
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Save pointers to the start and end positions of the current parameter
+ title in the parameter string. Also save the parameter title's
+ delimiter character.
+
+ @param start_value Pointer to the start position of the current
+ parameter title.
+ @param end_value Pointer to the end position of the current
+ parameter title.
+*/
+
+inline void st_vp_param_string_parse::set_param_title(
+ char *start_title,
+ char *end_title
+)
+{
+ DBUG_ENTER("st_vp_param_string_parse::set_param_title");
+ start_title_ptr = start_title;
+ end_title_ptr = end_title;
+
+ if (*start_title == '"' ||
+ *start_title == '\'')
+ {
+ delim_title = *start_title;
+
+ if (start_title >= start_ptr && *--start_title == '\\')
+ delim_title_len = 2;
+ else
+ delim_title_len = 1;
+ }
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Initialize the current parameter value.
+*/
+
+inline void st_vp_param_string_parse::init_param_value()
+{
+ DBUG_ENTER("st_vp_param_string_parse::init_param_value");
+ start_value_ptr = end_value_ptr = NULL;
+ delim_value_len = 0;
+ delim_value = '\0';
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Save pointers to the start and end positions of the current parameter
+ value in the parameter string. Also save the parameter value's
+ delimiter character.
+
+ @param start_value Pointer to the start position of the current
+ parameter value.
+ @param end_value Pointer to the end position of the current
+ parameter value.
+*/
+
+inline void st_vp_param_string_parse::set_param_value(
+ char *start_value,
+ char *end_value
+)
+{
+ DBUG_ENTER("st_vp_param_string_parse::set_param_value");
+ start_value_ptr = start_value--;
+ end_value_ptr = end_value;
+
+ if (*start_value == '"' ||
+ *start_value == '\'')
+ {
+ delim_value = *start_value;
+
+ if (*--start_value == '\\')
+ delim_value_len = 2;
+ else
+ delim_value_len = 1;
+ }
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Determine whether the current parameter in the parameter string has
+ extra parameter values.
+
+ @return 0 Current parameter value in the parameter string
+ does not have extra parameter values.
+ <> 0 Error code indicating that the current parameter
+ value in the parameter string has extra
+ parameter values.
+*/
+
+inline int st_vp_param_string_parse::has_extra_parameter_values()
+{
+ int error_num = 0;
+ DBUG_ENTER("st_vp_param_string_parse::has_extra_parameter_values");
+
+ if (end_value_ptr)
+ {
+ /* There is a current parameter value */
+ char *end_param_ptr = end_value_ptr;
+
+ while (end_param_ptr < end_ptr &&
+ (*end_param_ptr == ' ' || *end_param_ptr == '\r' ||
+ *end_param_ptr == '\n' || *end_param_ptr == '\t'))
+ end_param_ptr++;
+
+ if (end_param_ptr < end_ptr && *end_param_ptr != '\0')
+ {
+ /* Extra values in parameter definition */
+ error_num = print_param_error();
+ }
+ }
+
+ DBUG_RETURN(error_num);
+}
+
+/**
+ Restore the current parameter's input delimiter characters in the
+ parameter string. They were NULLed during parameter parsing.
+*/
+
+inline void st_vp_param_string_parse::restore_delims()
+{
+ char *end = end_title_ptr - 1;
+ DBUG_ENTER("st_vp_param_string_parse::restore_delims");
+
+ switch (delim_title_len)
+ {
+ case 2:
+ *end++ = '\\';
+ /* Fall through */
+ case 1:
+ *end = delim_title;
+ }
+
+ end = end_value_ptr - 1;
+ switch (delim_value_len)
+ {
+ case 2:
+ *end++ = '\\';
+ /* Fall through */
+ case 1:
+ *end = delim_value;
+ }
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Print a parameter string error message.
+
+ @return Error code.
+*/
+
+int st_vp_param_string_parse::print_param_error()
+{
+ DBUG_ENTER("st_vp_param_string_parse::print_param_error");
+ if (start_title_ptr)
+ {
+ /* Restore the input delimiter characters */
+ restore_delims();
+
+ /* Print the error message */
+ switch (error_num)
+ {
+ case ER_VP_INVALID_UDF_PARAM_NUM:
+ my_printf_error(error_num, ER_VP_INVALID_UDF_PARAM_STR,
+ MYF(0), start_title_ptr);
+ break;
+ case ER_VP_INVALID_TABLE_INFO_NUM:
+ default:
+ my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_STR,
+ MYF(0), start_title_ptr);
+ }
+
+ DBUG_RETURN(error_num);
+ }
+ DBUG_RETURN(0);
+}
+
+char *vp_get_string_between_quote(
+ char *ptr,
+ bool alloc,
+ VP_PARAM_STRING_PARSE *param_string_parse
+) {
+ char *start_ptr, *end_ptr, *tmp_ptr, *esc_ptr;
+ bool find_flg = FALSE, esc_flg = FALSE;
+ DBUG_ENTER("vp_get_string_between_quote");
+
+ start_ptr = strchr(ptr, '\'');
+ end_ptr = strchr(ptr, '"');
+ if (start_ptr && (!end_ptr || start_ptr < end_ptr))
+ {
+ tmp_ptr = ++start_ptr;
+ while (!find_flg)
+ {
+ if (!(end_ptr = strchr(tmp_ptr, '\'')))
+ DBUG_RETURN(NULL);
+ esc_ptr = tmp_ptr;
+ while (!find_flg)
+ {
+ esc_ptr = strchr(esc_ptr, '\\');
+ if (!esc_ptr || esc_ptr > end_ptr)
+ find_flg = TRUE;
+ else if (esc_ptr == end_ptr - 1)
+ {
+ esc_flg = TRUE;
+ tmp_ptr = end_ptr + 1;
+ break;
+ } else {
+ esc_flg = TRUE;
+ esc_ptr += 2;
+ }
+ }
+ }
+ } else if (end_ptr)
+ {
+ start_ptr = end_ptr;
+ tmp_ptr = ++start_ptr;
+ while (!find_flg)
+ {
+ if (!(end_ptr = strchr(tmp_ptr, '"')))
+ DBUG_RETURN(NULL);
+ esc_ptr = tmp_ptr;
+ while (!find_flg)
+ {
+ esc_ptr = strchr(esc_ptr, '\\');
+ if (!esc_ptr || esc_ptr > end_ptr)
+ find_flg = TRUE;
+ else if (esc_ptr == end_ptr - 1)
+ {
+ esc_flg = TRUE;
+ tmp_ptr = end_ptr + 1;
+ break;
+ } else {
+ esc_flg = TRUE;
+ esc_ptr += 2;
+ }
+ }
+ }
+ } else
+ DBUG_RETURN(NULL);
+
+ *end_ptr = '\0';
+ if (esc_flg)
+ {
+ esc_ptr = start_ptr;
+ while (TRUE)
+ {
+ esc_ptr = strchr(esc_ptr, '\\');
+ if (!esc_ptr)
+ break;
+ switch(*(esc_ptr + 1))
+ {
+ case 'b':
+ *esc_ptr = '\b';
+ break;
+ case 'n':
+ *esc_ptr = '\n';
+ break;
+ case 'r':
+ *esc_ptr = '\r';
+ break;
+ case 't':
+ *esc_ptr = '\t';
+ break;
+ default:
+ *esc_ptr = *(esc_ptr + 1);
+ break;
+ }
+ esc_ptr++;
+ strcpy(esc_ptr, esc_ptr + 1);
+ }
+ }
+
+ if (param_string_parse)
+ param_string_parse->set_param_value(start_ptr, start_ptr + strlen(start_ptr) + 1);
+
+ if (alloc)
+ {
+ DBUG_RETURN(
+ vp_create_string(
+ start_ptr,
+ strlen(start_ptr))
+ );
+ } else {
+ DBUG_RETURN(start_ptr);
+ }
+}
+
+int vp_parse_table_info(
+ VP_SHARE *share,
+ TABLE *table,
+ uint create_table
+) {
+ int error_num = 0;
+ char *comment_string = NULL;
+ char *sprit_ptr[2];
+ char *tmp_ptr, *tmp_ptr2, *start_ptr;
+ int roop_count;
+ int title_length;
+ VP_PARAM_STRING_PARSE param_string_parse;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_element *part_elem;
+ partition_element *sub_elem;
+#endif
+ DBUG_ENTER("vp_parse_table_info");
+#if MYSQL_VERSION_ID < 50500
+ DBUG_PRINT("info",("vp partition_info=%s", table->s->partition_info));
+#else
+ DBUG_PRINT("info",("vp partition_info=%s", table->s->partition_info_str));
+#endif
+ DBUG_PRINT("info",("vp part_info=%p", table->part_info));
+ DBUG_PRINT("info",("vp s->db=%s", table->s->db.str));
+ DBUG_PRINT("info",("vp s->table_name=%s", table->s->table_name.str));
+ DBUG_PRINT("info",("vp s->path=%s", table->s->path.str));
+ DBUG_PRINT("info",
+ ("vp s->normalized_path=%s", table->s->normalized_path.str));
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ vp_get_partition_info(share->table_name, share->table_name_length, table->s,
+ table->part_info, &part_elem, &sub_elem);
+#endif
+ share->choose_table_mode = -1;
+ share->choose_table_mode_for_lock = -1;
+ share->multi_range_mode = -1;
+ share->pk_correspond_mode = -1;
+ share->info_src_table = -1;
+ share->auto_increment_table = -1;
+ share->table_count_mode = -1;
+ share->support_table_cache = -1;
+ share->child_binlog = -1;
+#ifndef WITHOUT_VP_BG_ACCESS
+ share->bgs_mode = -1;
+ share->bgi_mode = -1;
+ share->bgu_mode = -1;
+#endif
+ share->zero_record_update_mode = -1;
+ share->allow_bulk_autoinc = -1;
+ share->allow_different_column_type = -1;
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef VP_PARTITION_HAS_CONNECTION_STRING
+ for (roop_count = 6; roop_count > 0; roop_count--)
+#else
+ for (roop_count = 4; roop_count > 0; roop_count--)
+#endif
+#else
+ for (roop_count = 2; roop_count > 0; roop_count--)
+#endif
+ {
+ if (comment_string)
+ {
+ vp_my_free(comment_string, MYF(0));
+ comment_string = NULL;
+ }
+ switch (roop_count)
+ {
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#ifdef VP_PARTITION_HAS_CONNECTION_STRING
+ case 6:
+ if (!sub_elem || sub_elem->connect_string.length == 0)
+ continue;
+ DBUG_PRINT("info",("vp create sub connect string"));
+ if (
+ !(comment_string = vp_create_string(
+ sub_elem->connect_string.str,
+ sub_elem->connect_string.length))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp connect_string=%s", comment_string));
+ break;
+ case 5:
+#else
+ case 4:
+#endif
+ if (!sub_elem || !sub_elem->part_comment)
+ continue;
+ DBUG_PRINT("info",("vp create sub comment string"));
+ if (
+ !(comment_string = vp_create_string(
+ sub_elem->part_comment,
+ strlen(sub_elem->part_comment)))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp sub comment string=%s", comment_string));
+ break;
+#ifdef VP_PARTITION_HAS_CONNECTION_STRING
+ case 4:
+ if (!part_elem || part_elem->connect_string.length == 0)
+ continue;
+ DBUG_PRINT("info",("vp create part connect string"));
+ if (
+ !(comment_string = vp_create_string(
+ part_elem->connect_string.str,
+ part_elem->connect_string.length))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp connect_string=%s", comment_string));
+ break;
+#endif
+ case 3:
+ if (!part_elem || !part_elem->part_comment)
+ continue;
+ DBUG_PRINT("info",("vp create part comment string"));
+ if (
+ !(comment_string = vp_create_string(
+ part_elem->part_comment,
+ strlen(part_elem->part_comment)))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp part comment string=%s", comment_string));
+ break;
+#endif
+ case 2:
+ if (table->s->comment.length == 0)
+ continue;
+ DBUG_PRINT("info",("vp create comment string"));
+ if (
+ !(comment_string = vp_create_string(
+ table->s->comment.str,
+ table->s->comment.length))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp comment string=%s", comment_string));
+ break;
+ default:
+ if (table->s->connect_string.length == 0)
+ continue;
+ DBUG_PRINT("info",("vp create connect_string string"));
+ if (
+ !(comment_string = vp_create_string(
+ table->s->connect_string.str,
+ table->s->connect_string.length))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_comment_string;
+ }
+ DBUG_PRINT("info",("vp comment_string=%s", comment_string));
+ break;
+ }
+
+ sprit_ptr[0] = comment_string;
+ param_string_parse.init(comment_string,
+ ER_VP_INVALID_TABLE_INFO_NUM);
+ while (sprit_ptr[0])
+ {
+ if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
+ {
+ *sprit_ptr[1] = '\0';
+ sprit_ptr[1]++;
+ }
+ tmp_ptr = sprit_ptr[0];
+ sprit_ptr[0] = sprit_ptr[1];
+ while (*tmp_ptr == ' ' || *tmp_ptr == '\r' ||
+ *tmp_ptr == '\n' || *tmp_ptr == '\t')
+ tmp_ptr++;
+
+ if (*tmp_ptr == '\0')
+ continue;
+
+ title_length = 0;
+ start_ptr = tmp_ptr;
+ while (*start_ptr != ' ' && *start_ptr != '\'' &&
+ *start_ptr != '"' && *start_ptr != '\0' &&
+ *start_ptr != '\r' && *start_ptr != '\n' &&
+ *start_ptr != '\t')
+ {
+ title_length++;
+ start_ptr++;
+ }
+ param_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
+
+ switch (title_length)
+ {
+ case 0:
+ error_num = param_string_parse.print_param_error();
+ if (error_num)
+ goto error;
+ continue;
+ case 3:
+ VP_PARAM_INT_WITH_MAX(share, "aba", allow_bulk_autoinc, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "adc", allow_different_column_type,
+ 0, 1);
+ VP_PARAM_INT(share, "ait", auto_increment_table, 1);
+#ifndef WITHOUT_VP_BG_ACCESS
+ VP_PARAM_INT_WITH_MAX(share, "bgs", bgs_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "bgi", bgi_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "bgu", bgu_mode, 0, 1);
+#endif
+ VP_PARAM_INT_WITH_MAX(share, "cbl", child_binlog, 0, 1);
+ VP_PARAM_STR(share, "cil", choose_ignore_table_list_for_lock);
+ VP_PARAM_STR(share, "cit", choose_ignore_table_list);
+ VP_PARAM_INT_WITH_MAX(share, "cml", choose_table_mode_for_lock,
+ 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "ctm", choose_table_mode, 0, 1);
+ VP_PARAM_STR(share, "ddb", tgt_default_db_name);
+ VP_PARAM_INT_WITH_MAX(share, "tcm", table_count_mode, 0, 1);
+ VP_PARAM_INT(share, "ist", info_src_table, 0);
+ VP_PARAM_INT_WITH_MAX(share, "mrm", multi_range_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "pcm", pk_correspond_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "stc", support_table_cache, 0, 2);
+ VP_PARAM_STR(share, "tnl", tgt_table_name_list);
+ VP_PARAM_STR(share, "tnp", tgt_table_name_prefix);
+ VP_PARAM_STR(share, "tns", tgt_table_name_suffix);
+ VP_PARAM_INT_WITH_MAX(share, "zru", zero_record_update_mode, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+#ifndef WITHOUT_VP_BG_ACCESS
+ case 8:
+ VP_PARAM_INT_WITH_MAX(share, "bgs_mode", bgs_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "bgi_mode", bgi_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "bgu_mode", bgu_mode, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+#endif
+ case 12:
+ VP_PARAM_INT_WITH_MAX(share, "child_binlog", child_binlog, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 15:
+ VP_PARAM_STR(share, "table_name_list", tgt_table_name_list);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 16:
+ VP_PARAM_INT_WITH_MAX(share, "multi_range_mode", multi_range_mode,
+ 0, 1);
+ VP_PARAM_STR(share, "default_database", tgt_default_db_name);
+ VP_PARAM_INT_WITH_MAX(share, "table_count_mode", table_count_mode,
+ 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 17:
+ VP_PARAM_INT_WITH_MAX(share, "choose_table_mode", choose_table_mode,
+ 0, 1);
+ VP_PARAM_STR(share, "table_name_prefix", tgt_table_name_prefix);
+ VP_PARAM_STR(share, "table_name_suffix", tgt_table_name_suffix);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 18:
+ VP_PARAM_INT_WITH_MAX(share, "pk_correspond_mode",
+ pk_correspond_mode, 0, 1);
+ VP_PARAM_INT_WITH_MAX(share, "allow_bulk_autoinc",
+ allow_bulk_autoinc, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 19:
+ VP_PARAM_INT_WITH_MAX(share, "support_table_cache",
+ support_table_cache, 0, 2);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 20:
+ VP_PARAM_INT(share, "auto_increment_table", auto_increment_table, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 23:
+ VP_PARAM_INT(share, "infomation_source_table", info_src_table, 0);
+ VP_PARAM_INT_WITH_MAX(share, "zero_record_update_mode",
+ zero_record_update_mode, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 24:
+ VP_PARAM_STR(share, "choose_ignore_table_list",
+ choose_ignore_table_list);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 26:
+ VP_PARAM_INT_WITH_MAX(share, "choose_table_mode_for_lock",
+ choose_table_mode_for_lock, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 27:
+ VP_PARAM_INT_WITH_MAX(share, "allow_different_column_type",
+ allow_different_column_type, 0, 1);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ case 33:
+ VP_PARAM_STR(share, "choose_ignore_table_list_for_lock",
+ choose_ignore_table_list_for_lock);
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ default:
+ error_num = param_string_parse.print_param_error();
+ goto error;
+ }
+
+ /* Verify that the remainder of the parameter value is whitespace */
+ if ((error_num = param_string_parse.has_extra_parameter_values()))
+ goto error;
+ }
+ }
+
+ if ((error_num = vp_set_table_info_default(
+ share,
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ part_elem,
+ sub_elem,
+#endif
+ table
+ )))
+ goto error;
+
+ if (create_table)
+ {
+ DBUG_PRINT("info",
+ ("vp tgt_default_db_name_length = %u",
+ share->tgt_default_db_name_length));
+ if (share->tgt_default_db_name_length > VP_TABLE_INFO_MAX_LEN)
+ {
+ error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
+ my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
+ MYF(0), share->tgt_default_db_name, "default_database");
+ goto error;
+ }
+
+/*
+ DBUG_PRINT("info",
+ ("vp tgt_table_name_list_length = %ld",
+ share->tgt_table_name_list_length));
+ if (share->tgt_table_name_list_length > VP_TABLE_INFO_MAX_LEN)
+ {
+ error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
+ my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
+ MYF(0), share->tgt_table_name_list, "table_name_list");
+ goto error;
+ }
+*/
+
+ DBUG_PRINT("info",
+ ("vp tgt_table_name_prefix_length = %u",
+ share->tgt_table_name_prefix_length));
+ if (share->tgt_table_name_prefix_length > VP_TABLE_INFO_MAX_LEN)
+ {
+ error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
+ my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
+ MYF(0), share->tgt_table_name_prefix, "table_name_prefix");
+ goto error;
+ }
+
+ DBUG_PRINT("info",
+ ("vp tgt_table_name_suffix_length = %u",
+ share->tgt_table_name_suffix_length));
+ if (share->tgt_table_name_suffix_length > VP_TABLE_INFO_MAX_LEN)
+ {
+ error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
+ my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
+ MYF(0), share->tgt_table_name_suffix, "table_name_suffix");
+ goto error;
+ }
+ }
+
+ if (comment_string)
+ vp_my_free(comment_string, MYF(0));
+ DBUG_RETURN(0);
+
+error:
+ if (comment_string)
+ vp_my_free(comment_string, MYF(0));
+error_alloc_comment_string:
+ DBUG_RETURN(error_num);
+}
+
+int vp_set_table_info_default(
+ VP_SHARE *share,
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_element *part_elem,
+ partition_element *sub_elem,
+#endif
+ TABLE *table
+) {
+ DBUG_ENTER("vp_set_table_info_default");
+ if (!share->tgt_default_db_name)
+ {
+ DBUG_PRINT("info",("vp create default tgt_default_db_name"));
+ share->tgt_default_db_name_length = table->s->db.length;
+ if (
+ !(share->tgt_default_db_name = vp_create_string(
+ table->s->db.str,
+ share->tgt_default_db_name_length))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!share->tgt_table_name_prefix)
+ {
+ DBUG_PRINT("info",("vp create default tgt_table_name_prefix"));
+ share->tgt_table_name_prefix_length = 0;
+ if (
+ !(share->tgt_table_name_prefix = vp_create_string(
+ "",
+ share->tgt_table_name_prefix_length))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!share->tgt_table_name_suffix)
+ {
+ DBUG_PRINT("info",("vp create default tgt_table_name_suffix"));
+ share->tgt_table_name_suffix_length = 0;
+ if (
+ !(share->tgt_table_name_suffix = vp_create_string(
+ "",
+ share->tgt_table_name_suffix_length))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!share->tgt_table_name_list && table)
+ {
+ DBUG_PRINT("info",("vp create default tgt_table_name_list"));
+ share->tgt_table_name_list_length = share->table_name_length;
+ if (
+ !(share->tgt_table_name_list = vp_create_table_name_string(
+ table->s->table_name.str,
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ (part_elem ? part_elem->partition_name : NULL),
+ (sub_elem ? sub_elem->partition_name : NULL)
+#else
+ NULL,
+ NULL
+#endif
+ ))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!share->choose_ignore_table_list)
+ {
+ DBUG_PRINT("info",("vp create default choose_ignore_table_list"));
+ share->choose_ignore_table_list_length = 0;
+ if (
+ !(share->choose_ignore_table_list = vp_create_string(
+ "",
+ share->choose_ignore_table_list_length))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (!share->choose_ignore_table_list_for_lock)
+ {
+ DBUG_PRINT("info",("vp create default choose_ignore_table_list_for_lock"));
+ share->choose_ignore_table_list_for_lock_length = 0;
+ if (
+ !(share->choose_ignore_table_list_for_lock = vp_create_string(
+ "",
+ share->choose_ignore_table_list_for_lock_length))
+ ) {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ }
+
+ if (share->choose_table_mode == -1)
+ share->choose_table_mode = 0;
+ if (share->choose_table_mode_for_lock == -1)
+ share->choose_table_mode_for_lock = 1;
+ if (share->multi_range_mode == -1)
+ share->multi_range_mode = 1;
+ if (share->pk_correspond_mode == -1)
+ share->pk_correspond_mode = 0;
+ if (share->info_src_table == -1)
+ share->info_src_table = 0;
+ if (share->table_count_mode == -1)
+ share->table_count_mode = 0;
+ if (share->support_table_cache == -1)
+ share->support_table_cache = 1;
+ if (share->auto_increment_table == -1)
+ share->auto_increment_table = 1;
+ if (share->child_binlog == -1)
+ share->child_binlog = 0;
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (share->bgs_mode == -1)
+ share->bgs_mode = 0;
+ if (share->bgi_mode == -1)
+ share->bgi_mode = 0;
+ if (share->bgu_mode == -1)
+ share->bgu_mode = 0;
+#endif
+ if (share->zero_record_update_mode == -1)
+ share->zero_record_update_mode = 0;
+ if (share->allow_bulk_autoinc == -1)
+ share->allow_bulk_autoinc = 0;
+ if (share->allow_different_column_type == -1)
+ share->allow_different_column_type = 0;
+ DBUG_RETURN(0);
+}
+
+VP_SHARE *vp_get_share(
+ const char *table_name,
+ TABLE *table,
+ const THD *thd,
+ ha_vp *vp,
+ int *error_num
+) {
+ VP_SHARE *share;
+ uint length;
+ char *tmp_name;
+ DBUG_ENTER("vp_get_share");
+
+ length = (uint) strlen(table_name);
+ pthread_mutex_lock(&vp_tbl_mutex);
+ if (!(share = (VP_SHARE*) my_hash_search(&vp_open_tables,
+ (uchar*) table_name, length)))
+ {
+ DBUG_PRINT("info",("vp create new share"));
+ if (!(share = (VP_SHARE *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &share, sizeof(*share),
+ &tmp_name, length + 1,
+ NullS))
+ ) {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_share;
+ }
+
+ share->use_count = 0;
+ share->table_name_length = length;
+ share->table_name = tmp_name;
+ strmov(share->table_name, table_name);
+
+ if ((*error_num = vp_parse_table_info(share, table, 0)))
+ goto error_parse_comment_string;
+
+ if (
+ (*error_num = vp_create_table_list(share)) ||
+ (*error_num = vp_table_num_list_to_bitmap(share,
+ share->choose_ignore_table_list, share->select_ignore)) ||
+ (*error_num = vp_table_num_list_to_bitmap(share,
+ share->choose_ignore_table_list_for_lock,
+ share->select_ignore_with_lock))
+ )
+ goto error_create_table_list;
+
+ if (share->table_count_mode)
+ share->additional_table_flags |= HA_STATS_RECORDS_IS_EXACT;
+
+ if (share->info_src_table > share->table_count)
+ share->info_src_table = share->table_count;
+ if (share->auto_increment_table > share->table_count)
+ share->auto_increment_table = share->table_count;
+ share->auto_increment_table--;
+
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_share,
+ &share->mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_init_mutex;
+ }
+
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&share->init_mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_share_init,
+ &share->init_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_init_init_mutex;
+ }
+
+ thr_lock_init(&share->lock);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (!(share->partition_share =
+ vp_get_pt_share(table, share, error_num)))
+ goto error_get_pt_share;
+#endif
+
+ if (my_hash_insert(&vp_open_tables, (uchar*) share))
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_hash_insert;
+ }
+ }
+ share->use_count++;
+ pthread_mutex_unlock(&vp_tbl_mutex);
+
+ vp->share = share;
+
+ DBUG_PRINT("info",("vp share=%p", share));
+ DBUG_RETURN(share);
+
+error_hash_insert:
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+error_get_pt_share:
+#endif
+ thr_lock_delete(&share->lock);
+ pthread_mutex_destroy(&share->init_mutex);
+error_init_init_mutex:
+ pthread_mutex_destroy(&share->mutex);
+error_init_mutex:
+error_create_table_list:
+error_parse_comment_string:
+ vp_free_share_alloc(share);
+ vp_my_free(share, MYF(0));
+error_alloc_share:
+ pthread_mutex_unlock(&vp_tbl_mutex);
+ DBUG_RETURN(NULL);
+}
+
+int vp_free_share(
+ VP_SHARE *share
+) {
+ DBUG_ENTER("vp_free_share");
+ pthread_mutex_lock(&vp_tbl_mutex);
+ if (!--share->use_count)
+ {
+ vp_free_share_alloc(share);
+ my_hash_delete(&vp_open_tables, (uchar*) share);
+ thr_lock_delete(&share->lock);
+ pthread_mutex_destroy(&share->init_mutex);
+ pthread_mutex_destroy(&share->mutex);
+ vp_my_free(share, MYF(0));
+ }
+ pthread_mutex_unlock(&vp_tbl_mutex);
+ DBUG_RETURN(0);
+}
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+VP_PARTITION_SHARE *vp_get_pt_share(
+ TABLE *table,
+ VP_SHARE *share,
+ int *error_num
+) {
+ VP_PARTITION_SHARE *partition_share;
+ char *tmp_name;
+ DBUG_ENTER("vp_get_pt_share");
+
+ pthread_mutex_lock(&vp_pt_share_mutex);
+ if (!(partition_share = (VP_PARTITION_SHARE*) my_hash_search(
+ &vp_open_pt_share,
+ (uchar*) table->s->path.str, table->s->path.length)))
+ {
+ DBUG_PRINT("info",("vp create new pt share"));
+ if (!(partition_share = (VP_PARTITION_SHARE *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &partition_share, sizeof(*partition_share),
+ &tmp_name, table->s->path.length + 1,
+ NullS))
+ ) {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc_share;
+ }
+
+ partition_share->use_count = 0;
+ partition_share->table_name_length = table->s->path.length;
+ partition_share->table_name = tmp_name;
+ memcpy(partition_share->table_name, table->s->path.str,
+ partition_share->table_name_length);
+
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&partition_share->pt_handler_mutex,
+ MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_pt_handler,
+ &partition_share->pt_handler_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_init_pt_handler_mutex;
+ }
+
+ if(
+ my_hash_init(&partition_share->pt_handler_hash, system_charset_info,
+ 32, 0, 0, (my_hash_get_key) vp_pt_handler_share_get_key, 0, 0)
+ ) {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_init_pt_handler_hash;
+ }
+
+ if (my_hash_insert(&vp_open_pt_share, (uchar*) partition_share))
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_hash_insert;
+ }
+ }
+ partition_share->use_count++;
+ pthread_mutex_unlock(&vp_pt_share_mutex);
+
+ DBUG_PRINT("info",("vp partition_share=%p", partition_share));
+ DBUG_RETURN(partition_share);
+
+error_hash_insert:
+ my_hash_free(&partition_share->pt_handler_hash);
+error_init_pt_handler_hash:
+ pthread_mutex_destroy(&partition_share->pt_handler_mutex);
+error_init_pt_handler_mutex:
+ vp_my_free(partition_share, MYF(0));
+error_alloc_share:
+ pthread_mutex_unlock(&vp_pt_share_mutex);
+ DBUG_RETURN(NULL);
+}
+
+int vp_free_pt_share(
+ VP_PARTITION_SHARE *partition_share
+) {
+ DBUG_ENTER("vp_free_pt_share");
+ pthread_mutex_lock(&vp_pt_share_mutex);
+ if (!--partition_share->use_count)
+ {
+ my_hash_delete(&vp_open_pt_share, (uchar*) partition_share);
+ my_hash_free(&partition_share->pt_handler_hash);
+ pthread_mutex_destroy(&partition_share->pt_handler_mutex);
+ vp_my_free(partition_share, MYF(0));
+ }
+ pthread_mutex_unlock(&vp_pt_share_mutex);
+ DBUG_RETURN(0);
+}
+#endif
+
+bool vp_flush_logs(
+ handlerton *hton
+) {
+ DBUG_ENTER("vp_flush_logs");
+ DBUG_RETURN(FALSE);
+}
+
+handler* vp_create_handler(
+ handlerton *hton,
+ TABLE_SHARE *table,
+ MEM_ROOT *mem_root
+) {
+ DBUG_ENTER("vp_create_handler");
+ DBUG_RETURN(new (mem_root) ha_vp(hton, table));
+}
+
+int vp_close_connection(
+ handlerton* hton,
+ THD* thd
+) {
+ DBUG_ENTER("vp_close_connection");
+ DBUG_RETURN(0);
+}
+
+void vp_drop_database(
+ handlerton *hton,
+ char* path
+) {
+ DBUG_ENTER("vp_drop_database");
+ DBUG_VOID_RETURN;
+}
+
+bool vp_show_status(
+ handlerton *hton,
+ THD *thd,
+ stat_print_fn *stat_print,
+ enum ha_stat_type stat_type
+) {
+ DBUG_ENTER("vp_show_status");
+ switch (stat_type) {
+ case HA_ENGINE_STATUS:
+ default:
+ DBUG_RETURN(FALSE);
+ }
+}
+
+int vp_start_consistent_snapshot(
+ handlerton *hton,
+ THD* thd
+) {
+ DBUG_ENTER("vp_start_consistent_snapshot");
+ DBUG_RETURN(0);
+}
+
+int vp_commit(
+ handlerton *hton,
+ THD *thd,
+ bool all
+) {
+ DBUG_ENTER("vp_commit");
+ DBUG_RETURN(0);
+}
+
+int vp_rollback(
+ handlerton *hton,
+ THD *thd,
+ bool all
+) {
+ DBUG_ENTER("vp_rollback");
+ DBUG_RETURN(0);
+}
+
+int vp_xa_prepare(
+ handlerton *hton,
+ THD* thd,
+ bool all
+) {
+ DBUG_ENTER("vp_xa_prepare");
+ DBUG_RETURN(0);
+}
+
+int vp_xa_recover(
+ handlerton *hton,
+ XID* xid_list,
+ uint len
+) {
+ DBUG_ENTER("vp_xa_recover");
+ DBUG_RETURN(0);
+}
+
+int vp_xa_commit_by_xid(
+ handlerton *hton,
+ XID* xid
+) {
+ DBUG_ENTER("vp_xa_commit_by_xid");
+ DBUG_RETURN(0);
+}
+
+int vp_xa_rollback_by_xid(
+ handlerton *hton,
+ XID* xid
+) {
+ DBUG_ENTER("vp_xa_rollback_by_xid");
+ DBUG_RETURN(0);
+}
+
+int vp_db_done(
+ void *p
+) {
+ DBUG_ENTER("vp_db_done");
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ my_hash_free(&vp_open_pt_share);
+#endif
+ my_hash_free(&vp_open_tables);
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ pthread_mutex_destroy(&vp_pt_share_mutex);
+#endif
+ pthread_mutex_destroy(&vp_tbl_mutex);
+#ifndef WITHOUT_VP_BG_ACCESS
+ pthread_attr_destroy(&vp_pt_attr);
+#endif
+ DBUG_RETURN(0);
+}
+
+int vp_panic(
+ handlerton *hton,
+ ha_panic_function type
+) {
+ DBUG_ENTER("vp_panic");
+ DBUG_RETURN(0);
+}
+
+int vp_db_init(
+ void *p
+) {
+ int error_num;
+ handlerton *vp_hton = (handlerton *)p;
+ DBUG_ENTER("vp_db_init");
+ vp_hton_ptr = vp_hton;
+
+ vp_hton->state = SHOW_OPTION_YES;
+#ifdef PARTITION_HAS_EXTRA_ATTACH_CHILDREN
+ vp_hton->flags = HTON_NO_FLAGS;
+#else
+ vp_hton->flags = HTON_NO_PARTITION;
+#endif
+#ifdef HTON_CAN_MERGE
+ vp_hton->flags |= HTON_CAN_MERGE;
+#endif
+#ifdef HTON_CAN_MULTISTEP_MERGE
+ vp_hton->flags |= HTON_CAN_MULTISTEP_MERGE;
+#endif
+#ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION
+ vp_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION;
+#endif
+ /* vp_hton->db_type = DB_TYPE_VP; */
+ /*
+ vp_hton->savepoint_offset;
+ vp_hton->savepoint_set = vp_savepoint_set;
+ vp_hton->savepoint_rollback = vp_savepoint_rollback;
+ vp_hton->savepoint_release = vp_savepoint_release;
+ vp_hton->create_cursor_read_view = vp_create_cursor_read_view;
+ vp_hton->set_cursor_read_view = vp_set_cursor_read_view;
+ vp_hton->close_cursor_read_view = vp_close_cursor_read_view;
+ */
+ vp_hton->panic = vp_panic;
+ vp_hton->close_connection = vp_close_connection;
+ vp_hton->start_consistent_snapshot = vp_start_consistent_snapshot;
+ vp_hton->flush_logs = vp_flush_logs;
+ vp_hton->commit = vp_commit;
+ vp_hton->rollback = vp_rollback;
+ if (vp_param_support_xa())
+ {
+ vp_hton->prepare = vp_xa_prepare;
+ vp_hton->recover = vp_xa_recover;
+ vp_hton->commit_by_xid = vp_xa_commit_by_xid;
+ vp_hton->rollback_by_xid = vp_xa_rollback_by_xid;
+ }
+ vp_hton->create = vp_create_handler;
+ vp_hton->drop_database = vp_drop_database;
+ vp_hton->show_status = vp_show_status;
+
+#ifdef _WIN32
+ HMODULE current_module = GetModuleHandle(NULL);
+ vp_partition_hton_ptr = (handlerton *)
+ GetProcAddress(current_module, "?partition_hton@@3PAUhandlerton@@A");
+#ifndef VP_HAS_NEXT_THREAD_ID
+ vp_db_att_thread_id = (ulong *)
+ GetProcAddress(current_module, "?thread_id@@3KA");
+#endif
+#else
+ vp_partition_hton_ptr = partition_hton;
+#ifndef VP_HAS_NEXT_THREAD_ID
+ vp_db_att_thread_id = &thread_id;
+#endif
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+ init_vp_psi_keys();
+#endif
+
+#ifndef WITHOUT_VP_BG_ACCESS
+ if (pthread_attr_init(&vp_pt_attr))
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_pt_attr_init;
+ }
+ if (pthread_attr_setdetachstate(&vp_pt_attr, PTHREAD_CREATE_DETACHED))
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_pt_attr_setstate;
+ }
+#endif
+
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&vp_tbl_mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_tbl,
+ &vp_tbl_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_tbl_mutex_init;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+#if MYSQL_VERSION_ID < 50500
+ if (pthread_mutex_init(&vp_pt_share_mutex, MY_MUTEX_INIT_FAST))
+#else
+ if (mysql_mutex_init(vp_key_mutex_pt_share,
+ &vp_pt_share_mutex, MY_MUTEX_INIT_FAST))
+#endif
+ {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_pt_share_mutex_init;
+ }
+#endif
+
+ if(
+ my_hash_init(&vp_open_tables, system_charset_info, 32, 0, 0,
+ (my_hash_get_key) vp_tbl_get_key, 0, 0)
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_open_tables_hash_init;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if(
+ my_hash_init(&vp_open_pt_share, system_charset_info, 32, 0, 0,
+ (my_hash_get_key) vp_pt_share_get_key, 0, 0)
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_open_pt_share_hash_init;
+ }
+#endif
+
+ DBUG_RETURN(0);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+error_open_pt_share_hash_init:
+#endif
+ my_hash_free(&vp_open_tables);
+error_open_tables_hash_init:
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ pthread_mutex_destroy(&vp_pt_share_mutex);
+error_pt_share_mutex_init:
+#endif
+ pthread_mutex_destroy(&vp_tbl_mutex);
+error_tbl_mutex_init:
+#ifndef WITHOUT_VP_BG_ACCESS
+error_pt_attr_setstate:
+ pthread_attr_destroy(&vp_pt_attr);
+error_pt_attr_init:
+#endif
+ DBUG_RETURN(error_num);
+}
+
+char *vp_create_string(
+ const char *str,
+ uint length
+) {
+ char *res;
+ DBUG_ENTER("vp_create_string");
+ if (!(res = (char*) my_malloc(length + 1, MYF(MY_WME))))
+ DBUG_RETURN(NULL);
+ memcpy(res, str, length);
+ res[length] = '\0';
+ DBUG_RETURN(res);
+}
+
+char *vp_create_table_name_string(
+ const char *table_name,
+ const char *part_name,
+ const char *sub_name
+) {
+ char *res, *tmp;
+ uint length = strlen(table_name);
+ DBUG_ENTER("vp_create_table_name_string");
+ if (part_name)
+ {
+ length += sizeof("#P#") - 1 + strlen(part_name);
+ if (sub_name)
+ length += sizeof("#SP#") - 1 + strlen(sub_name);
+ }
+ if (!(res = (char*) my_malloc(length + 1, MYF(MY_WME))))
+ DBUG_RETURN(NULL);
+ tmp = strmov(res, table_name);
+ if (part_name)
+ {
+ tmp = strmov(tmp, "#P#");
+ tmp = strmov(tmp, part_name);
+ if (sub_name)
+ {
+ tmp = strmov(tmp, "#SP#");
+ tmp = strmov(tmp, sub_name);
+ }
+ }
+ DBUG_RETURN(res);
+}
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+void vp_get_partition_info(
+ const char *table_name,
+ uint table_name_length,
+ const TABLE_SHARE *table_share,
+ partition_info *part_info,
+ partition_element **part_elem,
+ partition_element **sub_elem
+) {
+ char tmp_name[FN_REFLEN + 1];
+ partition_element *tmp_part_elem = NULL, *tmp_sub_elem = NULL;
+ bool tmp_flg = FALSE, tmp_find_flg = FALSE;
+ DBUG_ENTER("vp_get_partition_info");
+ *part_elem = NULL;
+ *sub_elem = NULL;
+ if (!part_info)
+ DBUG_VOID_RETURN;
+
+ if (!memcmp(table_name + table_name_length - 5, "#TMP#", 5))
+ tmp_flg = TRUE;
+
+ DBUG_PRINT("info",("vp table_name=%s", table_name));
+ List_iterator<partition_element> part_it(part_info->partitions);
+ while ((*part_elem = part_it++))
+ {
+ if ((*part_elem)->subpartitions.elements)
+ {
+ List_iterator<partition_element> sub_it((*part_elem)->subpartitions);
+ while ((*sub_elem = sub_it++))
+ {
+ if (VP_create_subpartition_name(
+ tmp_name, FN_REFLEN + 1, table_share->path.str,
+ (*part_elem)->partition_name, (*sub_elem)->partition_name,
+ NORMAL_PART_NAME))
+ {
+ DBUG_VOID_RETURN;
+ }
+ DBUG_PRINT("info",("vp tmp_name=%s", tmp_name));
+ if (!memcmp(table_name, tmp_name, table_name_length + 1))
+ DBUG_VOID_RETURN;
+ if (
+ tmp_flg &&
+ *(tmp_name + table_name_length - 5) == '\0' &&
+ !memcmp(table_name, tmp_name, table_name_length - 5)
+ ) {
+ tmp_part_elem = *part_elem;
+ tmp_sub_elem = *sub_elem;
+ tmp_flg = FALSE;
+ tmp_find_flg = TRUE;
+ }
+ }
+ } else {
+ if (VP_create_partition_name(
+ tmp_name, FN_REFLEN + 1, table_share->path.str,
+ (*part_elem)->partition_name, NORMAL_PART_NAME, TRUE))
+ {
+ DBUG_VOID_RETURN;
+ }
+ DBUG_PRINT("info",("vp tmp_name=%s", tmp_name));
+ if (!memcmp(table_name, tmp_name, table_name_length + 1))
+ DBUG_VOID_RETURN;
+ if (
+ tmp_flg &&
+ *(tmp_name + table_name_length - 5) == '\0' &&
+ !memcmp(table_name, tmp_name, table_name_length - 5)
+ ) {
+ tmp_part_elem = *part_elem;
+ tmp_flg = FALSE;
+ tmp_find_flg = TRUE;
+ }
+ }
+ }
+ if (tmp_find_flg)
+ {
+ *part_elem = tmp_part_elem;
+ *sub_elem = tmp_sub_elem;
+ DBUG_PRINT("info",("vp tmp find"));
+ DBUG_VOID_RETURN;
+ }
+ *part_elem = NULL;
+ *sub_elem = NULL;
+ DBUG_PRINT("info",("vp no hit"));
+ DBUG_VOID_RETURN;
+}
+#endif
+
+int vp_create_table_list(
+ VP_SHARE *share
+) {
+ int table_count, roop_count, length;
+ char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *tmp_name_ptr, *tmp_path_ptr;
+ DBUG_ENTER("vp_create_table_list");
+ DBUG_PRINT("info",("vp tgt_table_name_list=%s",
+ share->tgt_table_name_list));
+ table_count = 1;
+ tmp_ptr = share->tgt_table_name_list;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ while (TRUE)
+ {
+ if ((tmp_ptr2 = strchr(tmp_ptr, ' ')))
+ {
+ table_count++;
+ tmp_ptr = tmp_ptr2 + 1;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ } else
+ break;
+ }
+ share->use_tables_size = (table_count + 7) / 8;
+ if (!(share->tgt_db_name = (char**)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &share->tgt_db_name, sizeof(char*) * table_count,
+ &share->tgt_table_name, sizeof(char*) * table_count,
+ &share->part_tables, sizeof(TABLE_LIST) * table_count,
+ &tmp_name_ptr, sizeof(char) * (
+ share->tgt_table_name_list_length +
+ share->tgt_default_db_name_length * table_count +
+ share->tgt_table_name_prefix_length * table_count +
+ share->tgt_table_name_suffix_length * table_count +
+ 2 * table_count
+ ),
+ &tmp_path_ptr, sizeof(char) * (
+ share->tgt_table_name_list_length +
+ share->tgt_default_db_name_length * table_count +
+ share->tgt_table_name_prefix_length * table_count +
+ share->tgt_table_name_suffix_length * table_count +
+ 4 * table_count
+ ),
+ &share->select_ignore,
+ sizeof(uchar) * share->use_tables_size,
+ &share->select_ignore_with_lock,
+ sizeof(uchar) * share->use_tables_size,
+ NullS))
+ )
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+
+ tmp_ptr = share->tgt_table_name_list;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ roop_count = 0;
+ while (TRUE)
+ {
+ if ((tmp_ptr2 = strchr(tmp_ptr, ' ')))
+ *tmp_ptr2 = '\0';
+
+ VP_TABLE_LIST_db_str(&share->part_tables[roop_count]) =
+ share->tgt_db_name[roop_count] = tmp_name_ptr;
+
+ if ((tmp_ptr3 = strchr(tmp_ptr, '.')))
+ {
+ /* exist database name */
+ *tmp_ptr3 = '\0';
+ length = strlen(tmp_ptr);
+ memcpy(tmp_name_ptr, tmp_ptr, length + 1);
+ tmp_name_ptr += length + 1;
+ tmp_ptr = tmp_ptr3 + 1;
+ VP_TABLE_LIST_db_length(&share->part_tables[roop_count]) = length;
+ } else {
+ memcpy(tmp_name_ptr, share->tgt_default_db_name,
+ share->tgt_default_db_name_length + 1);
+ tmp_name_ptr += share->tgt_default_db_name_length + 1;
+ VP_TABLE_LIST_db_length(&share->part_tables[roop_count]) =
+ share->tgt_default_db_name_length;
+ }
+
+ VP_TABLE_LIST_alias_str(&share->part_tables[roop_count]) =
+ VP_TABLE_LIST_table_name_str(&share->part_tables[roop_count]) =
+ share->tgt_table_name[roop_count] =
+ tmp_name_ptr;
+ memcpy(tmp_name_ptr, share->tgt_table_name_prefix,
+ share->tgt_table_name_prefix_length);
+ tmp_name_ptr += share->tgt_table_name_prefix_length;
+
+ length = strlen(tmp_ptr);
+ memcpy(tmp_name_ptr, tmp_ptr, length);
+ tmp_name_ptr += length;
+
+ memcpy(tmp_name_ptr, share->tgt_table_name_suffix,
+ share->tgt_table_name_suffix_length + 1);
+ tmp_name_ptr += share->tgt_table_name_suffix_length + 1;
+
+#ifdef VP_TABLE_LIST_ALIAS_HAS_LENGTH
+ VP_TABLE_LIST_alias_length(&share->part_tables[roop_count]) =
+#endif
+ VP_TABLE_LIST_table_name_length(&share->part_tables[roop_count]) =
+ share->tgt_table_name_prefix_length + length +
+ share->tgt_table_name_suffix_length;
+
+ DBUG_PRINT("info",("vp db=%s",
+ VP_TABLE_LIST_db_str(&share->part_tables[roop_count])));
+ DBUG_PRINT("info",("vp table_name=%s",
+ VP_TABLE_LIST_table_name_str(&share->part_tables[roop_count])));
+
+ if (!tmp_ptr2)
+ break;
+ tmp_ptr = tmp_ptr2 + 1;
+ while (*tmp_ptr == ' ')
+ tmp_ptr++;
+ roop_count++;
+ }
+ share->table_count = table_count;
+ DBUG_RETURN(0);
+}
+
+int vp_correspond_columns(
+ ha_vp *vp,
+ TABLE *table,
+ VP_SHARE *share,
+ TABLE_SHARE *table_share,
+ TABLE_LIST *part_tables,
+ bool reinit
+) {
+ int error_num, roop_count, roop_count2, roop_count3, field_count, field_idx,
+ key_count, bitmap_size;
+ uint max_count, min_count;
+ int *correspond_columns_p, *tmp_correspond_columns_p;
+ int **correspond_columns_c_ptr, *correspond_columns_c,
+ *tmp_correspond_columns_c;
+ int *correspond_pt_columns_p, *tmp_correspond_pt_columns_p;
+ int **uncorrespond_pt_columns_c_ptr, *uncorrespond_pt_columns_c,
+ *tmp_uncorrespond_pt_columns_c;
+ uchar *correspond_columns_bit, *tmp_correspond_columns_bit;
+ VP_KEY *keys, *largest_key, *tmp_keys, *tmp_keys2, *tmp_keys3;
+ uchar *keys_bit, *tmp_keys_bit;
+ VP_CORRESPOND_KEY **correspond_pk, *correspond_keys_p,
+ *tmp_correspond_keys_p, *tmp_correspond_keys_p2,
+ *tmp_correspond_keys_p3, *tmp_correspond_keys_p4, *tmp_correspond_keys_p5,
+ **correspond_keys_p_ptr;
+ uchar *correspond_keys_bit, *tmp_correspond_keys_bit;
+ bool correspond_flag, tmp_correspond_flag, different_column,
+ different_column_pos, same_all_columns;
+ uchar *need_converting, *same_columns, *need_searching,
+ *need_full_col_for_update, *pk_in_read_index, *cpy_clm_bitmap;
+ TABLE *part_table;
+ TABLE_SHARE *part_table_share = NULL;
+ Field *field, *field2, **fields;
+ KEY *key_info, *key_info2;
+ KEY_PART_INFO *key_part, *key_part2, *key_part3 = NULL;
+ handlerton *hton;
+ ulong *def_versions;
+ uint key_parts2;
+ DBUG_ENTER("vp_correspond_columns");
+ if (share->init && reinit)
+ {
+ correspond_flag = TRUE;
+ def_versions = share->def_versions;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (def_versions[roop_count] !=
+ part_tables[roop_count].table->s->get_table_def_version())
+ {
+ correspond_flag = FALSE;
+ break;
+ }
+ }
+ if (correspond_flag)
+ DBUG_RETURN(0);
+ }
+
+ pthread_mutex_lock(&share->init_mutex);
+ share->reinit = reinit;
+ if (share->init && share->reinit)
+ {
+ correspond_flag = TRUE;
+ def_versions = share->def_versions;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (def_versions[roop_count] !=
+ part_tables[roop_count].table->s->get_table_def_version())
+ {
+ correspond_flag = FALSE;
+ break;
+ }
+ }
+ if (correspond_flag)
+ share->reinit = FALSE;
+ else
+ vp_my_free(share->correspond_columns_p, MYF(0));
+ }
+
+ if (!share->init || share->reinit)
+ {
+ field_count = 0;
+ key_count = 0;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ part_table_share = part_tables[roop_count].table->s;
+ field_count += part_table_share->fields;
+ key_count += part_table_share->keys;
+ }
+
+ bitmap_size = (table_share->fields + 7) / 8;
+ if (!(correspond_columns_p = (int *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &correspond_columns_p,
+ sizeof(int) * table_share->fields * share->table_count,
+ &correspond_pt_columns_p,
+ sizeof(int) * table_share->fields * share->table_count,
+ &correspond_columns_c_ptr,
+ sizeof(int *) * share->table_count,
+ &uncorrespond_pt_columns_c_ptr,
+ sizeof(int *) * share->table_count,
+ &correspond_columns_c,
+ sizeof(int) * field_count,
+ &uncorrespond_pt_columns_c,
+ sizeof(int) * field_count,
+ &correspond_columns_bit,
+ sizeof(uchar) * bitmap_size * (share->table_count + 1),
+ &keys,
+ sizeof(VP_KEY) * table_share->keys,
+ &keys_bit,
+ sizeof(uchar) * bitmap_size * table_share->keys,
+ &correspond_pk,
+ sizeof(VP_CORRESPOND_KEY *) * share->table_count,
+ &correspond_keys_p_ptr,
+ sizeof(VP_CORRESPOND_KEY *) * share->table_count,
+ &correspond_keys_p,
+ sizeof(VP_CORRESPOND_KEY) * key_count,
+ &correspond_keys_bit,
+ sizeof(uchar) * bitmap_size * key_count,
+ &cpy_clm_bitmap, sizeof(uchar) * bitmap_size,
+ &need_converting,
+ sizeof(uchar) * share->use_tables_size,
+ &same_columns,
+ sizeof(uchar) * share->use_tables_size,
+ &need_searching,
+ sizeof(uchar) * share->use_tables_size,
+ &need_full_col_for_update,
+ sizeof(uchar) * share->use_tables_size,
+ &pk_in_read_index,
+ sizeof(uchar) * share->use_tables_size,
+ &def_versions,
+ sizeof(ulong) * share->table_count,
+ NullS))
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
+ goto error_alloc;
+ }
+
+ tmp_correspond_columns_p = correspond_columns_p;
+ for (roop_count = 0; roop_count < share->table_count;
+ roop_count++)
+ {
+ for (roop_count2 = 0; roop_count2 < (int) table_share->fields;
+ roop_count2++, tmp_correspond_columns_p++)
+ *tmp_correspond_columns_p = MAX_FIELDS;
+ }
+ same_all_columns = TRUE;
+ tmp_correspond_columns_p = correspond_columns_p;
+ tmp_correspond_pt_columns_p = correspond_pt_columns_p;
+ tmp_correspond_columns_c = correspond_columns_c;
+ tmp_uncorrespond_pt_columns_c = uncorrespond_pt_columns_c;
+ tmp_correspond_columns_bit =
+ correspond_columns_bit + bitmap_size;
+ tmp_correspond_keys_p = correspond_keys_p;
+ tmp_correspond_keys_p2 = NULL;
+ tmp_correspond_keys_bit = correspond_keys_bit;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ correspond_columns_c_ptr[roop_count] = tmp_correspond_columns_c;
+ uncorrespond_pt_columns_c_ptr[roop_count] = tmp_uncorrespond_pt_columns_c;
+ correspond_keys_p_ptr[roop_count] = tmp_correspond_keys_p;
+ part_table = part_tables[roop_count].table;
+ part_table_share = part_table->s;
+ hton = part_table_share->db_type();
+ if (hton->db_type == DB_TYPE_PARTITION_DB)
+ {
+ hton = vp_get_default_part_db_type_from_partition(part_table_share);
+ }
+ DBUG_PRINT("info",("vp part_table_share->primary_key=%u",
+ part_table_share->primary_key));
+ if (
+ hton->db_type == DB_TYPE_HEAP ||
+ hton->db_type == DB_TYPE_MYISAM ||
+ hton->db_type == DB_TYPE_MRG_MYISAM ||
+ part_table_share->primary_key == MAX_KEY
+ )
+ vp_set_bit(need_full_col_for_update, roop_count);
+
+ if (
+ part_table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX &&
+ part_table_share->primary_key != MAX_KEY
+ )
+ vp_set_bit(pk_in_read_index, roop_count);
+
+ correspond_flag = FALSE;
+ different_column = FALSE;
+ different_column_pos = FALSE;
+ DBUG_PRINT("info",("vp correspond table %s",
+ part_table_share->table_name.str));
+ for (roop_count2 = 0; roop_count2 < (int) part_table_share->fields;
+ roop_count2++)
+ {
+ if ((field = find_field_in_table_sef(table,
+ part_table_share->fieldnames.type_names[roop_count2])))
+ {
+ DBUG_PRINT("info",("vp correspond column %s",
+ part_table_share->fieldnames.type_names[roop_count2]));
+
+ field2 = part_table->field[roop_count2];
+
+ DBUG_PRINT("info",("vp field->field_index=%u",
+ field->field_index));
+ DBUG_PRINT("info",("vp field2->field_index=%u",
+ field2->field_index));
+ if (field->field_index != field2->field_index)
+ {
+ different_column_pos = TRUE;
+ }
+
+#ifdef VP_CREATE_FIELD_FIELDPTR_FIELDPTR_REQUIRES_THDPTR
+ Create_field create_field(current_thd, field2, NULL);
+#else
+ Create_field create_field(field2, NULL);
+#endif
+ if (!field->is_equal(&create_field))
+ {
+ DBUG_PRINT("info",("vp different column"));
+ different_column = TRUE;
+ }
+ if (field->type() != field2->type())
+ {
+ if (share->allow_different_column_type)
+ {
+ DBUG_PRINT("info",("vp different column type"));
+ different_column = TRUE;
+ } else {
+ error_num = ER_VP_DIFFERENT_COLUMN_TYPE_NUM;
+ my_printf_error(error_num, ER_VP_DIFFERENT_COLUMN_TYPE_STR,
+ MYF(0),
+ part_table_share->table_name.str,
+ part_table_share->fieldnames.type_names[roop_count2]);
+ goto error_table_correspond;
+ }
+ }
+ if (
+ field->charset() != field2->charset() ||
+ ((field->null_bit == 0) != (field2->null_bit == 0)) ||
+ field->pack_length() != field2->pack_length()
+ ) {
+ DBUG_PRINT("info",("vp need converting"));
+ DBUG_PRINT("info",("vp charset %p %p",
+ field->charset(), field2->charset()));
+ DBUG_PRINT("info",("vp null_bit %d %d",
+ field->null_bit, field2->null_bit));
+ DBUG_PRINT("info",("vp pack_length %u %u",
+ field->pack_length(), field2->pack_length()));
+ vp_set_bit(need_converting, roop_count);
+ }
+
+ field_idx = field->field_index;
+ /* tmp_correspond_columns_p[parent field idx] = child field idx */
+ tmp_correspond_columns_p[field_idx] = roop_count2;
+ /* tmp_correspond_columns_c[child field idx] = parent field idx */
+ tmp_correspond_columns_c[roop_count2] = field_idx;
+ vp_set_bit(tmp_correspond_columns_bit, field_idx);
+ vp_set_bit(correspond_columns_bit, field_idx);
+ correspond_flag = TRUE;
+ } else {
+ DBUG_PRINT("info",("vp uncorrespond column %s",
+ part_table_share->fieldnames.type_names[roop_count2]));
+ tmp_correspond_columns_c[roop_count2] = MAX_FIELDS;
+ DBUG_PRINT("info",("vp different column"));
+ different_column = TRUE;
+ }
+ }
+ if (!correspond_flag)
+ {
+ error_num = ER_VP_CANT_CORRESPOND_TABLE_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_TABLE_STR, MYF(0),
+ part_table_share->table_name.str);
+ goto error_table_correspond;
+ }
+ if (
+ !different_column &&
+ part_table_share->fields == table_share->fields &&
+ !different_column_pos &&
+ !vp_bit_is_set(need_converting, roop_count)
+ ) {
+ DBUG_PRINT("info",("vp same_columns %d", roop_count));
+ vp_set_bit(same_columns, roop_count);
+ } else
+ same_all_columns = FALSE;
+
+ roop_count2 = 0;
+ roop_count3 = 0;
+ fields = part_table->file->get_full_part_fields();
+ if (fields)
+ {
+ for (; *fields; ++fields)
+ {
+ field_idx = (*fields)->field_index;
+ if (tmp_correspond_columns_c[field_idx] == MAX_FIELDS)
+ {
+ tmp_uncorrespond_pt_columns_c[roop_count2] = field_idx;
+ ++roop_count2;
+ } else {
+ tmp_correspond_pt_columns_p[roop_count3] =
+ tmp_correspond_columns_c[field_idx];
+ ++roop_count3;
+ }
+ }
+ }
+ tmp_uncorrespond_pt_columns_c[roop_count2] = MAX_FIELDS;
+ tmp_correspond_pt_columns_p[roop_count3] = MAX_FIELDS;
+
+ part_table_share = part_tables[roop_count].table->s;
+ key_info = part_table_share->key_info;
+ for (roop_count2 = 0; roop_count2 < (int) part_table_share->keys;
+ roop_count2++)
+ {
+ tmp_correspond_keys_p->table_idx = roop_count;
+ tmp_correspond_keys_p->key_idx = roop_count2;
+ tmp_correspond_keys_p->columns_bit = tmp_correspond_keys_bit;
+ tmp_correspond_keys_p->next = tmp_correspond_keys_p2;
+ tmp_correspond_keys_p2 = tmp_correspond_keys_p;
+ for (
+ roop_count3 = 0, key_part = key_info[roop_count2].key_part;
+ roop_count3 <
+ (int) vp_user_defined_key_parts(&key_info[roop_count2]);
+ roop_count3++, key_part++
+ ) {
+ field_idx = tmp_correspond_columns_c[key_part->field->field_index];
+ if (field_idx < MAX_FIELDS)
+ vp_set_bit(tmp_correspond_keys_bit, field_idx);
+ }
+ if (vp_bit_is_set(pk_in_read_index, roop_count))
+ {
+ for (
+ roop_count3 = 0,
+ key_part = key_info[part_table_share->primary_key].key_part;
+ roop_count3 <
+ (int) vp_user_defined_key_parts(
+ &key_info[part_table_share->primary_key]);
+ roop_count3++, key_part++
+ ) {
+ field_idx = tmp_correspond_columns_c[key_part->field->field_index];
+ if (field_idx < MAX_FIELDS)
+ vp_set_bit(tmp_correspond_keys_bit, field_idx);
+ }
+ }
+ tmp_correspond_keys_p++;
+ tmp_correspond_keys_bit += bitmap_size;
+ }
+
+ tmp_correspond_columns_p += table_share->fields;
+ tmp_correspond_pt_columns_p += table_share->fields;
+ tmp_correspond_columns_c += part_table_share->fields;
+ tmp_uncorrespond_pt_columns_c += part_table_share->fields;
+ tmp_correspond_columns_bit += bitmap_size;
+ }
+ tmp_correspond_keys_p4 = tmp_correspond_keys_p2;
+
+ for (roop_count = 0; roop_count < (int) table_share->fields; roop_count++)
+ {
+ if (!(vp_bit_is_set(correspond_columns_bit, roop_count)))
+ {
+ error_num = ER_VP_CANT_CORRESPOND_COLUMN_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_COLUMN_STR, MYF(0),
+ table_share->fieldnames.type_names[roop_count]);
+ goto error_column_correspond;
+ }
+ }
+
+ tmp_keys_bit = keys_bit;
+ key_info = table_share->key_info;
+ for (roop_count = 0; roop_count < (int) table_share->keys;
+ roop_count++)
+ {
+ keys[roop_count].key_idx = roop_count;
+ keys[roop_count].columns_bit = tmp_keys_bit;
+ if (roop_count < (int) table_share->keys - 1)
+ {
+ keys[roop_count].key_length_next = &keys[roop_count + 1];
+ }
+ if (roop_count > 0)
+ {
+ keys[roop_count].key_length_prev = &keys[roop_count - 1];
+ }
+ for (
+ roop_count2 = 0, key_part = key_info[roop_count].key_part;
+ roop_count2 < (int) vp_user_defined_key_parts(&key_info[roop_count]);
+ roop_count2++, key_part++
+ ) {
+ field_idx = key_part->field->field_index;
+ vp_set_bit(tmp_keys_bit, field_idx);
+ }
+ tmp_keys_bit += bitmap_size;
+ }
+
+ tmp_keys = largest_key = &keys[0];
+ while (tmp_keys)
+ {
+ max_count = vp_user_defined_key_parts(&key_info[tmp_keys->key_idx]);
+ tmp_keys2 = tmp_keys->key_length_next;
+ tmp_keys3 = tmp_keys;
+ while (tmp_keys2)
+ {
+ if (max_count < vp_user_defined_key_parts(
+ &key_info[tmp_keys2->key_idx]))
+ {
+ max_count = vp_user_defined_key_parts(&key_info[tmp_keys2->key_idx]);
+ tmp_keys = tmp_keys2;
+ }
+ tmp_keys2 = tmp_keys2->key_length_next;
+ }
+ if (tmp_keys != tmp_keys3)
+ {
+ if (tmp_keys->key_length_next)
+ tmp_keys->key_length_next->key_length_prev =
+ tmp_keys->key_length_prev;
+ tmp_keys->key_length_prev->key_length_next =
+ tmp_keys->key_length_next;
+ tmp_keys->key_length_next = tmp_keys3;
+ tmp_keys->key_length_prev = tmp_keys3->key_length_prev;
+ if (tmp_keys3->key_length_prev)
+ tmp_keys3->key_length_prev->key_length_next = tmp_keys;
+ else
+ largest_key = tmp_keys;
+ tmp_keys3->key_length_prev = tmp_keys;
+ }
+ DBUG_PRINT("info",("vp key_length=%d key_id=%d",
+ vp_user_defined_key_parts(&key_info[tmp_keys->key_idx]),
+ tmp_keys->key_idx));
+ tmp_keys = tmp_keys->key_length_next;
+ }
+
+ /* correspond keys */
+ tmp_keys = largest_key;
+ tmp_correspond_keys_p = tmp_correspond_keys_p4;
+ while (tmp_keys)
+ {
+ correspond_flag = FALSE;
+ min_count = MAX_FIELDS;
+ tmp_correspond_keys_p2 = tmp_correspond_keys_p;
+ tmp_correspond_keys_p3 = NULL;
+ while (tmp_correspond_keys_p2)
+ {
+ tmp_correspond_flag = TRUE;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ if ((tmp_keys->columns_bit[roop_count] &
+ tmp_correspond_keys_p2->columns_bit[roop_count]) !=
+ tmp_keys->columns_bit[roop_count])
+ {
+ DBUG_PRINT("info",("vp uncorrespond key p1 %d and child %d-%d",
+ tmp_keys->key_idx, tmp_correspond_keys_p2->table_idx,
+ tmp_correspond_keys_p2->key_idx));
+ tmp_correspond_flag = FALSE;
+ break;
+ }
+ }
+ if (tmp_correspond_flag)
+ {
+ part_table_share =
+ part_tables[tmp_correspond_keys_p2->table_idx].table->s;
+ key_info2 = part_table_share->key_info;
+ if (
+ (key_info[tmp_keys->key_idx].flags & HA_FULLTEXT) !=
+ (key_info2[tmp_correspond_keys_p2->key_idx].flags & HA_FULLTEXT) ||
+ (key_info[tmp_keys->key_idx].flags & HA_SPATIAL) !=
+ (key_info2[tmp_correspond_keys_p2->key_idx].flags & HA_SPATIAL) ||
+ key_info[tmp_keys->key_idx].algorithm !=
+ key_info2[tmp_correspond_keys_p2->key_idx].algorithm
+ ) {
+ DBUG_PRINT("info",("vp uncorrespond key p2 %d and child %d-%d",
+ tmp_keys->key_idx, tmp_correspond_keys_p2->table_idx,
+ tmp_correspond_keys_p2->key_idx));
+ DBUG_PRINT("info",("vp flags=%lu %lu",
+ key_info[tmp_keys->key_idx].flags,
+ key_info2[tmp_correspond_keys_p2->key_idx].flags));
+ DBUG_PRINT("info",("vp algorithm=%u %u",
+ key_info[tmp_keys->key_idx].algorithm,
+ key_info2[tmp_correspond_keys_p2->key_idx].algorithm));
+ tmp_correspond_flag = FALSE;
+ } else if (
+ (key_info[tmp_keys->key_idx].flags & HA_FULLTEXT) &&
+ vp_user_defined_key_parts(&key_info[tmp_keys->key_idx]) !=
+ vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p2->key_idx])
+ ) {
+ DBUG_PRINT("info",("vp uncorrespond key p2 %d and child %d-%d",
+ tmp_keys->key_idx, tmp_correspond_keys_p2->table_idx,
+ tmp_correspond_keys_p2->key_idx));
+ DBUG_PRINT("info",("vp key_parts=%u %u",
+ vp_user_defined_key_parts(&key_info[tmp_keys->key_idx]),
+ vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p2->key_idx])));
+ tmp_correspond_flag = FALSE;
+ }
+ }
+ if (tmp_correspond_flag)
+ {
+ key_part = key_info[tmp_keys->key_idx].key_part;
+ key_part2 = key_info2[tmp_correspond_keys_p2->key_idx].key_part;
+ key_parts2 = vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p2->key_idx]);
+ if (vp_bit_is_set(pk_in_read_index,
+ tmp_correspond_keys_p2->table_idx))
+ key_part3 = key_info2[part_table_share->primary_key].key_part;
+ for (roop_count = 0;
+ roop_count < (int) vp_user_defined_key_parts(
+ &key_info[tmp_keys->key_idx]);
+ roop_count++)
+ {
+ field = key_part[roop_count].field;
+ if (roop_count < (int) key_parts2)
+ field2 = key_part2[roop_count].field;
+ else
+ field2 = key_part3[roop_count - key_parts2].field;
+ if (
+ correspond_columns_p[table_share->fields *
+ tmp_correspond_keys_p2->table_idx + field->field_index] !=
+ field2->field_index
+ ) {
+ DBUG_PRINT("info",("vp uncorrespond key p3 %d and child %d-%d",
+ tmp_keys->key_idx, tmp_correspond_keys_p2->table_idx,
+ tmp_correspond_keys_p2->key_idx));
+ tmp_correspond_flag = FALSE;
+ break;
+ }
+ }
+ }
+ if (tmp_correspond_flag)
+ {
+ DBUG_PRINT("info",("vp correspond key %d and child %d-%d",
+ tmp_keys->key_idx, tmp_correspond_keys_p2->table_idx,
+ tmp_correspond_keys_p2->key_idx));
+ if (tmp_correspond_keys_p2 == tmp_correspond_keys_p)
+ tmp_correspond_keys_p = tmp_correspond_keys_p->next;
+ else
+ tmp_correspond_keys_p3->next = tmp_correspond_keys_p2->next;
+ tmp_correspond_keys_p4 = tmp_correspond_keys_p2->next;
+ tmp_correspond_keys_p2->next = tmp_keys->correspond_key;
+ tmp_keys->correspond_key = tmp_correspond_keys_p2;
+ correspond_flag = TRUE;
+ tmp_correspond_keys_p2->key_parts =
+ vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p2->key_idx]);
+ if (min_count > tmp_correspond_keys_p2->key_parts)
+ {
+ min_count = tmp_correspond_keys_p2->key_parts;
+ tmp_correspond_keys_p2->next_shortest =
+ tmp_keys->shortest_correspond_key;
+ tmp_keys->shortest_correspond_key = tmp_correspond_keys_p2;
+ } else {
+ tmp_correspond_keys_p5 = tmp_keys->shortest_correspond_key;
+ while (TRUE)
+ {
+ if (!tmp_correspond_keys_p5->next_shortest)
+ {
+ tmp_correspond_keys_p5->next_shortest = tmp_correspond_keys_p2;
+ break;
+ }
+ if (tmp_correspond_keys_p5->next_shortest->key_parts >
+ tmp_correspond_keys_p2->key_parts)
+ {
+ tmp_correspond_keys_p2->next_shortest =
+ tmp_correspond_keys_p5->next_shortest;
+ tmp_correspond_keys_p5->next_shortest = tmp_correspond_keys_p2;
+ break;
+ }
+ tmp_correspond_keys_p5 = tmp_correspond_keys_p5->next_shortest;
+ }
+ }
+ tmp_correspond_keys_p2 = tmp_correspond_keys_p4;
+ } else {
+ tmp_correspond_keys_p3 = tmp_correspond_keys_p2;
+ tmp_correspond_keys_p2 = tmp_correspond_keys_p2->next;
+ }
+ }
+
+ if (!correspond_flag && (tmp_keys2 = tmp_keys->key_length_prev))
+ {
+ DBUG_PRINT("info",("vp check key with same columns"));
+ while (vp_user_defined_key_parts(&key_info[tmp_keys->key_idx]) ==
+ vp_user_defined_key_parts(&key_info[tmp_keys2->key_idx]))
+ {
+ tmp_correspond_flag = TRUE;
+ for (roop_count = 0; roop_count < bitmap_size; roop_count++)
+ {
+ if (tmp_keys->columns_bit[roop_count] !=
+ tmp_keys2->columns_bit[roop_count])
+ {
+ DBUG_PRINT("info",("vp uncorrespond key(same size) %d and %d",
+ tmp_keys->key_idx, tmp_keys2->key_idx));
+ tmp_correspond_flag = FALSE;
+ break;
+ }
+ }
+ if (tmp_correspond_flag)
+ {
+ DBUG_PRINT("info",("vp correspond key(same size) %d and %d",
+ tmp_keys->key_idx, tmp_keys2->key_idx));
+ tmp_keys->correspond_key = tmp_keys2->correspond_key;
+ tmp_keys->shortest_correspond_key =
+ tmp_keys2->shortest_correspond_key;
+ correspond_flag = TRUE;
+ break;
+ }
+ if (!(tmp_keys2 = tmp_keys2->key_length_prev))
+ break;
+ }
+ }
+
+ if (!correspond_flag)
+ {
+ error_num = ER_VP_CANT_CORRESPOND_KEY_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_KEY_STR, MYF(0),
+ tmp_keys->key_idx);
+ goto error_key_correspond;
+ }
+ tmp_keys = tmp_keys->key_length_next;
+ }
+
+ /* PK check */
+ DBUG_PRINT("info",("vp PK check start"));
+ if (share->pk_correspond_mode == 0)
+ {
+ tmp_correspond_keys_p = correspond_keys_p;
+ key_info = &table_share->key_info[table_share->primary_key];
+ key_part = key_info->key_part;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ DBUG_PRINT("info",("vp roop_count=%d", roop_count));
+ part_table_share = part_tables[roop_count].table->s;
+ DBUG_PRINT("info",("vp part_table_share->primary_key=%d",
+ part_table_share->primary_key));
+ DBUG_PRINT("info",("vp parent key_parts=%d",
+ vp_user_defined_key_parts(key_info)));
+ DBUG_PRINT("info",("vp child key_parts=%d",
+ vp_user_defined_key_parts(
+ &part_table_share->key_info[part_table_share->primary_key])));
+ if (
+ part_table_share->primary_key == MAX_KEY ||
+ vp_user_defined_key_parts(key_info) !=
+ vp_user_defined_key_parts(
+ &part_table_share->key_info[part_table_share->primary_key])
+ ) {
+ error_num = ER_VP_CANT_CORRESPOND_PK_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_PK_STR, MYF(0),
+ part_table_share->table_name.str);
+ goto error_key_correspond;
+ }
+ key_info2 = &part_table_share->key_info[part_table_share->primary_key];
+ key_part2 = key_info2->key_part;
+ for (roop_count2 = 0;
+ roop_count2 < (int) vp_user_defined_key_parts(key_info);
+ roop_count2++)
+ {
+ DBUG_PRINT("info",("vp roop_count2=%d", roop_count2));
+ field = key_part[roop_count2].field;
+ field2 = key_part2[roop_count2].field;
+ DBUG_PRINT("info",("vp correspond field index=%d",
+ correspond_columns_p[table_share->fields *
+ roop_count + field->field_index]));
+ DBUG_PRINT("info",("vp current field index=%d",
+ field2->field_index));
+ if (
+ correspond_columns_p[table_share->fields *
+ roop_count + field->field_index] !=
+ field2->field_index
+ ) {
+ error_num = ER_VP_CANT_CORRESPOND_PK_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_PK_STR, MYF(0),
+ part_table_share->table_name.str);
+ goto error_key_correspond;
+ }
+ }
+ correspond_pk[roop_count] =
+ &tmp_correspond_keys_p[part_table_share->primary_key];
+ tmp_correspond_keys_p += part_table_share->keys;
+ }
+ } else {
+ tmp_correspond_keys_p = keys[table_share->primary_key].correspond_key;
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (
+ !tmp_correspond_keys_p ||
+ tmp_correspond_keys_p->table_idx != roop_count
+ ) {
+ part_table_share = part_tables[roop_count].table->s;
+ error_num = ER_VP_CANT_CORRESPOND_PK_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_PK_STR, MYF(0),
+ part_table_share->table_name.str);
+ goto error_key_correspond;
+ }
+
+ key_info2 = part_tables[roop_count].table->s->key_info;
+ min_count = vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p->key_idx]);
+ correspond_pk[roop_count] = tmp_correspond_keys_p;
+ tmp_correspond_keys_p = tmp_correspond_keys_p->next;
+ while (
+ tmp_correspond_keys_p &&
+ tmp_correspond_keys_p->table_idx == roop_count
+ ) {
+ if (min_count > vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p->key_idx]))
+ {
+ min_count = vp_user_defined_key_parts(
+ &key_info2[tmp_correspond_keys_p->key_idx]);
+ correspond_pk[roop_count] = tmp_correspond_keys_p;
+ }
+ tmp_correspond_keys_p = tmp_correspond_keys_p->next;
+ }
+ }
+ }
+
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ def_versions[roop_count] =
+ part_tables[roop_count].table->s->get_table_def_version();
+
+ if (share->zero_record_update_mode)
+ {
+ for (roop_count = 0; roop_count < share->table_count; roop_count++)
+ {
+ if (vp_bit_is_set(share->select_ignore_with_lock, roop_count))
+ {
+ for (roop_count2 = 0; roop_count2 < bitmap_size; roop_count2++)
+ {
+ cpy_clm_bitmap[roop_count2] |= correspond_columns_bit[
+ (roop_count * bitmap_size) + roop_count2];
+ }
+ }
+ }
+ }
+
+ /* auto_increment column check */
+ if (table->found_next_number_field)
+ {
+ part_table = part_tables[share->auto_increment_table].table;
+ if (
+ !part_table->found_next_number_field ||
+ part_table->found_next_number_field->field_index !=
+ correspond_columns_p[table_share->fields *
+ share->auto_increment_table +
+ table->found_next_number_field->field_index]
+ ) {
+ error_num = ER_VP_CANT_CORRESPOND_AUTO_INC_NUM;
+ my_printf_error(error_num, ER_VP_CANT_CORRESPOND_AUTO_INC_STR, MYF(0),
+ part_table_share->table_name.str);
+ goto error_auto_inc_correspond;
+ }
+ }
+
+ share->bitmap_size = bitmap_size;
+ share->correspond_columns_p = correspond_columns_p;
+ share->correspond_pt_columns_p = correspond_pt_columns_p;
+ share->correspond_columns_c_ptr = correspond_columns_c_ptr;
+ share->uncorrespond_pt_columns_c_ptr = uncorrespond_pt_columns_c_ptr;
+ share->correspond_columns_bit = correspond_columns_bit + bitmap_size;
+ share->all_columns_bit = correspond_columns_bit;
+ share->keys = keys;
+ share->largest_key = largest_key;
+ share->correspond_pk = correspond_pk;
+ share->correspond_keys_p_ptr = correspond_keys_p_ptr;
+ share->cpy_clm_bitmap = cpy_clm_bitmap;
+ share->need_converting = need_converting;
+ share->same_all_columns = same_all_columns;
+ share->same_columns = same_columns;
+ share->need_searching = need_searching;
+ share->need_full_col_for_update = need_full_col_for_update;
+ share->pk_in_read_index = pk_in_read_index;
+ share->def_versions = def_versions;
+ share->init = TRUE;
+ share->reinit = FALSE;
+
+ vp->overwrite_index_bits();
+ }
+ pthread_mutex_unlock(&share->init_mutex);
+ DBUG_RETURN(0);
+
+error_auto_inc_correspond:
+error_key_correspond:
+error_column_correspond:
+error_table_correspond:
+ vp_my_free(correspond_columns_p, MYF(0));
+error_alloc:
+ pthread_mutex_unlock(&share->init_mutex);
+ DBUG_RETURN(error_num);
+}
+
+uchar vp_bit_count(
+ uchar bitmap
+) {
+ DBUG_ENTER("vp_bit_count");
+ DBUG_PRINT("info",("vp bitmap=%d", bitmap));
+ bitmap = ((bitmap & 0xaa) >> 1) + (bitmap & 0x55);
+ bitmap = ((bitmap & 0xcc) >> 2) + (bitmap & 0x33);
+ bitmap = ((bitmap & 0xf0) >> 4) + (bitmap & 0x0f);
+ DBUG_PRINT("info",("vp bitcount=%d", bitmap));
+ DBUG_RETURN(bitmap);
+}
+
+void *vp_bg_action(
+ void *arg
+) {
+ VP_BG_BASE *base = (VP_BG_BASE *) arg;
+ TABLE *table;
+ THD *thd;
+ my_thread_init();
+ DBUG_ENTER("vp_bg_action");
+ /* init start */
+ if (!(thd = VP_new_THD(next_thread_id())))
+ {
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_sync_cond);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ my_thread_end();
+ DBUG_RETURN(NULL);
+ }
+ VP_set_next_thread_id(thd);
+#ifdef HAVE_PSI_INTERFACE
+ mysql_thread_set_psi_id(thd->thread_id);
+#endif
+ thd->thread_stack = (char*) &thd;
+ thd->store_globals();
+ base->bg_thd = thd;
+ pthread_mutex_lock(&base->bg_mutex);
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_sync_cond);
+ base->bg_init = TRUE;
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ /* init end */
+
+ while (TRUE)
+ {
+ pthread_cond_wait(&base->bg_cond, &base->bg_mutex);
+ DBUG_PRINT("info",("vp bg loop start"));
+ if (base->bg_caller_sync_wait)
+ {
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_sync_cond);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ }
+ switch (base->bg_command)
+ {
+ case VP_BG_COMMAND_KILL:
+ DBUG_PRINT("info",("vp bg kill start"));
+ pthread_mutex_lock(&base->bg_sync_mutex);
+ pthread_cond_signal(&base->bg_sync_cond);
+ pthread_mutex_unlock(&base->bg_mutex);
+ pthread_mutex_unlock(&base->bg_sync_mutex);
+ delete thd;
+#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
+ my_pthread_setspecific_ptr(THR_THD, NULL);
+#endif
+ my_thread_end();
+ DBUG_RETURN(NULL);
+ case VP_BG_COMMAND_SELECT:
+ DBUG_PRINT("info",("vp bg select start"));
+ table = base->part_table->table;
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ base->bg_error = table->file->ha_index_read_map(
+ table->record[0], (const uchar *) base->table_key,
+ base->tgt_key_part_map, HA_READ_KEY_EXACT);
+#else
+ base->bg_error = table->file->index_read_map(
+ table->record[0], (const uchar *) base->table_key,
+ base->tgt_key_part_map, HA_READ_KEY_EXACT);
+#endif
+ break;
+ case VP_BG_COMMAND_INSERT:
+ DBUG_PRINT("info",("vp bg insert start"));
+ table = base->part_table->table;
+/*
+ table->next_number_field = table->found_next_number_field;
+*/
+ base->bg_error = table->file->ha_write_row(table->record[0]);
+ table->next_number_field = NULL;
+ table->auto_increment_field_not_null = FALSE;
+ break;
+ case VP_BG_COMMAND_UPDATE:
+ table = base->part_table->table;
+ base->bg_error = table->file->ha_update_row(
+ table->record[1], table->record[0]);
+ break;
+ case VP_BG_COMMAND_DELETE:
+ table = base->part_table->table;
+ base->bg_error = table->file->ha_delete_row(table->record[0]);
+ break;
+ case VP_BG_COMMAND_UPDATE_SELECT:
+ DBUG_PRINT("info",("vp bg update select start"));
+ table = base->part_table->table;
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200
+ base->bg_error = table->file->ha_index_read_idx_map(
+ table->record[0], base->key_idx, (const uchar *) base->table_key,
+ base->tgt_key_part_map, HA_READ_KEY_EXACT);
+#else
+ base->bg_error = table->file->index_read_idx_map(
+ table->record[0], base->key_idx, (const uchar *) base->table_key,
+ base->tgt_key_part_map, HA_READ_KEY_EXACT);
+#endif
+ if (!base->bg_error)
+ {
+ if (base->record_idx)
+ {
+ store_record(table, record[1]);
+ } else {
+ base->bg_error = table->file->ha_delete_row(table->record[0]);
+ }
+ }
+ break;
+ }
+ continue;
+ }
+}
+
+int vp_table_num_list_to_bitmap(
+ VP_SHARE *share,
+ char *table_num_list,
+ uchar *bitmap
+) {
+ int table_idx;
+ DBUG_ENTER("vp_table_num_list_to_bitmap");
+ while(*table_num_list)
+ {
+ while (*table_num_list == ' ')
+ table_num_list++;
+ if (*table_num_list)
+ {
+ table_idx = atoi(table_num_list);
+ if (table_idx > share->table_count || table_idx < 1)
+ {
+ my_printf_error(ER_VP_TBL_NUM_OUT_OF_RANGE_NUM,
+ ER_VP_TBL_NUM_OUT_OF_RANGE_STR, MYF(0), table_idx);
+ DBUG_RETURN(ER_VP_TBL_NUM_OUT_OF_RANGE_NUM);
+ }
+ vp_set_bit(bitmap, table_idx - 1);
+ }
+ if (!(table_num_list = strchr(table_num_list, ' ')))
+ break;
+ }
+ DBUG_RETURN(0);
+}
diff --git a/storage/vp/vp_table.h b/storage/vp/vp_table.h
new file mode 100644
index 00000000000..b68b3247e8b
--- /dev/null
+++ b/storage/vp/vp_table.h
@@ -0,0 +1,461 @@
+/* Copyright (C) 2009-2019 Kentoku Shiba
+ Copyright (C) 2019 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ Structure used to manage VP parameter string parsing. Types of
+ parameters include:
+ - connection strings
+ - UDF parameters
+
+ A parameter string consists of one or more parameter definitions using
+ the following syntax:
+ <parameter title> <parameter value>
+ A comma is the separator character between multiple parameter definitions.
+ Parameter titles must not be quoted. Parameter values must be quoted with
+ single or double quotes.
+*/
+
+typedef struct st_vp_param_string_parse
+{
+ char *start_ptr; /* Pointer to the start of the parameter string */
+ char *end_ptr; /* Pointer to the end of the parameter string */
+ char *start_title_ptr; /* Pointer to the start of the current parameter
+ title */
+ char *end_title_ptr; /* Pointer to the end of the current parameter
+ title */
+ char *start_value_ptr; /* Pointer to the start of the current parameter
+ value */
+ char *end_value_ptr; /* Pointer to the end of the current parameter
+ value */
+ int error_num; /* Error code of the error message to print when
+ an error is detected */
+ uint delim_title_len; /* Length of the paramater title's delimiter */
+ uint delim_value_len; /* Length of the paramater value's delimiter */
+ char delim_title; /* Current parameter title's delimiter character */
+ char delim_value; /* Current parameter value's delimiter character */
+
+ /**
+ Initialize the parameter string parse information.
+
+ @param param_string Pointer to the parameter string being parsed.
+ @param error_code Error code of the error message to print when
+ an error is detected.
+ */
+
+ void init(
+ char *param_string,
+ int error_code
+ );
+
+ /**
+ Initialize the current parameter title.
+ */
+
+ void init_param_title();
+
+ /**
+ Save pointers to the start and end positions of the current parameter
+ title in the parameter string. Also save the parameter title's
+ delimiter character.
+
+ @param start_value Pointer to the start position of the current
+ parameter title.
+ @param end_value Pointer to the end position of the current
+ parameter title.
+ */
+
+ void set_param_title(
+ char *start_title,
+ char *end_title
+ );
+
+ /**
+ Initialize the current parameter value.
+ */
+
+ void init_param_value();
+
+ /**
+ Save pointers to the start and end positions of the current parameter
+ value in the parameter string. Also save the parameter value's
+ delimiter character.
+
+ @param start_value Pointer to the start position of the current
+ parameter value.
+ @param end_value Pointer to the end position of the current
+ parameter value.
+ */
+
+ void set_param_value(
+ char *start_value,
+ char *end_value
+ );
+
+ /**
+ Determine whether the current parameter in the parameter string has
+ extra parameter values.
+
+ @return 0 Current parameter value in the parameter string
+ does not have extra parameter values.
+ <> 0 Error code indicating that the current parameter
+ value in the parameter string has extra
+ parameter values.
+ */
+
+ int has_extra_parameter_values();
+
+ /**
+ Restore the current parameter's input delimiter characters in the
+ parameter string. They were NULLed during parameter parsing.
+ */
+
+ void restore_delims();
+
+ /**
+ Print a parameter string error message.
+
+ @return Error code.
+ */
+
+ int print_param_error();
+
+} VP_PARAM_STRING_PARSE;
+
+#define VP_PARAM_STR_LEN(name) name ## _length
+#define VP_PARAM_STR(base_struct, title_name, param_name) \
+ if (!strncasecmp(tmp_ptr, title_name, title_length)) \
+ { \
+ DBUG_PRINT("info",("vp " title_name " start")); \
+ if (!base_struct->param_name) \
+ { \
+ if ((base_struct->param_name = vp_get_string_between_quote( \
+ start_ptr, TRUE, &param_string_parse))) \
+ base_struct->VP_PARAM_STR_LEN(param_name) = strlen(base_struct->param_name); \
+ else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ DBUG_PRINT("info",("vp " title_name "=%s", base_struct->param_name)); \
+ } \
+ break; \
+ }
+#define VP_PARAM_HINT_WITH_MAX(base_struct, title_name, param_name, check_length, max_size, min_val, max_val) \
+ if (!strncasecmp(tmp_ptr, title_name, check_length)) \
+ { \
+ DBUG_PRINT("info",("vp " title_name " start")); \
+ DBUG_PRINT("info",("vp max_size=%d", max_size)); \
+ int hint_num = atoi(tmp_ptr + check_length) - 1; \
+ DBUG_PRINT("info",("vp hint_num=%d", hint_num)); \
+ DBUG_PRINT("info",("vp " base_struct "->param_name=%x", \
+ base_struct->param_name)); \
+ if (base_struct->param_name) \
+ { \
+ if (hint_num < 0 || hint_num >= max_size) \
+ { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } else if (base_struct->param_name[hint_num] != -1) \
+ break; \
+ char *hint_str = vp_get_string_between_quote(start_ptr, FALSE); \
+ if (hint_str) \
+ { \
+ base_struct->param_name[hint_num] = atoi(hint_str); \
+ if (base_struct->param_name[hint_num] < min_val) \
+ base_struct->param_name[hint_num] = min_val; \
+ else if (base_struct->param_name[hint_num] > max_val) \
+ base_struct->param_name[hint_num] = max_val; \
+ } else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ DBUG_PRINT("info",("vp " title_name "[%d]=%d", hint_num, \
+ base_struct->param_name[hint_num])); \
+ } else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ break; \
+ }
+#define VP_PARAM_INT_WITH_MAX(base_struct, title_name, param_name, min_val, max_val) \
+ if (!strncasecmp(tmp_ptr, title_name, title_length)) \
+ { \
+ DBUG_PRINT("info",("vp " title_name " start")); \
+ if (base_struct->param_name == -1) \
+ { \
+ if ((tmp_ptr2 = vp_get_string_between_quote( \
+ start_ptr, FALSE))) \
+ { \
+ base_struct->param_name = atoi(tmp_ptr2); \
+ if (base_struct->param_name < min_val) \
+ base_struct->param_name = min_val; \
+ else if (base_struct->param_name > max_val) \
+ base_struct->param_name = max_val; \
+ param_string_parse.set_param_value(tmp_ptr2, \
+ tmp_ptr2 + \
+ strlen(tmp_ptr2) + 1); \
+ } else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ DBUG_PRINT("info",("vp " title_name "=%d", base_struct->param_name)); \
+ } \
+ break; \
+ }
+#define VP_PARAM_INT(base_struct, title_name, param_name, min_val) \
+ if (!strncasecmp(tmp_ptr, title_name, title_length)) \
+ { \
+ DBUG_PRINT("info",("vp " title_name " start")); \
+ if (base_struct->param_name == -1) \
+ { \
+ if ((tmp_ptr2 = vp_get_string_between_quote( \
+ start_ptr, FALSE))) \
+ { \
+ base_struct->param_name = atoi(tmp_ptr2); \
+ if (base_struct->param_name < min_val) \
+ base_struct->param_name = min_val; \
+ param_string_parse.set_param_value(tmp_ptr2, \
+ tmp_ptr2 + \
+ strlen(tmp_ptr2) + 1); \
+ } else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ DBUG_PRINT("info",("vp " title_name "=%d", base_struct->param_name)); \
+ } \
+ break; \
+ }
+#define VP_PARAM_LONGLONG(base_struct, title_name, param_name, min_val) \
+ if (!strncasecmp(tmp_ptr, title_name, title_length)) \
+ { \
+ DBUG_PRINT("info",("vp " title_name " start")); \
+ if (base_struct->param_name == -1) \
+ { \
+ if ((tmp_ptr2 = vp_get_string_between_quote( \
+ start_ptr, FALSE))) \
+ { \
+ base_struct->param_name = \
+ my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \
+ if (base_struct->param_name < min_val) \
+ base_struct->param_name = min_val; \
+ param_string_parse.set_param_value(tmp_ptr2, \
+ tmp_ptr2 + \
+ strlen(tmp_ptr2) + 1); \
+ } else { \
+ error_num = param_string_parse.print_param_error(); \
+ goto error; \
+ } \
+ DBUG_PRINT("info",("vp " title_name "=%lld", \
+ base_struct->param_name)); \
+ } \
+ break; \
+ }
+
+uchar *vp_tbl_get_key(
+ VP_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+uchar *vp_pt_share_get_key(
+ VP_PARTITION_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+);
+
+uchar *vp_pt_handler_share_get_key(
+ VP_PARTITION_HANDLER_SHARE *share,
+ size_t *length,
+ my_bool not_used __attribute__ ((unused))
+);
+#endif
+
+int vp_free_share_alloc(
+ VP_SHARE *share
+);
+
+char *vp_get_string_between_quote(
+ char *ptr,
+ bool alloc,
+ VP_PARAM_STRING_PARSE *param_string_parse = NULL
+);
+
+int vp_parse_table_info(
+ VP_SHARE *share,
+ TABLE *table,
+ uint create_table
+);
+
+int vp_set_table_info_default(
+ VP_SHARE *share,
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ partition_element *part_elem,
+ partition_element *sub_elem,
+#endif
+ TABLE *table
+);
+
+VP_SHARE *vp_get_share(
+ const char *table_name,
+ TABLE *table,
+ const THD *thd,
+ ha_vp *vp,
+ int *error_num
+);
+
+int vp_free_share(
+ VP_SHARE *vp
+);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+VP_PARTITION_SHARE *vp_get_pt_share(
+ TABLE *table,
+ VP_SHARE *share,
+ int *error_num
+);
+
+int vp_free_pt_share(
+ VP_PARTITION_SHARE *partition_share
+);
+#endif
+
+bool vp_flush_logs(
+ handlerton *hton
+);
+
+handler* vp_create_handler(
+ handlerton *hton,
+ TABLE_SHARE *table,
+ MEM_ROOT *mem_root
+);
+
+int vp_close_connection(
+ handlerton* hton,
+ THD* thd
+);
+
+void vp_drop_database(
+ handlerton *hton,
+ char* path
+);
+
+bool vp_show_status(
+ handlerton *hton,
+ THD *thd,
+ stat_print_fn *stat_print,
+ enum ha_stat_type stat_type
+);
+
+int vp_start_consistent_snapshot(
+ handlerton *hton,
+ THD* thd
+);
+
+int vp_commit(
+ handlerton *hton,
+ THD *thd,
+ bool all
+);
+
+int vp_rollback(
+ handlerton *hton,
+ THD *thd,
+ bool all
+);
+
+int vp_xa_prepare(
+ handlerton *hton,
+ THD* thd,
+ bool all
+);
+
+int vp_xa_recover(
+ handlerton *hton,
+ XID* xid_list,
+ uint len
+);
+
+int vp_xa_commit_by_xid(
+ handlerton *hton,
+ XID* xid
+);
+
+int vp_xa_rollback_by_xid(
+ handlerton *hton,
+ XID* xid
+);
+
+int vp_db_done(
+ void *p
+);
+
+int vp_panic(
+ handlerton *hton,
+ ha_panic_function type
+);
+
+int vp_db_init(
+ void *p
+);
+
+char *vp_create_string(
+ const char *str,
+ uint length
+);
+
+char *vp_create_table_name_string(
+ const char *table_name,
+ const char *part_name,
+ const char *sub_name
+);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+void vp_get_partition_info(
+ const char *table_name,
+ uint table_name_length,
+ const TABLE_SHARE *table_share,
+ partition_info *part_info,
+ partition_element **part_elem,
+ partition_element **sub_elem
+);
+#endif
+
+int vp_create_table_list(
+ VP_SHARE *share
+);
+
+int vp_correspond_columns(
+ ha_vp *vp,
+ TABLE *table,
+ VP_SHARE *share,
+ TABLE_SHARE *table_share,
+ TABLE_LIST *part_tables,
+ bool reinit
+);
+
+uchar vp_bit_count(
+ uchar bitmap
+);
+
+void *vp_bg_action(
+ void *arg
+);
+
+int vp_table_num_list_to_bitmap(
+ VP_SHARE *share,
+ char *table_num_list,
+ uchar *bitmap
+);
diff --git a/storage/vp/vp_udf.cc b/storage/vp/vp_udf.cc
new file mode 100644
index 00000000000..102b3764bea
--- /dev/null
+++ b/storage/vp/vp_udf.cc
@@ -0,0 +1,44 @@
+/* Copyright (C) 2009-2014 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MYSQL_SERVER 1
+#include <my_global.h>
+#include "mysql.h"
+#include "vp_udf.h"
+
+extern "C" {
+long long vp_copy_tables(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *is_null,
+ char *error
+) {
+ return vp_copy_tables_body(initid, args, is_null, error);
+}
+
+my_bool vp_copy_tables_init(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *message
+) {
+ return vp_copy_tables_init_body(initid, args, message);
+}
+
+void vp_copy_tables_deinit(
+ UDF_INIT *initid
+) {
+ vp_copy_tables_deinit_body(initid);
+}
+}
diff --git a/storage/vp/vp_udf.def b/storage/vp/vp_udf.def
new file mode 100644
index 00000000000..f23d51c6ef6
--- /dev/null
+++ b/storage/vp/vp_udf.def
@@ -0,0 +1,6 @@
+LIBRARY ha_vp
+VERSION 1.0
+EXPORTS
+ vp_copy_tables
+ vp_copy_tables_init
+ vp_copy_tables_deinit
diff --git a/storage/vp/vp_udf.h b/storage/vp/vp_udf.h
new file mode 100644
index 00000000000..94947a99856
--- /dev/null
+++ b/storage/vp/vp_udf.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2009-2014 Kentoku Shiba
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+long long vp_copy_tables_body(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *is_null,
+ char *error
+);
+
+my_bool vp_copy_tables_init_body(
+ UDF_INIT *initid,
+ UDF_ARGS *args,
+ char *message
+);
+
+void vp_copy_tables_deinit_body(
+ UDF_INIT *initid
+);