From d1dc70675c000fc5c6b38ce4456fd2faf56abaf0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 4 Sep 2024 10:10:04 +1000 Subject: [PATCH 01/54] MDEV-34864 SHOW INDEX FROM - SEQ_IN_INDEX to ULong MySQL-Connector-Net casts SEQ_IN_INDEX to uint and will raise an exception if the type is a System.Int64. As we don't support a huge number of multi-columns in an index reducing to a uint is sufficient to represent all values and maintain compatibility with MySQL-Connector-Net. This matches the type (uint) returned by MySQL-8.3 and 8.0. Reviewer: Alexander Barkov --- mysql-test/main/show_check.result | 6 +++--- mysql-test/suite/funcs_1/r/is_columns_is.result | 4 ++-- mysql-test/suite/funcs_1/r/is_columns_is_embedded.result | 4 ++-- mysql-test/suite/funcs_1/r/is_statistics.result | 6 +++--- sql/sql_show.cc | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mysql-test/main/show_check.result b/mysql-test/main/show_check.result index 7c0a3251e45..ecbaa8af774 100644 --- a/mysql-test/main/show_check.result +++ b/mysql-test/main/show_check.result @@ -66,7 +66,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 8 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 8 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 1 N 4097 0 8 def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 8 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 @@ -650,7 +650,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 64 2 N 4097 0 63 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 64 7 N 4097 0 63 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 64 6 N 4097 0 63 def information_schema STATISTICS STATISTICS COLLATION Collation 253 1 1 Y 4096 0 63 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 @@ -920,7 +920,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def information_schema STATISTICS STATISTICS TABLE_NAME Table 253 192 2 N 4097 0 33 def information_schema STATISTICS STATISTICS NON_UNIQUE Non_unique 8 1 1 N 36865 0 63 def information_schema STATISTICS STATISTICS INDEX_NAME Key_name 253 192 7 N 4097 0 33 -def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 36865 0 63 +def information_schema STATISTICS STATISTICS SEQ_IN_INDEX Seq_in_index 3 2 1 N 36897 0 63 def information_schema STATISTICS STATISTICS COLUMN_NAME Column_name 253 192 1 N 4097 0 33 def information_schema STATISTICS STATISTICS COLLATION Collation 253 3 1 Y 4096 0 33 def information_schema STATISTICS STATISTICS CARDINALITY Cardinality 8 21 1 Y 36864 0 63 diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 0758acc66a9..4f739e054ba 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -356,7 +356,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) select NEVER NULL def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select NEVER NULL def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select NEVER NULL -def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) select NEVER NULL +def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned select NEVER NULL def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select NEVER NULL def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select NEVER NULL def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL @@ -898,7 +898,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1) 3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) -NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2) +NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned 3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8 utf8_general_ci varchar(1) NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index a759b66d106..da9e42d6e09 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -356,7 +356,7 @@ def information_schema STATISTICS INDEX_TYPE 14 NULL NO varchar 16 48 NULL NULL def information_schema STATISTICS NON_UNIQUE 4 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) NEVER NULL def information_schema STATISTICS NULLABLE 13 NULL NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) NEVER NULL def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) NEVER NULL -def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) NEVER NULL +def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(2) unsigned NEVER NULL def information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) NEVER NULL def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) NEVER NULL def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL @@ -898,7 +898,7 @@ NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) NULL information_schema STATISTICS NON_UNIQUE bigint NULL NULL NULL NULL bigint(1) 3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) -NULL information_schema STATISTICS SEQ_IN_INDEX bigint NULL NULL NULL NULL bigint(2) +NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(2) unsigned 3.0000 information_schema STATISTICS COLUMN_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS COLLATION varchar 1 3 utf8 utf8_general_ci varchar(1) NULL information_schema STATISTICS CARDINALITY bigint NULL NULL NULL NULL bigint(21) diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result index 3d5ed9c3674..ae1b7db30bb 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics.result +++ b/mysql-test/suite/funcs_1/r/is_statistics.result @@ -34,7 +34,7 @@ TABLE_NAME varchar(64) NO NULL NON_UNIQUE bigint(1) NO NULL INDEX_SCHEMA varchar(64) NO NULL INDEX_NAME varchar(64) NO NULL -SEQ_IN_INDEX bigint(2) NO NULL +SEQ_IN_INDEX int(2) unsigned NO NULL COLUMN_NAME varchar(64) NO NULL COLLATION varchar(1) YES NULL CARDINALITY bigint(21) YES NULL @@ -53,7 +53,7 @@ STATISTICS CREATE TEMPORARY TABLE `STATISTICS` ( `NON_UNIQUE` bigint(1) NOT NULL, `INDEX_SCHEMA` varchar(64) NOT NULL, `INDEX_NAME` varchar(64) NOT NULL, - `SEQ_IN_INDEX` bigint(2) NOT NULL, + `SEQ_IN_INDEX` int(2) unsigned NOT NULL, `COLUMN_NAME` varchar(64) NOT NULL, `COLLATION` varchar(1), `CARDINALITY` bigint(21), @@ -72,7 +72,7 @@ TABLE_NAME varchar(64) NO NULL NON_UNIQUE bigint(1) NO NULL INDEX_SCHEMA varchar(64) NO NULL INDEX_NAME varchar(64) NO NULL -SEQ_IN_INDEX bigint(2) NO NULL +SEQ_IN_INDEX int(2) unsigned NO NULL COLUMN_NAME varchar(64) NO NULL COLLATION varchar(1) YES NULL CARDINALITY bigint(21) YES NULL diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ed32d298d19..9057ff8712f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9392,7 +9392,7 @@ ST_FIELD_INFO stat_fields_info[]= Column("NON_UNIQUE", SLonglong(1),NOT_NULL, "Non_unique", OPEN_FRM_ONLY), Column("INDEX_SCHEMA", Name(), NOT_NULL, OPEN_FRM_ONLY), Column("INDEX_NAME", Name(), NOT_NULL, "Key_name", OPEN_FRM_ONLY), - Column("SEQ_IN_INDEX", SLonglong(2),NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY), + Column("SEQ_IN_INDEX", ULong(2), NOT_NULL, "Seq_in_index",OPEN_FRM_ONLY), Column("COLUMN_NAME", Name(), NOT_NULL, "Column_name", OPEN_FRM_ONLY), Column("COLLATION", Varchar(1), NULLABLE, "Collation", OPEN_FULL_TABLE), Column("CARDINALITY", SLonglong(), NULLABLE, "Cardinality", OPEN_FULL_TABLE), From c991efd9c35eb3f2a90b2562071860a10a4cbaa2 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Aug 2024 13:34:53 +1000 Subject: [PATCH 02/54] MDEV-34825 FreeBSD fails to build under clang natively clang doesn't have /usr/local/lib in the path. As such there are various depedency linkages that will fail. For example pcre and libfmt.` --- cmake/os/FreeBSD.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake index e1c764692bc..9eccdd90c34 100644 --- a/cmake/os/FreeBSD.cmake +++ b/cmake/os/FreeBSD.cmake @@ -28,3 +28,6 @@ SET(EXECINFO_ROOT /usr/local CACHE INTERNAL "Where to find execinfo library and INCLUDE_DIRECTORIES(${EXECINFO_ROOT}/include) SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${EXECINFO_ROOT}/include) SET(ENV{LIB} "$ENV{LIB}:${EXECINFO_ROOT}/lib") + +# For all userspace dependencies +LINK_DIRECTORIES(/usr/local/lib) From 2e23c7342ff724b6eb82fd020e0bcdf312ae3209 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Aug 2024 14:32:37 +1000 Subject: [PATCH 03/54] MDEV-34567 unit.my_apc always failing on FreeBSD-14 Without the call to my_mutex_init, the mutex attributes my_fast_mutexattr and my_errorcheck_mutexattr are uninitialized. Linux tolerates this but FreeBSD doesn't (and segfaults). We fix for all since the unit text should be testing the standard mutexes of the system. --- unittest/sql/my_apc-t.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/unittest/sql/my_apc-t.cc b/unittest/sql/my_apc-t.cc index f1a28225f41..8fb9181377a 100644 --- a/unittest/sql/my_apc-t.cc +++ b/unittest/sql/my_apc-t.cc @@ -190,6 +190,7 @@ int main(int args, char **argv) pthread_t request_thr[N_THREADS]; int i; + my_mutex_init(); my_thread_global_init(); mysql_mutex_init(0, &apc_counters_mutex, MY_MUTEX_INIT_FAST); From b2ebe1cb7bde32945af67512a76ef7d980f8d1a2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 12 Jan 2024 16:57:37 +0100 Subject: [PATCH 04/54] MDEV-33091 pcre2 headers aren't found on Solaris use pkg-config to find pcre2, if possible rename PCRE_INCLUDES to use PKG_CHECK_MODULES naming, PCRE_INCLUDE_DIRS --- client/CMakeLists.txt | 2 +- cmake/pcre.cmake | 34 +++++++++++++--------- cmake/plugin.cmake | 2 +- extra/mariabackup/CMakeLists.txt | 2 +- libmysqld/CMakeLists.txt | 2 +- libmysqld/examples/CMakeLists.txt | 2 +- plugin/feedback/CMakeLists.txt | 2 +- plugin/qc_info/CMakeLists.txt | 2 +- sql/CMakeLists.txt | 2 +- storage/perfschema/CMakeLists.txt | 2 +- storage/perfschema/unittest/CMakeLists.txt | 2 +- unittest/embedded/CMakeLists.txt | 2 +- 12 files changed, 32 insertions(+), 24 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 3ad788f8023..a8e80bc8b5b 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/mysys_ssl ${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 89f928f684a..4873051170e 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -1,4 +1,3 @@ -INCLUDE (CheckCSourceRuns) INCLUDE (ExternalProject) SET(WITH_PCRE "auto" CACHE STRING @@ -6,7 +5,8 @@ SET(WITH_PCRE "auto" CACHE STRING MACRO(BUNDLE_PCRE2) SET(dir "${CMAKE_BINARY_DIR}/extra/pcre2") - SET(PCRE_INCLUDES ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + SET(PCRE_INCLUDE_DIRS ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + MESSAGE(STATUS "Will download and bundle pcre2") SET(byproducts) FOREACH(lib pcre2-posix pcre2-8) ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL) @@ -76,18 +76,26 @@ SET_TARGET_PROPERTIES(pcre2 PROPERTIES EXCLUDE_FROM_ALL TRUE) ENDMACRO() MACRO (CHECK_PCRE) - IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") - CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2) - ENDIF() - IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled") - IF (WITH_PCRE STREQUAL "system") - MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + IF (NOT TARGET pcre2 AND NOT PCRE_FOUND) + IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") + FIND_PACKAGE(PkgConfig QUIET) + PKG_CHECK_MODULES(PCRE libpcre2-8) + # in case pkg-config or libpcre2-8.pc is not installed: + IF(NOT PCRE_FOUND) + UNSET(PCRE_FOUND CACHE) + CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" PCRE_FOUND) + ENDIF() ENDIF() - BUNDLE_PCRE2() - ELSE() - CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) - IF(NEEDS_PCRE2_DEBIAN_HACK) - SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + IF(NOT PCRE_FOUND OR WITH_PCRE STREQUAL "bundled") + IF (WITH_PCRE STREQUAL "system") + MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + ENDIF() + BUNDLE_PCRE2() + ELSE() + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) + IF(NEEDS_PCRE2_DEBIAN_HACK) + SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + ENDIF() ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 7fd3b6294b9..378fc5f5f1c 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -44,7 +44,7 @@ MACRO(MYSQL_ADD_PLUGIN) # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index 6a83ba0238a..8fcc8b2af54 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES( ) IF(NOT HAVE_SYSTEM_REGEX) - INCLUDE_DIRECTORIES(${PCRE_INCLUDES}) + INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS}) ADD_DEFINITIONS(${PCRE2_DEBIAN_HACK}) ENDIF() diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 44115b5c1fc..854c30d33ce 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -23,7 +23,7 @@ ${CMAKE_SOURCE_DIR}/libmysqld ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/tpool ${CMAKE_BINARY_DIR}/sql -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${SSL_INTERNAL_INCLUDE_DIRS} diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 2a10def8e2e..d6646a128ca 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} ) diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt index 2103250e5a6..fc35cbadc31 100644 --- a/plugin/feedback/CMakeLists.txt +++ b/plugin/feedback/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc diff --git a/plugin/qc_info/CMakeLists.txt b/plugin/qc_info/CMakeLists.txt index b8c5f926cff..329f49c1fc9 100644 --- a/plugin/qc_info/CMakeLists.txt +++ b/plugin/qc_info/CMakeLists.txt @@ -1,4 +1,4 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES}) + ${PCRE_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(QUERY_CACHE_INFO qc_info.cc RECOMPILE_FOR_EMBEDDED) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 8d24a140865..9e735a51433 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -52,7 +52,7 @@ ENDIF() INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/sql diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt index aea4040c408..8bdba6d9c8b 100644 --- a/storage/perfschema/CMakeLists.txt +++ b/storage/perfschema/CMakeLists.txt @@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_BINARY_DIR}/sql ${CMAKE_CURRENT_BINARY_DIR} - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) ADD_DEFINITIONS(-DMYSQL_SERVER) diff --git a/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt index 2a22990f807..600795c78fc 100644 --- a/storage/perfschema/unittest/CMakeLists.txt +++ b/storage/perfschema/unittest/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/mysql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${SSL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/unittest/mytap diff --git a/unittest/embedded/CMakeLists.txt b/unittest/embedded/CMakeLists.txt index cf48550c377..428bb811de6 100644 --- a/unittest/embedded/CMakeLists.txt +++ b/unittest/embedded/CMakeLists.txt @@ -1,7 +1,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} ) From 566c22e8148433e967f3bc5b482c037b8ec44511 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 Feb 2024 11:26:36 +0100 Subject: [PATCH 05/54] pcre.cmake: always check the library with check_library_exists() even if pkg-config has it. otherwise build dependencies aren't detected. --- cmake/pcre.cmake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 4873051170e..db685c3572d 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -81,18 +81,15 @@ MACRO (CHECK_PCRE) FIND_PACKAGE(PkgConfig QUIET) PKG_CHECK_MODULES(PCRE libpcre2-8) # in case pkg-config or libpcre2-8.pc is not installed: - IF(NOT PCRE_FOUND) - UNSET(PCRE_FOUND CACHE) - CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" PCRE_FOUND) - ENDIF() + CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "${PCRE_LIBRARY_DIRS}" HAVE_PCRE2_MATCH_8) ENDIF() - IF(NOT PCRE_FOUND OR WITH_PCRE STREQUAL "bundled") + IF(NOT HAVE_PCRE2_MATCH_8 OR WITH_PCRE STREQUAL "bundled") IF (WITH_PCRE STREQUAL "system") MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") ENDIF() BUNDLE_PCRE2() ELSE() - CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "${PCRE_LIBRARY_DIRS}" NEEDS_PCRE2_DEBIAN_HACK) IF(NEEDS_PCRE2_DEBIAN_HACK) SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") ENDIF() From 7b2b03c4f27959b64618aa3ff3cd308a7d2c877c Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Wed, 28 Aug 2024 18:37:49 +1000 Subject: [PATCH 06/54] MDEV-34825 FreeBSD fails to build under clang natively Upstream the patch from: https://github.com/freebsd/freebsd-ports/blob/15d22e1c70da81aaa5751ad0d82f92e9451c4d81/databases/mariadb106-server/files/patch-mysys_crc32_crc32c.cc --- mysys/crc32/crc32c.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/crc32/crc32c.cc b/mysys/crc32/crc32c.cc index 6de7af70db7..0d65d0027d4 100644 --- a/mysys/crc32/crc32c.cc +++ b/mysys/crc32/crc32c.cc @@ -455,7 +455,7 @@ static int arch_ppc_probe(void) { return arch_ppc_crc32; } -# elif defined __FreeBSD_version && __FreeBSD_version >= 1200000 +# elif defined __FreeBSD__ # include # include # include From e9b70e59a3946b47ee0812c029221cb246675cf0 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Wed, 28 Aug 2024 18:40:52 +1000 Subject: [PATCH 07/54] MDEV-34825 FreeBSD - upstream riscv64 compatibility patch From https://github.com/freebsd/freebsd-ports/blob/15d22e1c70da81aaa5751ad0d82f92e9451c4d81/databases/mariadb106-server/files/patch-sql_mysqld.cc --- sql/mysqld.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5bc8bde3d6..d874a115bce 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -208,7 +208,7 @@ typedef fp_except fp_except_t; inline void setup_fpu() { -#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) +#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) && defined(FP_X_INV) /* We can't handle floating point exceptions with threads, so disable this on freebsd Don't fall for overflow, underflow,divide-by-zero or loss of precision. @@ -221,7 +221,7 @@ inline void setup_fpu() fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP)); #endif /* FP_X_DNML */ -#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT */ +#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT && FP_X_INV */ #ifdef HAVE_FEDISABLEEXCEPT fedisableexcept(FE_ALL_EXCEPT); From dff354e7df2fa774ce4da77202a17e2cae99ac59 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Aug 2024 18:56:55 +1000 Subject: [PATCH 08/54] MDEV-34825: my_cpu.h - non-glibc ism for POWER Taking both the FreeBSD[1] and Alpine[1] patch concepts; provide non-GLIBC definations for HMT_*. Provide FreeBSD ASM base for __ppc_get_timebase. On alternately use __builtin_ppc_get_timebase which is described on https://gcc.gnu.org/onlinedocs/gcc/Basic-PowerPC-Built-in-Functions-Available-on-all-Configurations.html an not depended on glibc/musl. [1] https://github.com/freebsd/freebsd-ports/blob/15d22e1c70da81aaa5751ad0d82f92e9451c4d81/databases/mariadb106-server/files/patch-include_my__cpu.h [2] https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/mariadb/ppc-remove-glibc-dep.patch --- include/my_cpu.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/my_cpu.h b/include/my_cpu.h index 05fa937c98d..1f562dc700c 100644 --- a/include/my_cpu.h +++ b/include/my_cpu.h @@ -24,6 +24,7 @@ */ #ifdef _ARCH_PWR8 +#ifdef __GLIBC__ #include /* Very low priority */ #define HMT_very_low() __ppc_set_ppr_very_low() @@ -37,6 +38,18 @@ #define HMT_medium_high() __ppc_set_ppr_med_high() /* High priority */ #define HMT_high() asm volatile("or 3,3,3") +#else /* GLIBC */ +#if defined(__FreeBSD__) +#include +#include +#endif +#define HMT_very_low() __asm__ volatile ("or 31,31,31") +#define HMT_low() __asm__ volatile ("or 1,1,1") +#define HMT_medium_low() __asm__ volatile ("or 6,6,6") +#define HMT_medium() __asm__ volatile ("or 2,2,2") +#define HMT_medium_high() __asm__ volatile ("or 5,5,5") +#define HMT_high() asm volatile("or 3,3,3") +#endif /* GLIBC */ #else #define HMT_very_low() #define HMT_low() @@ -81,7 +94,13 @@ static inline void MY_RELAX_CPU(void) __asm__ __volatile__ ("pause"); #endif #elif defined(_ARCH_PWR8) - __ppc_get_timebase(); +#ifdef __FreeBSD__ + uint64_t __tb; + __asm__ volatile ("mfspr %0, 268" : "=r" (__tb)); +#else + /* Changed from __ppc_get_timebase for musl compatibility */ + __builtin_ppc_get_timebase(); +#endif #elif defined __GNUC__ && (defined __arm__ || defined __aarch64__) /* Mainly, prevent the compiler from optimizing away delay loops */ #ifdef _aarch64_ From 8024b8e4c19ff08793382278b3fa36c263799d9b Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 5 Sep 2024 11:22:40 +1000 Subject: [PATCH 09/54] MDEV-33091 pcre2 headers - handle columnstore From e735cf2ed7cefb2af36f10f3cb47dfc060789df3, the PCRE_INCLUDES changed to PCRE_INCLUDE_DIRS for consistency. The columnstore module depends on the old name. Create a mapping for the columnstore submodule. 10.6+ fix for submodule is: * https://github.com/mariadb-corporation/mariadb-columnstore-engine/pull/3304 --- storage/columnstore/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 7c875251214..2b6d8b7d3a5 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -21,6 +21,7 @@ CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") return() ENDIF() + SET(PCRE_INCLUDES "${PCRE_INCLUDE_DIRS}") add_subdirectory(columnstore) IF(TARGET columnstore) From 2c3e07df473e26807f097e7a5905f004ef53e890 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 6 Sep 2024 11:34:31 +1000 Subject: [PATCH 10/54] MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1 The memory leak happened on second execution of a prepared statement that runs UPDATE statement with correlated subquery in right hand side of the SET clause. In this case, invocation of the method table->stat_records() could return the zero value that results in going into the 'if' branch that handles impossible where condition. The issue is that this condition branch missed saving of leaf tables that has to be performed as first condition optimization activity. Later the PS statement memory root is marked as read only on finishing first time execution of the prepared statement. Next time the same statement is executed it hits the assertion on attempt to allocate a memory on the PS memory root marked as read only. This memory allocation takes place by the sequence of the following invocations: Prepared_statement::execute mysql_execute_command Sql_cmd_dml::execute Sql_cmd_update::execute_inner Sql_cmd_update::update_single_table st_select_lex::save_leaf_tables List::push_back To fix the issue, add the flag SELECT_LEX::leaf_tables_saved to control whether the method SELECT_LEX::save_leaf_tables() has to be called or it has been already invoked and no more invocation required. Similar issue could take place on running the DELETE statement with the LIMIT clause in PS/SP mode. The reason of memory leak is the same as for UPDATE case and be fixed in the same way. --- mysql-test/main/ps_mem_leaks.result | 30 ++++++++++++++++++++++++++ mysql-test/main/ps_mem_leaks.test | 33 +++++++++++++++++++++++++++++ sql/sql_delete.cc | 11 ++++++++-- sql/sql_insert.cc | 4 ++-- sql/sql_lex.cc | 1 + sql/sql_lex.h | 4 ++++ sql/sql_select.cc | 4 +++- sql/sql_update.cc | 11 ++++++++-- 8 files changed, 91 insertions(+), 7 deletions(-) diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index 2ddf47a992c..309433e1eb7 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -89,3 +89,33 @@ f DEALLOCATE PREPARE stmt; DROP TABLE t1; # End of 10.4 tests +# +# MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1 +# +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); +PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +id value +1 1 +2 1 +3 NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +# Memory leak also could take place on running the DELETE statement +# with the LIMIT clause. Check it. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); +CREATE PROCEDURE p1(p1 INT) +DELETE FROM t1 LIMIT p1; +CALL p1(0); +CALL p1(1); +CALL p1(2); +# Clean up +DROP TABLE t1; +DROP PROCEDURE p1; +# End of 10.5 tests diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index dacb4ecabba..c0404687eb7 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -110,3 +110,36 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1 +--echo # +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); + +PREPARE stmt FROM 'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; + +--echo # Memory leak also could take place on running the DELETE statement +--echo # with the LIMIT clause. Check it. +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); + +CREATE PROCEDURE p1(p1 INT) + DELETE FROM t1 LIMIT p1; + +CALL p1(0); +CALL p1(1); +CALL p1(2); + +--echo # Clean up +DROP TABLE t1; +DROP PROCEDURE p1; + +--echo # End of 10.5 tests diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 99da79c599b..ea6b5e6ff66 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -530,6 +530,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, */ if (unlikely(thd->is_error())) DBUG_RETURN(TRUE); + + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd, 0); DBUG_RETURN(0); // Nothing to delete } @@ -902,10 +909,10 @@ cleanup: query_cache_invalidate3(thd, table_list, 1); } - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } delete deltempfile; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cf3ec929d09..46486e09a8b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1373,10 +1373,10 @@ values_loop_end: ::my_ok(thd, info.copied + info.deleted + updated, id, buff); } thd->abort_on_warning= 0; - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } my_free(readbuff); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2dc5d119fd5..fc39bd858f8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3023,6 +3023,7 @@ void st_select_lex::init_query() olap= UNSPECIFIED_OLAP_TYPE; having_fix_field= 0; having_fix_field_for_pushed_cond= 0; + leaf_tables_saved= false; context.select_lex= this; context.init(); cond_count= between_count= with_wild= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 0a88e92d723..e0cb336de5a 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1182,6 +1182,10 @@ public: */ bool have_merged_subqueries; + /** + Flag to guard against double initialization of leaf tables list + */ + bool leaf_tables_saved; List leaf_tables; List leaf_tables_exec; List leaf_tables_prep; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 93b53699c9a..ea690422eac 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2054,12 +2054,14 @@ JOIN::optimize_inner() /* Convert all outer joins to inner joins if possible */ conds= simplify_joins(this, join_list, conds, TRUE, FALSE); - if (thd->is_error() || select_lex->save_leaf_tables(thd)) + if (thd->is_error() || + (!select_lex->leaf_tables_saved && select_lex->save_leaf_tables(thd))) { if (arena) thd->restore_active_arena(arena, &backup); DBUG_RETURN(1); } + select_lex->leaf_tables_saved= true; build_bitmap_for_nested_joins(join_list, 0); sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index adb209b7b56..c2868d8165e 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -598,6 +598,13 @@ int mysql_update(THD *thd, { DBUG_RETURN(1); // Error in where } + + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd); // No matching records DBUG_RETURN(0); } @@ -1366,10 +1373,10 @@ update_end: } thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ thd->abort_on_warning= 0; - if (thd->lex->current_select->first_cond_optimization) + if (!thd->lex->current_select->leaf_tables_saved) { thd->lex->current_select->save_leaf_tables(thd); - thd->lex->current_select->first_cond_optimization= 0; + thd->lex->current_select->leaf_tables_saved= true; } *found_return= found; *updated_return= updated; From 00cb3440858dd8462e0a8f847ae486d363fdb2d1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 16 Aug 2024 17:04:23 +1000 Subject: [PATCH 11/54] MDEV-33858 Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON Simply adding tests as the bug is fixed with a backport of MDEV-34447 --- mysql-test/main/ps_mem_leaks.result | 9 +++++++++ mysql-test/main/ps_mem_leaks.test | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index 309433e1eb7..da7fe3a3344 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -118,4 +118,13 @@ CALL p1(2); # Clean up DROP TABLE t1; DROP PROCEDURE p1; +# +# MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON +# +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?"; +EXECUTE stmt USING 0; +EXECUTE stmt USING 1; +DROP TABLE t; # End of 10.5 tests diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index c0404687eb7..1358ef7613e 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -142,4 +142,17 @@ CALL p1(2); DROP TABLE t1; DROP PROCEDURE p1; +--echo # +--echo # MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON +--echo # + +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); # Optional, fails either way +PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?"; +EXECUTE stmt USING 0; +EXECUTE stmt USING 1; + +# CLeanup +DROP TABLE t; + --echo # End of 10.5 tests From e886c2ba02ac021c648f84aa8f910af4fb4fb4bb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 21 Aug 2024 15:47:37 +1000 Subject: [PATCH 12/54] MDEV-34757 Check leaf_tables_saved in partition pruning in UPDATE and DELETE --- mysql-test/main/ps_mem_leaks.result | 198 ++++++++++++++++++++++++++++ mysql-test/main/ps_mem_leaks.test | 168 +++++++++++++++++++++++ sql/sql_delete.cc | 6 + sql/sql_update.cc | 6 + 4 files changed, 378 insertions(+) diff --git a/mysql-test/main/ps_mem_leaks.result b/mysql-test/main/ps_mem_leaks.result index da7fe3a3344..8acfb779bc5 100644 --- a/mysql-test/main/ps_mem_leaks.result +++ b/mysql-test/main/ps_mem_leaks.result @@ -119,6 +119,204 @@ CALL p1(2); DROP TABLE t1; DROP PROCEDURE p1; # +# MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning +# +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +EXECUTE stmt; +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +EXECUTE stmt; +SELECT * FROM t1; +id value +1 10 +2 10 +3 10 +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (null,1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +select * from t1; +a +1 +2 +1 +3 +deallocate prepare stmt; +drop table t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (null,1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using buffer +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +select * from t1; +a +1 +2 +3 +4 +deallocate prepare stmt; +drop table t1, t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +execute stmt using @var1, @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +deallocate prepare stmt; +DROP TABLE t1,t2; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); +CREATE PROCEDURE p1(p1 INT) +EXPLAIN DELETE FROM t1 LIMIT p1; +CALL p1(0); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +CALL p1(1); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +CALL p1(2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +# Clean up +DROP TABLE t1; +DROP PROCEDURE p1; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +select * from t1; +a +1 +2 +3 +deallocate prepare stmt; +drop table t1, t2; +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( +partition p0 values in (1,2), +partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?'; +execute stmt using @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching rows after partition pruning +select * from t1; +a +1 +2 +3 +4 +execute stmt using @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +select * from t1; +a +1 +2 +3 +4 +deallocate prepare stmt; +drop table t1, t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +execute stmt using @var1, @var1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL 3 Deleting all rows +deallocate prepare stmt; +DROP TABLE t1,t2; +# # MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON # CREATE TABLE t (a INT); diff --git a/mysql-test/main/ps_mem_leaks.test b/mysql-test/main/ps_mem_leaks.test index 1358ef7613e..907f0eb6bba 100644 --- a/mysql-test/main/ps_mem_leaks.test +++ b/mysql-test/main/ps_mem_leaks.test @@ -5,6 +5,7 @@ # The cmake option -DWITH_PROTECT_STATEMENT_MEMROOT is used only # for debug build --source include/have_debug.inc +--source include/have_partition.inc --echo # --echo # MDEV-32369: Memory leak when executing PS for query with IN subquery @@ -142,6 +143,173 @@ CALL p1(2); DROP TABLE t1; DROP PROCEDURE p1; +--echo # +--echo # MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning +--echo # +# same as the first MDEV-34444 testcase but with explain +CREATE TABLE t1 (id INT, value INT); +CREATE TABLE t2 (id INT); + +PREPARE stmt FROM 'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)'; +# we are testing 2nd ps assertion failure, not explain output, which +# may vary from version to version +--disable_result_log +EXECUTE stmt; +--enable_result_log +INSERT INTO t1 VALUES (1,10),(2,10),(3,10); +INSERT INTO t2 VALUES (1),(2); +--disable_result_log +EXECUTE stmt; +--enable_result_log +SELECT * FROM t1; +DEALLOCATE PREPARE stmt; +DROP TABLE t1, t2; + +# 2nd ps mem leak; partition pruning +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (null,1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# same but with explain +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (null,1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# top level impossible where +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# top level impossible where, with explain +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# Now we do delete instead of update + +# same as the second MDEV-34447 testcase but with explain +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 (c1) VALUES (1), (2), (3); + +CREATE PROCEDURE p1(p1 INT) + EXPLAIN DELETE FROM t1 LIMIT p1; + +CALL p1(0); +CALL p1(1); +CALL p1(2); + +--echo # Clean up +DROP TABLE t1; +DROP PROCEDURE p1; + +# partition pruning +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# same but with explain +set @var1=5; +set @var2=4; +create table t1 (a int) partition by list(a) ( + partition p0 values in (1,2), + partition p1 values in (3,4) +); +create table t2 (a int); +insert into t1 values (1),(2),(3),(4); +insert into t2 values (4); +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 where a = ?'; +execute stmt using @var1; +select * from t1; +execute stmt using @var2; +select * from t1; +deallocate prepare stmt; +drop table t1, t2; + +# top level impossible where +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + +# top level impossible where, with explain +set @var1=1; +set @var2=2; +CREATE TABLE t1 ( id INT(10), value INT(10) ); +CREATE TABLE t2 ( id INT(10) ); +insert into t1 values (1,10),(2,10),(3,10); +insert into t2 values (1),(2); + +PREPARE stmt FROM 'EXPLAIN DELETE FROM t1 WHERE ?=?'; +execute stmt using @var1, @var2; +execute stmt using @var1, @var1; +deallocate prepare stmt; +DROP TABLE t1,t2; + --echo # --echo # MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON --echo # diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index ea6b5e6ff66..67d07c3ff44 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -500,6 +500,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (thd->lex->describe || thd->lex->analyze_stmt) goto produce_explain_and_leave; + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd, 0); DBUG_RETURN(0); } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c2868d8165e..e96af1a19bf 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -569,6 +569,12 @@ int mysql_update(THD *thd, if (thd->is_error()) DBUG_RETURN(1); + if (!thd->lex->current_select->leaf_tables_saved) + { + thd->lex->current_select->save_leaf_tables(thd); + thd->lex->current_select->leaf_tables_saved= true; + } + my_ok(thd); // No matching records DBUG_RETURN(0); } From 024a18dbcb7f9c44094db03daa013fd8ba3c58b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 6 Sep 2024 14:29:09 +0300 Subject: [PATCH 13/54] MDEV-34823 Invalid arguments in ib_push_warning() In the bug report MDEV-32817 it occurred that the function row_mysql_get_table_status() is outputting a fil_space_t* as if it were a numeric tablespace identifier. ib_push_warning(): Remove. Let us invoke push_warning_printf() directly. innodb_decryption_failed(): Report a decryption failure and set the dict_table_t::file_unreadable flag. This code was being duplicated in very many places. We return the constant value DB_DECRYPTION_FAILED in order to avoid code duplication in the callers and to allow tail calls. innodb_fk_error(): Report a FOREIGN KEY error. dict_foreign_def_get(), dict_foreign_def_get_fields(): Remove. This code was being used in dict_create_add_foreign_to_dictionary() in an apparently uncovered code path. That ib_push_warning() call would pass the integer i+1 instead of a pointer to NUL terminated string ("%s"), and therefore the call should have resulted in a crash. dict_print_info_on_foreign_key_in_create_format(), innobase_quote_identifier(): Add const qualifiers. row_mysql_get_table_error(): Replaces row_mysql_get_table_status(). Display no message on DB_CORRUPTION; it should be properly reported at the SQL layer anyway. --- .../suite/innodb/r/innodb-fk-warnings.result | 2 +- storage/innobase/btr/btr0btr.cc | 11 +- storage/innobase/btr/btr0cur.cc | 53 ++----- storage/innobase/dict/dict0crea.cc | 145 +----------------- storage/innobase/dict/dict0dict.cc | 11 +- storage/innobase/handler/ha_innodb.cc | 96 +++++------- storage/innobase/include/dict0crea.h | 10 -- storage/innobase/include/dict0dict.h | 16 +- storage/innobase/include/ha_prototypes.h | 38 +++-- storage/innobase/row/row0ins.cc | 9 +- storage/innobase/row/row0merge.cc | 10 +- storage/innobase/row/row0mysql.cc | 61 +++----- storage/innobase/row/row0sel.cc | 9 +- 13 files changed, 108 insertions(+), 363 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-fk-warnings.result b/mysql-test/suite/innodb/r/innodb-fk-warnings.result index c85dcf22c06..b58d21b0914 100644 --- a/mysql-test/suite/innodb/r/innodb-fk-warnings.result +++ b/mysql-test/suite/innodb/r/innodb-fk-warnings.result @@ -16,7 +16,7 @@ CONSTRAINT test FOREIGN KEY (b) REFERENCES t2 (id) ERROR HY000: Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update") show warnings; Level Code Message -Warning 121 Create or Alter table `test`.`t2` with foreign key constraint failed. Foreign key constraint `test`.`test` already exists on data dictionary. Foreign key constraint names need to be unique in database. Error in foreign key definition: CONSTRAINT `test` FOREIGN KEY (`b`) REFERENCES `test`.`t2` (`id`). +Warning 121 CREATE or ALTER TABLE `test`.`t2` failed: duplicate name, CONSTRAINT `test` FOREIGN KEY (`b`) REFERENCES `t2` (`id`) Error 1005 Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update") Warning 1022 Can't write; duplicate key in table 't2' drop table t1; diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index db57d31dd15..104b3511fd0 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -228,16 +228,7 @@ btr_root_block_get( mtr); if (!block) { - index->table->file_unreadable = true; - - ib_push_warning( - static_cast(NULL), DB_DECRYPTION_FAILED, - "Table %s in file %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name, - UT_LIST_GET_FIRST(index->table->space->chain)->name); - + innodb_decryption_failed(nullptr, index->table); return NULL; } diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index bfea89b1762..2cda73900f6 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1617,13 +1617,7 @@ retry_page_get: if (err != DB_SUCCESS) { ut_ad(block == NULL); if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, index->table); } goto func_exit; @@ -1729,13 +1723,8 @@ retry_page_get: if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, + index->table); } goto func_exit; @@ -1759,13 +1748,8 @@ retry_page_get: if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, + index->table); } goto func_exit; @@ -2634,13 +2618,8 @@ btr_cur_open_at_index_side_func( if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, + index->table); } goto exit_loop; @@ -2976,13 +2955,8 @@ btr_cur_open_at_rnd_pos_func( if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, + index->table); } break; @@ -6136,13 +6110,8 @@ btr_estimate_n_rows_in_range_on_level( if (!block) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning((void *)NULL, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(nullptr, + index->table); } mtr_commit(&mtr); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index f5c852bb8d0..e904c2e3e86 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1726,104 +1726,6 @@ dict_create_add_foreign_field_to_dictionary( table_name, foreign->id, trx)); } -/********************************************************************//** -Construct foreign key constraint defintion from data dictionary information. -*/ -UNIV_INTERN -char* -dict_foreign_def_get( -/*=================*/ - dict_foreign_t* foreign,/*!< in: foreign */ - trx_t* trx) /*!< in: trx */ -{ - char* fk_def = (char *)mem_heap_alloc(foreign->heap, 4*1024); - const char* tbname; - char tablebuf[MAX_TABLE_NAME_LEN + 1] = ""; - unsigned i; - char* bufend; - - tbname = dict_remove_db_name(foreign->id); - bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN, - tbname, strlen(tbname), trx->mysql_thd); - tablebuf[bufend - tablebuf] = '\0'; - - sprintf(fk_def, - (char *)"CONSTRAINT %s FOREIGN KEY (", (char *)tablebuf); - - for(i = 0; i < foreign->n_fields; i++) { - char buf[MAX_TABLE_NAME_LEN + 1] = ""; - innobase_convert_name(buf, MAX_TABLE_NAME_LEN, - foreign->foreign_col_names[i], - strlen(foreign->foreign_col_names[i]), - trx->mysql_thd); - strcat(fk_def, buf); - if (i < static_cast(foreign->n_fields-1)) { - strcat(fk_def, (char *)","); - } - } - - strcat(fk_def,(char *)") REFERENCES "); - - bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN, - foreign->referenced_table_name, - strlen(foreign->referenced_table_name), - trx->mysql_thd); - tablebuf[bufend - tablebuf] = '\0'; - - strcat(fk_def, tablebuf); - strcat(fk_def, " ("); - - for(i = 0; i < foreign->n_fields; i++) { - char buf[MAX_TABLE_NAME_LEN + 1] = ""; - bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN, - foreign->referenced_col_names[i], - strlen(foreign->referenced_col_names[i]), - trx->mysql_thd); - buf[bufend - buf] = '\0'; - strcat(fk_def, buf); - if (i < (uint)foreign->n_fields-1) { - strcat(fk_def, (char *)","); - } - } - strcat(fk_def, (char *)")"); - - return fk_def; -} - -/********************************************************************//** -Convert foreign key column names from data dictionary to SQL-layer. -*/ -static -void -dict_foreign_def_get_fields( -/*========================*/ - dict_foreign_t* foreign,/*!< in: foreign */ - trx_t* trx, /*!< in: trx */ - char** field, /*!< out: foreign column */ - char** field2, /*!< out: referenced column */ - ulint col_no) /*!< in: column number */ -{ - char* bufend; - char* fieldbuf = (char *)mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1); - char* fieldbuf2 = (char *)mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1); - - bufend = innobase_convert_name(fieldbuf, MAX_TABLE_NAME_LEN, - foreign->foreign_col_names[col_no], - strlen(foreign->foreign_col_names[col_no]), - trx->mysql_thd); - - fieldbuf[bufend - fieldbuf] = '\0'; - - bufend = innobase_convert_name(fieldbuf2, MAX_TABLE_NAME_LEN, - foreign->referenced_col_names[col_no], - strlen(foreign->referenced_col_names[col_no]), - trx->mysql_thd); - - fieldbuf2[bufend - fieldbuf2] = '\0'; - *field = fieldbuf; - *field2 = fieldbuf2; -} - /********************************************************************//** Add a foreign key definition to the data dictionary tables. @return error code or DB_SUCCESS */ @@ -1865,29 +1767,8 @@ dict_create_add_foreign_to_dictionary( , name, foreign->id, trx); if (error != DB_SUCCESS) { - - if (error == DB_DUPLICATE_KEY) { - char buf[MAX_TABLE_NAME_LEN + 1] = ""; - char tablename[MAX_TABLE_NAME_LEN + 1] = ""; - char* fk_def; - - innobase_convert_name(tablename, MAX_TABLE_NAME_LEN, - name, strlen(name), trx->mysql_thd); - - innobase_convert_name(buf, MAX_TABLE_NAME_LEN, - foreign->id, strlen(foreign->id), trx->mysql_thd); - - fk_def = dict_foreign_def_get((dict_foreign_t*)foreign, trx); - - ib_push_warning(trx, error, - "Create or Alter table %s with foreign key constraint" - " failed. Foreign key constraint %s" - " already exists on data dictionary." - " Foreign key constraint names need to be unique in database." - " Error in foreign key definition: %s.", - tablename, buf, fk_def); - } - +err_exit: + innodb_fk_error(trx, error, name, *foreign); DBUG_RETURN(error); } @@ -1896,27 +1777,7 @@ dict_create_add_foreign_to_dictionary( i, name, foreign, trx); if (error != DB_SUCCESS) { - char buf[MAX_TABLE_NAME_LEN + 1] = ""; - char tablename[MAX_TABLE_NAME_LEN + 1] = ""; - char* field=NULL; - char* field2=NULL; - char* fk_def; - - innobase_convert_name(tablename, MAX_TABLE_NAME_LEN, - name, strlen(name), trx->mysql_thd); - innobase_convert_name(buf, MAX_TABLE_NAME_LEN, - foreign->id, strlen(foreign->id), trx->mysql_thd); - fk_def = dict_foreign_def_get((dict_foreign_t*)foreign, trx); - dict_foreign_def_get_fields((dict_foreign_t*)foreign, trx, &field, &field2, i); - - ib_push_warning(trx, error, - "Create or Alter table %s with foreign key constraint" - " failed. Error adding foreign key constraint name %s" - " fields %s or %s to the dictionary." - " Error in foreign key definition: %s.", - tablename, buf, i+1, fk_def); - - DBUG_RETURN(error); + goto err_exit; } } diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index a4ddf35aba6..d44b017b32f 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -3949,15 +3949,10 @@ dict_index_calc_min_rec_len( return(sum); } -/**********************************************************************//** -Outputs info on a foreign key of a table in a format suitable for -CREATE TABLE. */ std::string -dict_print_info_on_foreign_key_in_create_format( -/*============================================*/ - trx_t* trx, /*!< in: transaction */ - dict_foreign_t* foreign, /*!< in: foreign key constraint */ - ibool add_newline) /*!< in: whether to add a newline */ +dict_print_info_on_foreign_key_in_create_format(const trx_t *trx, + const dict_foreign_t *foreign, + bool add_newline) { const char* stripped_id; ulint i; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d249cb205f4..689cf76e1ce 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2921,7 +2921,7 @@ innobase_invalidate_query_cache( void innobase_quote_identifier( FILE* file, - trx_t* trx, + const trx_t* trx, const char* id) { const int q = trx != NULL && trx->mysql_thd != NULL @@ -2951,7 +2951,7 @@ innobase_quote_identifier( std::string innobase_quote_identifier( /*======================*/ - trx_t* trx, + const trx_t* trx, const char* id) { std::string quoted_identifier; @@ -21447,66 +21447,46 @@ static void innodb_remember_check_sysvar_funcs() check_sysvar_int = MYSQL_SYSVAR_NAME(flush_log_at_timeout).check; } -static const size_t MAX_BUF_SIZE = 4 * 1024; - -/********************************************************************//** -Helper function to push warnings from InnoDB internals to SQL-layer. */ -UNIV_INTERN -void -ib_push_warning( - trx_t* trx, /*!< in: trx */ - dberr_t error, /*!< in: error code to push as warning */ - const char *format,/*!< in: warning message */ - ...) +/** Report that a table cannot be decrypted. +@param thd connection context +@param table table that cannot be decrypted +@retval DB_DECRYPTION_FAILED (always) */ +ATTRIBUTE_COLD +dberr_t innodb_decryption_failed(THD *thd, dict_table_t *table) { - if (trx && trx->mysql_thd) { - THD *thd = (THD *)trx->mysql_thd; - va_list args; - char *buf; - - va_start(args, format); - buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME)); - buf[MAX_BUF_SIZE - 1] = 0; - vsnprintf(buf, MAX_BUF_SIZE - 1, format, args); - - push_warning_printf( - thd, Sql_condition::WARN_LEVEL_WARN, - uint(convert_error_code_to_mysql(error, 0, thd)), buf); - my_free(buf); - va_end(args); - } + table->file_unreadable= true; + if (!thd) + thd= current_thd; + const int dblen= int(table->name.dblen()); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_DECRYPTION_FAILED, + "Table %`.*s.%`s in tablespace " UINT32PF + " (file %s) cannot be decrypted.", + dblen, table->name.m_name, + table->name.m_name + dblen + 1, + uint32_t(table->space_id), + UT_LIST_GET_FIRST(table->space->chain)->name); + return DB_DECRYPTION_FAILED; } -/********************************************************************//** -Helper function to push warnings from InnoDB internals to SQL-layer. */ -UNIV_INTERN -void -ib_push_warning( - void* ithd, /*!< in: thd */ - dberr_t error, /*!< in: error code to push as warning */ - const char *format,/*!< in: warning message */ - ...) +/** Report a foreign key error. +@param error error to report +@param name table name +@param foreign constraint */ +ATTRIBUTE_COLD +void innodb_fk_error(const trx_t *trx, dberr_t err, const char *name, + const dict_foreign_t& foreign) { - va_list args; - THD *thd = (THD *)ithd; - char *buf; - - if (ithd == NULL) { - thd = current_thd; - } - - if (thd) { - va_start(args, format); - buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME)); - buf[MAX_BUF_SIZE - 1] = 0; - vsnprintf(buf, MAX_BUF_SIZE - 1, format, args); - - push_warning_printf( - thd, Sql_condition::WARN_LEVEL_WARN, - uint(convert_error_code_to_mysql(error, 0, thd)), buf); - my_free(buf); - va_end(args); - } + const int dblen= int(table_name_t(const_cast(name)).dblen()); + std::string fk= dict_print_info_on_foreign_key_in_create_format + (trx, &foreign, false); + push_warning_printf(trx->mysql_thd, Sql_condition::WARN_LEVEL_WARN, + convert_error_code_to_mysql(err, 0, nullptr), + "CREATE or ALTER TABLE %`.*s.%`s failed%s%.*s", + dblen, name, name + dblen + 1, + err == DB_DUPLICATE_KEY + ? ": duplicate name" : "", + int(fk.length()), fk.data()); } /** Helper function to push warnings from InnoDB internals to SQL-layer. diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 50f7f34a8e8..c82ab7d44db 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -209,16 +209,6 @@ dict_create_add_foreign_to_dictionary( trx_t* trx) /*!< in/out: dictionary transaction */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/********************************************************************//** -Construct foreign key constraint defintion from data dictionary information. -*/ -UNIV_INTERN -char* -dict_foreign_def_get( -/*=================*/ - dict_foreign_t* foreign,/*!< in: foreign */ - trx_t* trx); /*!< in: trx */ - /* Table create node structure */ struct tab_node_t{ que_common_t common; /*!< node type: QUE_NODE_TABLE_CREATE */ diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 65b88a65185..6bfd774b941 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -577,15 +577,15 @@ dict_print_info_on_foreign_keys( trx_t* trx, /*!< in: transaction */ dict_table_t* table); /*!< in: table */ -/**********************************************************************//** -Outputs info on a foreign key of a table in a format suitable for -CREATE TABLE. */ +/** Output info on a foreign key of a table in a format suitable for +CREATE TABLE. +@param trx transaction +@param foreign constraint +@param add_newline whether to add a newline */ std::string -dict_print_info_on_foreign_key_in_create_format( -/*============================================*/ - trx_t* trx, /*!< in: transaction */ - dict_foreign_t* foreign, /*!< in: foreign key constraint */ - ibool add_newline); /*!< in: whether to add a newline */ +dict_print_info_on_foreign_key_in_create_format(const trx_t *trx, + const dict_foreign_t *foreign, + bool add_newline); /*********************************************************************//** Tries to find an index whose first fields are the columns in the array, diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 04e1ec96b73..c86e5e01c5c 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -37,6 +37,9 @@ simple headers. /* Forward declarations */ class THD; class Field; +struct dict_table_t; +struct dict_foreign_t; +struct table_name_t; // JAN: TODO missing features: #undef MYSQL_FT_INIT_EXT @@ -83,7 +86,7 @@ innobase_invalidate_query_cache( void innobase_quote_identifier( FILE* file, - trx_t* trx, + const trx_t* trx, const char* id); /** Quote an standard SQL identifier like tablespace, index or column name. @@ -93,7 +96,7 @@ Return the string as an std:string object. @return a std::string with id properly quoted. */ std::string innobase_quote_identifier( - trx_t* trx, + const trx_t* trx, const char* id); /*****************************************************************//** @@ -456,25 +459,20 @@ innobase_convert_to_filename_charset( const char* from, /* in: identifier to convert */ ulint len); /* in: length of 'to', in bytes */ -/********************************************************************//** -Helper function to push warnings from InnoDB internals to SQL-layer. */ -UNIV_INTERN -void -ib_push_warning( - trx_t* trx, /*!< in: trx */ - dberr_t error, /*!< in: error code to push as warning */ - const char *format,/*!< in: warning message */ - ...); +/** Report that a table cannot be decrypted. +@param thd connection context +@param table table that cannot be decrypted +@retval DB_DECRYPTION_FAILED (always) */ +ATTRIBUTE_COLD +dberr_t innodb_decryption_failed(THD *thd, dict_table_t *table); -/********************************************************************//** -Helper function to push warnings from InnoDB internals to SQL-layer. */ -UNIV_INTERN -void -ib_push_warning( - void* ithd, /*!< in: thd */ - dberr_t error, /*!< in: error code to push as warning */ - const char *format,/*!< in: warning message */ - ...); +/** Report a foreign key error. +@param error error to report +@param name table name +@param foreign constraint */ +ATTRIBUTE_COLD +void innodb_fk_error(const trx_t *trx, dberr_t err, const char *name, + const dict_foreign_t& foreign); /********************************************************************//** Helper function to push warnings from InnoDB internals to SQL-layer. */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 2fdd259e932..350a002f83f 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -3043,13 +3043,8 @@ row_ins_sec_index_entry_low( if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning(thr_get_trx(thr)->mysql_thd, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - index->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(thr_get_trx(thr)->mysql_thd, + index->table); } goto func_exit; } diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index defeb39d2f4..9a44bb7d314 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -4473,13 +4473,9 @@ row_merge_build_indexes( /* Do not continue if we can't encrypt table pages */ if (!old_table->is_readable() || !new_table->is_readable()) { - error = DB_DECRYPTION_FAILED; - ib_push_warning(trx->mysql_thd, DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - !old_table->is_readable() ? old_table->name.m_name : - new_table->name.m_name); + error = innodb_decryption_failed(trx->mysql_thd, + !old_table->is_readable() + ? old_table : new_table); goto func_exit; } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index ba11bea75c4..4e7cd6b0b37 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -68,7 +68,7 @@ Created 9/17/2000 Heikki Tuuri #include #include #include - +#include "log.h" /** Provide optional 4.x backwards compatibility for 5.0 and above */ ibool row_rollback_on_timeout = FALSE; @@ -1257,51 +1257,26 @@ run_again: return(err); } -/** Determine is tablespace encrypted but decryption failed, is table corrupted -or is tablespace .ibd file missing. -@param[in] table Table -@param[in] trx Transaction -@param[in] push_warning true if we should push warning to user +/** Report an error for a failure to access a table. +@param table unreadable table +@param trx transaction @retval DB_DECRYPTION_FAILED table is encrypted but decryption failed @retval DB_CORRUPTION table is corrupted @retval DB_TABLESPACE_NOT_FOUND tablespace .ibd file not found */ -static -dberr_t -row_mysql_get_table_status( - const dict_table_t* table, - trx_t* trx, - bool push_warning = true) +ATTRIBUTE_COLD +static dberr_t row_mysql_get_table_error(trx_t *trx, dict_table_t *table) { - dberr_t err; - if (const fil_space_t* space = table->space) { - if (space->crypt_data && space->crypt_data->is_encrypted()) { - // maybe we cannot access the table due to failing - // to decrypt - if (push_warning) { - ib_push_warning(trx, DB_DECRYPTION_FAILED, - "Table %s in tablespace %lu encrypted." - "However key management plugin or used key_id is not found or" - " used encryption algorithm or method does not match.", - table->name.m_name, table->space); - } + if (const fil_space_t *space= table->space) + { + if (space->crypt_data && space->crypt_data->is_encrypted()) + return innodb_decryption_failed(trx->mysql_thd, table); + return DB_CORRUPTION; + } - err = DB_DECRYPTION_FAILED; - } else { - if (push_warning) { - ib_push_warning(trx, DB_CORRUPTION, - "Table %s in tablespace %lu corrupted.", - table->name.m_name, table->space); - } - - err = DB_CORRUPTION; - } - } else { - ib::error() << ".ibd file is missing for table " - << table->name; - err = DB_TABLESPACE_NOT_FOUND; - } - - return(err); + const int dblen= int(table->name.dblen()); + sql_print_error("InnoDB .ibd file is missing for table %`.*s.%`s", + dblen, table->name.m_name, table->name.m_name + dblen + 1); + return DB_TABLESPACE_NOT_FOUND; } /** Does an insert for MySQL. @@ -1339,7 +1314,7 @@ row_insert_for_mysql( return(DB_TABLESPACE_DELETED); } else if (!prebuilt->table->is_readable()) { - return(row_mysql_get_table_status(prebuilt->table, trx, true)); + return row_mysql_get_table_error(trx, prebuilt->table); } else if (high_level_read_only) { return(DB_READ_ONLY); } @@ -1726,7 +1701,7 @@ row_update_for_mysql(row_prebuilt_t* prebuilt) ut_ad(table->stat_initialized); if (!table->is_readable()) { - return(row_mysql_get_table_status(table, trx, true)); + return row_mysql_get_table_error(trx, table); } if (high_level_read_only) { diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 2a34685e7cc..d1ccedcbeca 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4753,13 +4753,8 @@ wait_table_again: if (err != DB_SUCCESS) { if (err == DB_DECRYPTION_FAILED) { - ib_push_warning(trx->mysql_thd, - DB_DECRYPTION_FAILED, - "Table %s is encrypted but encryption service or" - " used key_id is not available. " - " Can't continue reading table.", - prebuilt->table->name.m_name); - index->table->file_unreadable = true; + innodb_decryption_failed(trx->mysql_thd, + index->table); } rec = NULL; goto page_read_error; From f06060f5ed3f293763e034c011da6c6cf42ae3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 6 Sep 2024 14:31:55 +0300 Subject: [PATCH 14/54] Cleanup: Remove the function dict_remove_db_name() --- storage/innobase/dict/dict0dict.cc | 15 --------------- storage/innobase/include/dict0dict.h | 12 +++--------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index d44b017b32f..1df848d259c 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -185,21 +185,6 @@ dict_tables_have_same_db( return(FALSE); } -/********************************************************************//** -Return the end of table name where we have removed dbname and '/'. -@return table name */ -const char* -dict_remove_db_name( -/*================*/ - const char* name) /*!< in: table name in the form - dbname '/' tablename */ -{ - const char* s = strchr(name, '/'); - ut_a(s); - - return(s + 1); -} - /** Open a persistent table. @param[in] table_id persistent table identifier @param[in] ignore_err errors to ignore diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 6bfd774b941..412c41d2188 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -101,15 +101,9 @@ dict_table_is_partition(const dict_table_t* table) return (strstr(table->name.m_name, "#p#") || strstr(table->name.m_name, "#P#")); } -/********************************************************************//** -Return the end of table name where we have removed dbname and '/'. -@return table name */ -const char* -dict_remove_db_name( -/*================*/ - const char* name) /*!< in: table name in the form - dbname '/' tablename */ - MY_ATTRIBUTE((nonnull, warn_unused_result)); + +#define dict_remove_db_name(name) \ + (table_name_t{const_cast(name)}.dbend() + 1) /** Operation to perform when opening a table */ enum dict_table_op_t { From f0b2e76577a1b94d28671a3b6c53f08bce704821 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 6 Sep 2024 14:58:45 +0300 Subject: [PATCH 15/54] Removed ctrl-l from the source --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 97193e3e47d..b185c62aea6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5242,7 +5242,7 @@ static bool get_quick_record_count(THD *thd, SQL_SELECT *select, if (unlikely(check_stack_overrun(thd, STACK_MIN_SIZE, buff))) DBUG_RETURN(false); // Fatal error flag is set if (select) - { + { select->head=table; table->reginfo.impossible_range=0; /* From 886d740ad77013d6d080c2907b632c817c9784c9 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 6 Sep 2024 15:04:36 +0300 Subject: [PATCH 16/54] Optimized max_part_bit in sql_select.cc to use my_find_first_bit. --- sql/sql_select.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b185c62aea6..7dc76b3b35f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6967,12 +6967,13 @@ Item_equal::add_key_fields(JOIN *join, KEY_FIELD **key_fields, } -static uint +static inline uint max_part_bit(key_part_map bits) { - uint found; - for (found=0; bits & 1 ; found++,bits>>=1) ; - return found; + if (bits == 0) + return 0; + /* find first zero bit by reverting all bits and find first bit */ + return my_find_first_bit(~(ulonglong) bits); } From c41ab95a3899248059abe952725781fac32b51bf Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 6 Sep 2024 15:05:23 +0300 Subject: [PATCH 17/54] Remove rows and cost from optimizer trace for not usable key parts --- mysql-test/main/opt_trace.result | 2 -- sql/sql_select.cc | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 54821377fe0..ff9797a7072 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -9417,8 +9417,6 @@ S { "access_type": "ref", "index": "PRIMARY", - "rows": 1.79769e308, - "cost": 1.79769e308, "chosen": false, "cause": "no predicate for first keypart" } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7dc76b3b35f..bf80b360ab2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8085,7 +8085,6 @@ best_access_path(JOIN *join, SplM_plan_info *spl_plan= 0; table_map spl_pd_boundary= 0; Range_rowid_filter_cost_info *filter= 0; - const char* cause= NULL; enum join_type best_type= JT_UNKNOWN, type= JT_UNKNOWN; disable_jbuf= disable_jbuf || idx == join->const_tables; @@ -8113,6 +8112,7 @@ best_access_path(JOIN *join, TABLE *table= s->table; double best_records= DBL_MAX; uint max_key_part=0; + const char *cause= NULL; /* Test how we can use keys */ rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key @@ -8661,7 +8661,9 @@ best_access_path(JOIN *join, table->key_info[filter->key_no].name); } } - trace_access_idx.add("rows", records).add("cost", tmp); + + if (!cause) + trace_access_idx.add("rows", records).add("cost", tmp); if (tmp + 0.0001 < best_time - records/TIME_FOR_COMPARE) { @@ -8680,7 +8682,6 @@ best_access_path(JOIN *join, trace_access_idx.add("chosen", false) .add("cause", cause ? cause : "cost"); } - cause= NULL; } /* for each key */ records= best_records; } From c630e23a186c7ecfe0afac21163cb4fa2cdc5f7a Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 7 Sep 2024 17:17:44 +0300 Subject: [PATCH 18/54] MDEV-34894: Poor query plan, because range estimates are not reused for ref(const) (Variant 4, with @@optimizer_adjust_secondary_key_costs, reuse in two places, and conditions are replaced with equivalent simpler forms in two more) In best_access_path(), ReuseRangeEstimateForRef-3, the check for whether "all used key_part_i used key_part_i=const" was incorrect: it may produced a "NO" answer for cases when we had: key_part1= const // some key parts are usable key_part2= value_not_in_join_prefix //present but unusable key_part3= non_const_value // unusable due to gap in key parts. This caused the optimizer to fail to apply ReuseRangeEstimateForRef heuristics. The consequence is poor query plan choice when the index in question has very skewed data distribution. The fix is enabled if its @@optimizer_adjust_secondary_key_costs flag is set. --- mysql-test/main/join.result | 84 +++++++++++++++++++ mysql-test/main/join.test | 78 +++++++++++++++++ mysql-test/main/mysqld--help.result | 8 +- mysql-test/main/secondary_key_costs.result | 2 +- .../sys_vars/r/sysvars_server_embedded.result | 4 +- .../r/sysvars_server_notembedded.result | 4 +- sql/sql_priv.h | 1 + sql/sql_select.cc | 48 ++++++++--- sql/sys_vars.cc | 7 +- 9 files changed, 214 insertions(+), 22 deletions(-) diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result index 34c58910f07..9f843a7e722 100644 --- a/mysql-test/main/join.result +++ b/mysql-test/main/join.result @@ -3495,3 +3495,87 @@ a b c SET OPTIMIZER_USE_CONDITION_SELECTIVITY=@tmp; DROP TABLE t1,t2; # End of 10.6 tests +# +# MDEV-34894: Poor query plan, because range estimates are not reused for ref(const) +# +create table t0 ( +a int, +b int, +dummy int +); +insert into t0 select seq,seq,seq from seq_1_to_10; +create table t1 ( +pk1 int, +pk2 int, +pk3 int, +key1 int, +key(key1), +filler char(100), +primary key(pk1,pk2,pk3) +); +insert into t1 +select +seq, seq, seq, +FLOOR(seq/2), +'filler-data' +from seq_1_to_10000; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +update t1 set pk1=1 where pk1 between 1 and 200; +explain select * from t1 where pk1=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 231 +explain select * from t0,t1 where t1.pk1=t0.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 ref PRIMARY PRIMARY 4 test.t0.a 1 +create table t2 ( +col int +); +insert into t2 select seq from seq_1_to_10000; +set optimizer_adjust_secondary_key_costs='fix_reuse_range_for_ref'; +# This must use this good query plan: +# t0 - ALL +# t1 - ref, key=key1, not PRIMARY as pk1=1 is true for 20% of all rows +# t2 - ALL +explain select * from t0, t1, t2 +where +t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and +t1.key1=t0.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t1 ref PRIMARY,key1 key1 5 test.t0.b 1 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 10000 Using where; Using join buffer (flat, BNL join) +set optimizer_adjust_secondary_key_costs=''; +# Bad query: +# t0 - ALL +# t1 - ref, key=PRIMARY +# t2 - ALL +explain select * from t0, t1, t2 +where +t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and +t1.key1=t0.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 10 +1 SIMPLE t1 ref PRIMARY,key1 PRIMARY 4 const 1 Using index condition; Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 10000 Using where; Using join buffer (flat, BNL join) +drop table t0,t1,t2; +set @@optimizer_adjust_secondary_key_costs="fix_reuse_range_for_ref"; +CREATE OR REPLACE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT, key(a,b,c)) ENGINE=Aria; +INSERT INTO t1 select seq/10,mod(seq,2),seq from seq_1_to_1000; +update t1 set a=10 WHERE c < 100; +update t1 set a=12 WHERE a=11; +insert into t1 values (11,1,11), (11,2,11); +create or replace table t2 select seq from seq_1_to_10; +explain select count(*) from t1, t2 as seq where a=10 and b=seq.seq; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE seq ALL NULL NULL NULL NULL 10 +1 SIMPLE t1 ref a a 8 const,test.seq.seq 5 Using where; Using index +explain select count(*) from t1, t2 as seq where a=11 and b=seq.seq; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 4 const 2 Using index +1 SIMPLE seq ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +drop table t1,t2; +set @@optimizer_adjust_secondary_key_costs=default; diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index f8abc3fac22..6e037100ae5 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -1904,3 +1904,81 @@ SELECT * FROM SET OPTIMIZER_USE_CONDITION_SELECTIVITY=@tmp; DROP TABLE t1,t2; --echo # End of 10.6 tests + +--source include/have_sequence.inc + +--echo # +--echo # MDEV-34894: Poor query plan, because range estimates are not reused for ref(const) +--echo # +create table t0 ( + a int, + b int, + dummy int +); +insert into t0 select seq,seq,seq from seq_1_to_10; + +create table t1 ( + pk1 int, + pk2 int, + pk3 int, + key1 int, + key(key1), + filler char(100), + primary key(pk1,pk2,pk3) +); + +insert into t1 +select + seq, seq, seq, + FLOOR(seq/2), + 'filler-data' +from seq_1_to_10000; +analyze table t1; + +update t1 set pk1=1 where pk1 between 1 and 200; + +explain select * from t1 where pk1=1; + +explain select * from t0,t1 where t1.pk1=t0.a; + +create table t2 ( + col int +); +insert into t2 select seq from seq_1_to_10000; + +set optimizer_adjust_secondary_key_costs='fix_reuse_range_for_ref'; +--echo # This must use this good query plan: +--echo # t0 - ALL +--echo # t1 - ref, key=key1, not PRIMARY as pk1=1 is true for 20% of all rows +--echo # t2 - ALL +explain select * from t0, t1, t2 +where + t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and + t1.key1=t0.b; + +set optimizer_adjust_secondary_key_costs=''; +--echo # Bad query: +--echo # t0 - ALL +--echo # t1 - ref, key=PRIMARY +--echo # t2 - ALL +explain select * from t0, t1, t2 +where + t1.pk1=1 and t1.pk2=t2.col and t1.pk3=t0.dummy and + t1.key1=t0.b; + +drop table t0,t1,t2; + +set @@optimizer_adjust_secondary_key_costs="fix_reuse_range_for_ref"; +CREATE OR REPLACE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT, key(a,b,c)) ENGINE=Aria; +INSERT INTO t1 select seq/10,mod(seq,2),seq from seq_1_to_1000; +update t1 set a=10 WHERE c < 100; +update t1 set a=12 WHERE a=11; +insert into t1 values (11,1,11), (11,2,11); +create or replace table t2 select seq from seq_1_to_10; + +explain select count(*) from t1, t2 as seq where a=10 and b=seq.seq; +# This will execute code in ReuseRangeEstimateForRef-4 +explain select count(*) from t1, t2 as seq where a=11 and b=seq.seq; +drop table t1,t2; + +set @@optimizer_adjust_secondary_key_costs=default; diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 08cd1202655..1e5fad44a5b 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -721,8 +721,10 @@ The following specify which files/extra groups are read (specified before remain disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary - keys. This variable will be deleted in MariaDB 11.0 as it - is not needed with the new 11.0 optimizer. + keys. fix_reuse_range_for_ref = Do a better job at + reusing range access estimates when estimating ref + access. This variable will be deleted in MariaDB 11.0 as + it is not needed with the new 11.0 optimizer. Use 'ALL' to set all combinations. --optimizer-join-limit-pref-ratio=# For queries with JOIN and ORDER BY LIMIT : make the @@ -1705,7 +1707,7 @@ old-alter-table DEFAULT old-mode UTF8_IS_UTF8MB3 old-passwords FALSE old-style-user-limits FALSE -optimizer-adjust-secondary-key-costs +optimizer-adjust-secondary-key-costs fix_reuse_range_for_ref optimizer-join-limit-pref-ratio 0 optimizer-max-sel-arg-weight 32000 optimizer-max-sel-args 16000 diff --git a/mysql-test/main/secondary_key_costs.result b/mysql-test/main/secondary_key_costs.result index b246b666115..3a5b883068c 100644 --- a/mysql-test/main/secondary_key_costs.result +++ b/mysql-test/main/secondary_key_costs.result @@ -82,7 +82,7 @@ json_detailed(json_extract(@trace, '$**.considered_access_paths')) drop table t1, name, flag2; select @@optimizer_adjust_secondary_key_costs; @@optimizer_adjust_secondary_key_costs - +fix_reuse_range_for_ref set @@optimizer_adjust_secondary_key_costs=7; select @@optimizer_adjust_secondary_key_costs; @@optimizer_adjust_secondary_key_costs diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 42b661bc448..850497191d0 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -2275,11 +2275,11 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS VARIABLE_SCOPE SESSION VARIABLE_TYPE SET -VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. +VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. fix_reuse_range_for_ref = Do a better job at reusing range access estimates when estimating ref access. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality +ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality,fix_reuse_range_for_ref READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_JOIN_LIMIT_PREF_RATIO diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index b626551a570..fcbe4f51fc5 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -2435,11 +2435,11 @@ COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS VARIABLE_SCOPE SESSION VARIABLE_TYPE SET -VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. +VARIABLE_COMMENT A bit field with the following values: adjust_secondary_key_cost = Update secondary key costs for ranges to be at least 5x of clustered primary key costs. disable_max_seek = Disable 'max_seek optimization' for secondary keys and slight adjustment of filter cost. disable_forced_index_in_group_by = Disable automatic forced index in GROUP BY. fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB secondary keys. fix_reuse_range_for_ref = Do a better job at reusing range access estimates when estimating ref access. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality +ENUM_VALUE_LIST adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by,fix_innodb_cardinality,fix_reuse_range_for_ref READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_JOIN_LIMIT_PREF_RATIO diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 0bcb09a80ad..8f7962fc6b6 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -275,6 +275,7 @@ #define OPTIMIZER_ADJ_DISABLE_MAX_SEEKS (2) #define OPTIMIZER_ADJ_DISABLE_FORCE_INDEX_GROUP_BY (4) #define OPTIMIZER_FIX_INNODB_CARDINALITY (8) +#define OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF (16) /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bf80b360ab2..57e391dc82d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8125,6 +8125,7 @@ best_access_path(JOIN *join, key_part_map notnull_part=0; // key parts which won't have NULL in lookup tuple. table_map found_ref= 0; uint key= keyuse->key; + uint max_const_parts; filter= 0; bool ft_key= (keyuse->keypart == FT_KEYPART); /* Bitmap of keyparts where the ref access is over 'keypart=const': */ @@ -8228,6 +8229,8 @@ best_access_path(JOIN *join, rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables Json_writer_object trace_access_idx(thd); + max_const_parts= max_part_bit(const_part); + /* full text keys require special treatment */ @@ -8344,9 +8347,7 @@ best_access_path(JOIN *join, in ReuseRangeEstimateForRef-3. */ if (table->opt_range_keys.is_set(key) && - (const_part & - (((key_part_map)1 << table->opt_range[key].key_parts)-1)) == - (((key_part_map)1 << table->opt_range[key].key_parts)-1) && + table->opt_range[key].key_parts <= max_const_parts && table->opt_range[key].ranges == 1 && records > (double) table->opt_range[key].rows) { @@ -8394,6 +8395,17 @@ best_access_path(JOIN *join, found_part == PREV_BITS(uint,keyinfo->user_defined_key_parts))) { max_key_part= max_part_bit(found_part); + bool all_used_equalities_are_const; + if ((thd->variables.optimizer_adjust_secondary_key_costs & + OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF)) + { + all_used_equalities_are_const= (max_key_part == max_const_parts); + } + else + { + // Old, incorrect check: + all_used_equalities_are_const= !found_ref; + } /* ReuseRangeEstimateForRef-3: We're now considering a ref[or_null] access via @@ -8408,7 +8420,7 @@ best_access_path(JOIN *join, create quick select over another index), so we can't compare them to (**). We'll make indirect judgements instead. The sufficient conditions for re-use are: - (C1) All e_i in (**) are constants, i.e. found_ref==FALSE. (if + (C1) All e_i in (**) are constants (if this is not satisfied we have no way to know which ranges will be actually scanned by 'ref' until we execute the join) @@ -8418,7 +8430,7 @@ best_access_path(JOIN *join, We also have a property that "range optimizer produces equal or tighter set of scan intervals than ref(const) optimizer". Each of the intervals in (**) are "tightest possible" intervals when - one limits itself to using keyparts 1..K (which we do in #2). + one limits itself to using keyparts 1..K (which we do in #2). From here it follows that range access used either one, or both of the (I1) and (I2) intervals: @@ -8433,7 +8445,8 @@ best_access_path(JOIN *join, (C3) "range optimizer used (have ref_or_null?2:1) intervals" */ - if (table->opt_range_keys.is_set(key) && !found_ref && //(C1) + if (table->opt_range_keys.is_set(key) && + all_used_equalities_are_const && // (C1) table->opt_range[key].key_parts == max_key_part && //(C2) table->opt_range[key].ranges == 1 + MY_TEST(ref_or_null_part)) //(C3) { @@ -8466,10 +8479,10 @@ best_access_path(JOIN *join, */ if (table->opt_range_keys.is_set(key)) { + double rows= (double) table->opt_range[key].rows; if (table->opt_range[key].key_parts >= max_key_part) // (2) { - double rows= (double) table->opt_range[key].rows; - if (!found_ref && // (1) + if (all_used_equalities_are_const && // (1) records < rows) // (3) { trace_access_idx.add("used_range_estimates", "clipped up"); @@ -8537,15 +8550,26 @@ best_access_path(JOIN *join, */ if (table->opt_range_keys.is_set(key) && table->opt_range[key].key_parts <= max_key_part && - const_part & - ((key_part_map)1 << table->opt_range[key].key_parts) && table->opt_range[key].ranges == (1 + MY_TEST(ref_or_null_part & const_part)) && records > (double) table->opt_range[key].rows) { - trace_access_idx.add("used_range_estimates", true); - records= (double) table->opt_range[key].rows; + bool all_parts_used; + if ((thd->variables.optimizer_adjust_secondary_key_costs & + OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF)) + { + all_parts_used= table->opt_range[key].key_parts <= max_const_parts; + } + else + all_parts_used= (bool) (const_part & + ((key_part_map)1 + << table->opt_range[key].key_parts)); + if (all_parts_used) + { + trace_access_idx.add("used_range_estimates", true); + records= (double) table->opt_range[key].rows; + } } } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c5b507b936d..77d0c2daf78 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2837,7 +2837,8 @@ static Sys_var_ulong Sys_optimizer_trace_max_mem_size( */ static const char *adjust_secondary_key_cost[]= { - "adjust_secondary_key_cost", "disable_max_seek", "disable_forced_index_in_group_by", "fix_innodb_cardinality",0 + "adjust_secondary_key_cost", "disable_max_seek", "disable_forced_index_in_group_by", + "fix_innodb_cardinality", "fix_reuse_range_for_ref", 0 }; @@ -2852,10 +2853,12 @@ static Sys_var_set Sys_optimizer_adjust_secondary_key_costs( "GROUP BY. " "fix_innodb_cardinality = Disable doubling of the Cardinality for InnoDB " "secondary keys. " + "fix_reuse_range_for_ref = Do a better job at reusing range access estimates " + "when estimating ref access. " "This variable will be deleted in MariaDB 11.0 as it is not needed with the " "new 11.0 optimizer.", SESSION_VAR(optimizer_adjust_secondary_key_costs), CMD_LINE(REQUIRED_ARG), - adjust_secondary_key_cost, DEFAULT(0)); + adjust_secondary_key_cost, DEFAULT(OPTIMIZER_ADJ_FIX_REUSE_RANGE_FOR_REF)); static Sys_var_charptr_fscs Sys_pid_file( From 852d42e9933a2760b2542e977f2141d4e80dd8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 9 Sep 2024 16:47:35 +0300 Subject: [PATCH 19/54] MDEV-34483 Backup may copy unnecessarily much log In mariadb-backup --backup there are multiple mechanisms for ensuring that a sufficient amount of the InnoDB write-ahead log (ib_logfile0) is being copied at the end of the backup. The backup needs to include the latest committed transaction. While further transaction commits are blocked by BACKUP STAGE BLOCK_COMMIT, ongoing transactions may modify the database contents and write log records. We were unnecessarily copying such log, which would also cause further effort of rolling back incomplete transactions after the backup is restored. backup_wait_for_lsn(): Declare as static, and refactor some code to separate functions backup_wait_for_lsn_low() and backup_wait_timeout(). backup_wait_for_commit_lsn(): A new function to determine the current LSN (within BACKUP STAGE BLOCK_COMMIT) and to wait for the log to be copied until that. Invoked by BackupStages::stage_block_commit(). xtrabackup_backup_func(): Remove a condition that had already been checked by a caller of backup_wait_timeout(). server_lsn_after_lock: Declare as a local variable in BackupStages::stage_block_ddl(). log_copying_thread(), io_watching_thread(): Use metadata_last_lsn instead of metadata_to_lsn as the stop condition. BackupStages::stage_block_commit(): Ensure that the log tables (in particular, mysql.general_log) will have been copied before the BACKUP STAGE BLOCK_COMMIT is being followed by any further SQL statements. Reviewed by: Debarun Banerjee Tested by: Matthias Leich --- extra/mariabackup/backup_copy.cc | 3 - extra/mariabackup/xtrabackup.cc | 206 ++++++++++++------ .../suite/mariabackup/log_tables.result | 2 + mysql-test/suite/mariabackup/log_tables.test | 10 +- 4 files changed, 140 insertions(+), 81 deletions(-) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 3e97ef94835..c47c56d80d2 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1353,9 +1353,6 @@ out: return(ret); } -lsn_t server_lsn_after_lock; -extern void backup_wait_for_lsn(lsn_t lsn); - /** Release resources after backup_files() */ void backup_release() { diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 46b040d61bd..ca8891ca546 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3482,35 +3482,70 @@ static bool xtrabackup_copy_logfile() return false; } -/** -Wait until redo log copying thread processes given lsn -*/ -void backup_wait_for_lsn(lsn_t lsn) +static bool backup_wait_timeout(lsn_t lsn, lsn_t last_lsn) { - mysql_mutex_lock(&recv_sys.mutex); - for (lsn_t last_lsn{recv_sys.lsn}; last_lsn < lsn; ) + if (last_lsn >= lsn) + return true; + msg("Was only able to copy log from " LSN_PF " to " LSN_PF + ", not " LSN_PF "; try increasing innodb_log_file_size", + log_sys.next_checkpoint_lsn, last_lsn, lsn); + return false; +} + +/** +Wait for enough log to be copied. +@param lsn log sequence number target +@return the reached log sequence number (may be less or more than lsn) +*/ +static lsn_t backup_wait_for_lsn_low(lsn_t lsn) +{ + mysql_mutex_assert_owner(&recv_sys.mutex); + + lsn_t last_lsn{recv_sys.lsn}; + + if (last_lsn >= lsn) + return last_lsn; + + msg("Waiting for log copy thread to read lsn " LSN_PF, lsn); + + while (log_copying_running && last_lsn < lsn) { timespec abstime; set_timespec(abstime, 5); if (my_cond_timedwait(&scanned_lsn_cond, &recv_sys.mutex.m_mutex, &abstime) && last_lsn == recv_sys.lsn) - die("Was only able to copy log from " LSN_PF " to " LSN_PF - ", not " LSN_PF "; try increasing innodb_log_file_size", - log_sys.next_checkpoint_lsn, last_lsn, lsn); + break; last_lsn= recv_sys.lsn; } - mysql_mutex_unlock(&recv_sys.mutex); + + return last_lsn; +} + +/** +Wait for enough log to be copied after BACKUP STAGE BLOCK_DDL. +@param lsn log sequence number target +@return whether log_copying_thread() copied everything until the target lsn +*/ +static bool backup_wait_for_lsn(lsn_t lsn) +{ + if (!lsn) + return true; + mysql_mutex_lock(&recv_sys.mutex); + ut_ad(!metadata_to_lsn); + ut_ad(!metadata_last_lsn); + lsn_t last_lsn{backup_wait_for_lsn_low(lsn)}; + mysql_mutex_unlock(&recv_sys.mutex); + return backup_wait_timeout(lsn, last_lsn); } -extern lsn_t server_lsn_after_lock; static void log_copying_thread() { my_thread_init(); mysql_mutex_lock(&recv_sys.mutex); while (!xtrabackup_copy_logfile() && - (!metadata_to_lsn || metadata_to_lsn > recv_sys.lsn)) + (!metadata_last_lsn || metadata_last_lsn > recv_sys.lsn)) { timespec abstime; set_timespec_nsec(abstime, 1000000ULL * xtrabackup_log_copy_interval); @@ -3534,7 +3569,7 @@ static void io_watching_thread() mysql_mutex_lock(&recv_sys.mutex); ut_ad(have_io_watching_thread); - while (log_copying_running && !metadata_to_lsn) + while (log_copying_running && !metadata_last_lsn) { timespec abstime; set_timespec(abstime, 1); @@ -4685,6 +4720,7 @@ end: static void stop_backup_threads() { + ut_ad(metadata_last_lsn); mysql_cond_broadcast(&log_copying_stop); if (log_copying_running || have_io_watching_thread) @@ -4708,38 +4744,58 @@ static void stop_backup_threads() mysql_cond_destroy(&log_copying_stop); } +/** +Wait for enough log to be copied. +@return whether log_copying_thread() copied everything until the target lsn +*/ +static bool backup_wait_for_commit_lsn() +{ + lsn_t lsn= get_current_lsn(mysql_connection); + mysql_mutex_lock(&recv_sys.mutex); + ut_ad(!metadata_to_lsn); + ut_ad(!metadata_last_lsn); + + lsn_t last_lsn= recv_sys.lsn; + + /* read the latest checkpoint lsn */ + if (recv_sys.find_checkpoint() == DB_SUCCESS && log_sys.is_latest()) + { + if (log_sys.next_checkpoint_lsn > lsn) + lsn= log_sys.next_checkpoint_lsn; + metadata_to_lsn= log_sys.next_checkpoint_lsn; + msg("mariabackup: The latest check point (for incremental): '" + LSN_PF "'", metadata_to_lsn); + } + else + { + msg("Error: recv_sys.find_checkpoint() failed."); + metadata_last_lsn= 1; + stop_backup_threads(); + mysql_mutex_unlock(&recv_sys.mutex); + return false; + } + + recv_sys.lsn= last_lsn; + ut_ad(metadata_to_lsn); + metadata_last_lsn= lsn; + + last_lsn= backup_wait_for_lsn_low(LSN_MAX); + + metadata_last_lsn= last_lsn; + stop_backup_threads(); + mysql_mutex_unlock(&recv_sys.mutex); + return backup_wait_timeout(lsn, last_lsn); +} + /** Implement the core of --backup @return whether the operation succeeded */ bool Backup_datasinks::backup_low() { - mysql_mutex_lock(&recv_sys.mutex); - ut_ad(!metadata_to_lsn); - - /* read the latest checkpoint lsn */ - { - const lsn_t lsn = recv_sys.lsn; - if (recv_sys.find_checkpoint() == DB_SUCCESS - && log_sys.is_latest()) { - metadata_to_lsn = log_sys.next_checkpoint_lsn; - msg("mariabackup: The latest check point" - " (for incremental): '" LSN_PF "'", - metadata_to_lsn); - } else { - msg("Error: recv_sys.find_checkpoint() failed."); - } - - recv_sys.lsn = lsn; - stop_backup_threads(); - } - - if (metadata_to_lsn && xtrabackup_copy_logfile()) { - mysql_mutex_unlock(&recv_sys.mutex); - ds_close(dst_log_file); - dst_log_file = NULL; - return false; - } - - mysql_mutex_unlock(&recv_sys.mutex); + ut_d(mysql_mutex_lock(&recv_sys.mutex)); + ut_ad(metadata_last_lsn); + ut_ad(metadata_to_lsn); + ut_ad(!log_copying_running); + ut_d(mysql_mutex_unlock(&recv_sys.mutex)); if (ds_close(dst_log_file) || !metadata_to_lsn) { dst_log_file = NULL; @@ -4756,7 +4812,7 @@ bool Backup_datasinks::backup_low() for (uint32_t id : failed_ids) { msg("mariabackup: Failed to read undo log " - "tablespace space id %d and there is no undo " + "tablespace space id " UINT32PF " and there is no undo " "tablespace truncation redo record.", id); } @@ -4843,17 +4899,17 @@ private: // TODO: this came from the old code, where it was not thread-safe // too, use separate mysql connection per thread here DBUG_MARIABACKUP_EVENT("before_copy", node->space->name()); - DBUG_EXECUTE_FOR_KEY("wait_innodb_redo_before_copy", - node->space->name(), - backup_wait_for_lsn( - get_current_lsn(mysql_connection));); + DBUG_EXECUTE_FOR_KEY("wait_innodb_redo_before_copy", + node->space->name(), + backup_wait_for_lsn( + get_current_lsn(mysql_connection));); /* copy the datafile */ if(xtrabackup_copy_datafile(m_backup_datasinks.m_data, - m_backup_datasinks.m_meta, - node, thread_num, NULL, - xtrabackup_incremental - ? wf_incremental : wf_write_through, - m_corrupted_pages)) + m_backup_datasinks.m_meta, + node, thread_num, NULL, + xtrabackup_incremental + ? wf_incremental : wf_write_through, + m_corrupted_pages)) die("mariabackup: Error: failed to copy datafile."); // TODO: this came from the old code, where it was not thread-safe // too, use separate mysql connection per thread here @@ -4861,8 +4917,8 @@ private: m_tasks.finish_task(1); } - Backup_datasinks &m_backup_datasinks; - CorruptedPages &m_corrupted_pages; + Backup_datasinks &m_backup_datasinks; + CorruptedPages &m_corrupted_pages; TasksGroup m_tasks; }; @@ -5063,9 +5119,9 @@ class BackupStages { return false; } - msg("Waiting for log copy thread to read lsn %llu", - server_lsn_after_lock); - backup_wait_for_lsn(server_lsn_after_lock); + if (!backup_wait_for_lsn(server_lsn_after_lock)) { + return false; + } corrupted_pages.backup_fix_ddl(backup_datasinks.m_data, backup_datasinks.m_meta); @@ -5101,11 +5157,28 @@ class BackupStages { } // Copy log tables tail - if (!m_common_backup.copy_log_tables(true)) { + if (!m_common_backup.copy_log_tables(true) || + !m_common_backup.close_log_tables()) { msg("Error on copy log tables"); return false; } + // Copy just enough log to cover the latest commit. + // Meanwhile, there could be some active transactions + // that are modifying the database and writing more + // log. Not copying log for them will save busy work + // and avoid some rollback of the incomplete + // transactions after the backup has been restored. + // + // We find the current InnoDB LSN by executing + // SHOW ENGINE INNODB STATUS, which in the case of + // general_log=1, log_output='TABLES' + // would be written to the table mysql.general_log + // that we just finished copying above. + if (!backup_wait_for_commit_lsn()) { + return false; + } + // Copy stats tables if (!m_common_backup.copy_stats_tables()) { msg("Error on copy stats tables"); @@ -5123,11 +5196,6 @@ class BackupStages { return false; } - if (!m_common_backup.close_log_tables()) { - msg("Error on close log tables"); - return false; - } - if (!backup_files_from_datadir(backup_datasinks.m_data, fil_path_to_mysql_datadir, "aws-kms-key")) { @@ -5269,13 +5337,14 @@ static bool xtrabackup_backup_func() undo_space_trunc = backup_undo_trunc; first_page_init = backup_first_page_op; metadata_to_lsn = 0; + metadata_last_lsn = 0; /* initialize components */ if(innodb_init_param()) { fail: if (log_copying_running) { mysql_mutex_lock(&recv_sys.mutex); - metadata_to_lsn = 1; + metadata_last_lsn = 1; stop_backup_threads(); mysql_mutex_unlock(&recv_sys.mutex); } @@ -5460,14 +5529,9 @@ fail: xb_data_files_close(); - /* Make sure that the latest checkpoint was included */ - if (metadata_to_lsn > recv_sys.lsn) { - msg("Error: failed to copy enough redo log (" - "LSN=" LSN_PF "; checkpoint LSN=" LSN_PF ").", - recv_sys.lsn, metadata_to_lsn); - goto fail; - } - + ut_ad(!log_copying_running); + ut_ad(metadata_to_lsn <= recv_sys.lsn); + ut_ad(metadata_last_lsn == recv_sys.lsn); innodb_shutdown(); log_file_op = NULL; undo_space_trunc = NULL; diff --git a/mysql-test/suite/mariabackup/log_tables.result b/mysql-test/suite/mariabackup/log_tables.result index 840efc718e9..2528691f1b4 100644 --- a/mysql-test/suite/mariabackup/log_tables.result +++ b/mysql-test/suite/mariabackup/log_tables.result @@ -1,5 +1,7 @@ CREATE TABLE t(i INT) ENGINE ARIA TRANSACTIONAL=1 ROW_FORMAT=PAGE PAGE_CHECKSUM=1; +SET GLOBAL general_log = 0; +TRUNCATE mysql.general_log; SET GLOBAL general_log = 1; SET GLOBAL log_output = 'TABLE'; INSERT INTO t VALUES (1); diff --git a/mysql-test/suite/mariabackup/log_tables.test b/mysql-test/suite/mariabackup/log_tables.test index fe540a1ca91..707057a80e6 100644 --- a/mysql-test/suite/mariabackup/log_tables.test +++ b/mysql-test/suite/mariabackup/log_tables.test @@ -7,9 +7,9 @@ CREATE TABLE t(i INT) ENGINE ARIA TRANSACTIONAL=1 ROW_FORMAT=PAGE PAGE_CHECKSUM=1; ---let $general_log_old = `SELECT @@global.general_log` ---let $log_output_old = `SELECT @@global.log_output` - +# Truncate the log in order to make the test ./mtr --repeat proof +SET GLOBAL general_log = 0; +TRUNCATE mysql.general_log; SET GLOBAL general_log = 1; SET GLOBAL log_output = 'TABLE'; @@ -43,7 +43,3 @@ SELECT * FROM mysql.general_log --rmdir $targetdir DROP TABLE t; ---disable_query_log ---eval SET GLOBAL general_log = $general_log_old ---eval SET GLOBAL log_output = $log_output_old ---enable_query_log From ccb4bc775498eae2efa4901d53083998bad7ef27 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 9 Sep 2024 14:05:02 +1000 Subject: [PATCH 20/54] MDEV-33894: Resurrect innodb_log_write_ahead_size (postfix) os_file_log_maybe_unbuffered is now Linux only. Aso the stat st structure only used in linux. This avoids unused function/structure errors on FreeBSD. --- storage/innobase/os/os0file.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index f37f61d77bf..fa3ccfb6b80 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1095,13 +1095,11 @@ static ATTRIBUTE_COLD void os_file_log_buffered() log_sys.log_maybe_unbuffered= false; log_sys.log_buffered= true; } -# endif /** @return whether the log file may work with unbuffered I/O. */ static ATTRIBUTE_COLD bool os_file_log_maybe_unbuffered(const struct stat &st) { MSAN_STAT_WORKAROUND(&st); -# ifdef __linux__ char b[20 + sizeof "/sys/dev/block/" ":" "/../queue/physical_block_size"]; if (snprintf(b, sizeof b, "/sys/dev/block/%u:%u/queue/physical_block_size", major(st.st_dev), minor(st.st_dev)) >= @@ -1133,13 +1131,11 @@ static ATTRIBUTE_COLD bool os_file_log_maybe_unbuffered(const struct stat &st) if (s > 4096 || s < 64 || !ut_is_2pow(s)) return false; log_sys.set_block_size(uint32_t(s)); -# else - constexpr unsigned long s= 4096; -# endif return !(st.st_size & (s - 1)); } -#endif +# endif /* __linux__ */ +#endif /* O_DIRECT */ /** NOTE! Use the corresponding macro os_file_create(), not directly this function! @@ -1192,7 +1188,9 @@ os_file_create_func( } #ifdef O_DIRECT +# ifdef __linux__ struct stat st; +# endif ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE || type == OS_DATA_FILE_NO_O_DIRECT); int direct_flag = 0; From 24d67aaf9c1a89b9ca64a6798af819b6417f47c9 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 9 Sep 2024 14:13:38 +1000 Subject: [PATCH 21/54] MDEV-34825 FreeBSD fails to build under clang natively (postfix) 10.5 added contents of cmake/os/FreeBSD.cmake in c991efd9c35eb3f2a90b2562071860a10a4cbaa2. in the merge to 10.11, d002b1f removed this file. In the past FreeBSD.cmake was removed in 5369df741b3a87d7b262aafe95438b33ed124295 in the 10.11 branch as no remaining code was needed. The combination of this and the merge lead to the the file being removed. My assumption is this was a non-stable branch at the time. The purpose of this patch is clang doesn't have /usr/local/lib in the path. As such there are various depedency linkages that will fail. For example pcre and libfmt. --- cmake/os/FreeBSD.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cmake/os/FreeBSD.cmake diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake new file mode 100644 index 00000000000..4bcd844929f --- /dev/null +++ b/cmake/os/FreeBSD.cmake @@ -0,0 +1,19 @@ +# Copyright (C) 2024 MariaDB Foundation +# +# 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-1335 USA + +# This file includes FreeBSD specific options and quirks, related to system checks + +# For all userspace dependencies +LINK_DIRECTORIES(/usr/local/lib) From 05fafaf82d29310302de2072eddd54520b4665b5 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:22:59 +0800 Subject: [PATCH 22/54] MDEV-27646 remove SPIDER_HAS_HASH_VALUE_TYPE unifdef -DSPIDER_HAS_HASH_VALUE_TYPE -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/* --- storage/spider/ha_spider.cc | 43 ----------------- storage/spider/spd_conn.cc | 55 --------------------- storage/spider/spd_conn.h | 2 - storage/spider/spd_db_conn.cc | 2 - storage/spider/spd_db_mysql.cc | 15 ------ storage/spider/spd_db_mysql.h | 2 - storage/spider/spd_db_oracle.cc | 15 ------ storage/spider/spd_db_oracle.h | 2 - storage/spider/spd_direct_sql.cc | 19 -------- storage/spider/spd_include.h | 26 ---------- storage/spider/spd_ping_table.cc | 22 --------- storage/spider/spd_table.cc | 82 -------------------------------- storage/spider/spd_table.h | 12 ----- storage/spider/spd_trx.cc | 16 ------- 14 files changed, 313 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index afa3732c577..fa6568a9f65 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -49,9 +49,7 @@ extern handlerton *spider_hton_ptr; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE extern HASH spider_open_tables; -#endif extern pthread_mutex_t spider_lgtm_tblhnd_share_mutex; /* UTC time zone for timestamp columns */ @@ -10705,16 +10703,11 @@ int ha_spider::create( memset((void*)&tmp_share, 0, sizeof(SPIDER_SHARE)); tmp_share.table_name = (char*) name; tmp_share.table_name_length = strlen(name); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE tmp_share.table_name_hash_value = my_calc_hash(&trx->trx_alter_table_hash, (uchar*) tmp_share.table_name, tmp_share.table_name_length); tmp_share.lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( name, tmp_share.table_name_length, tmp_share.table_name_hash_value, FALSE, TRUE, &error_num); -#else - tmp_share.lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( - name, tmp_share.table_name_length, FALSE, TRUE, &error_num); -#endif if (!tmp_share.lgtm_tblhnd_share) { goto error; @@ -10787,16 +10780,10 @@ int ha_spider::create( spider_free_trx_alter_table(trx); trx->query_id = thd->query_id; } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(alter_table = (SPIDER_ALTER_TABLE*) my_hash_search_using_hash_value( &trx->trx_alter_table_hash, tmp_share.table_name_hash_value, (uchar*) tmp_share.table_name, tmp_share.table_name_length))) -#else - if (!(alter_table = - (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, - (uchar*) tmp_share.table_name, tmp_share.table_name_length))) -#endif { if ((error_num = spider_create_trx_alter_table(trx, &tmp_share, TRUE))) goto error; @@ -10921,12 +10908,10 @@ int ha_spider::rename_table( ) { int error_num, roop_count, old_link_count, from_len = strlen(from), to_len = strlen(to), tmp_error_num; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type from_hash_value = my_calc_hash(&spider_open_tables, (uchar*) from, from_len); my_hash_value_type to_hash_value = my_calc_hash(&spider_open_tables, (uchar*) to, to_len); -#endif THD *thd = ha_thd(); uint sql_command = thd_sql_command(thd); SPIDER_TRX *trx; @@ -11094,22 +11079,12 @@ int ha_spider::rename_table( } pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE from_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( from, from_len, from_hash_value, TRUE, FALSE, &error_num); -#else - from_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( - from, from_len, TRUE, FALSE, &error_num); -#endif if (from_lgtm_tblhnd_share) { -#ifdef SPIDER_HAS_HASH_VALUE_TYPE to_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( to, to_len, to_hash_value, TRUE, TRUE, &error_num); -#else - to_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( - to, to_len, TRUE, TRUE, &error_num); -#endif if (!to_lgtm_tblhnd_share) { pthread_mutex_unlock(&spider_lgtm_tblhnd_share_mutex); @@ -11135,13 +11110,8 @@ error: spider_close_sys_table(current_thd, table_tables, &open_tables_backup, need_lock); pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE to_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( to, to_len, to_hash_value, TRUE, FALSE, &tmp_error_num); -#else - to_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( - to, to_len, TRUE, FALSE, &tmp_error_num); -#endif if (to_lgtm_tblhnd_share) spider_free_lgtm_tblhnd_share_alloc(to_lgtm_tblhnd_share, TRUE); pthread_mutex_unlock(&spider_lgtm_tblhnd_share_mutex); @@ -11189,22 +11159,14 @@ int ha_spider::delete_table( { SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share; int roop_count, old_link_count = 0, name_len = strlen(name); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, (uchar*) name, name_len); -#endif if ( sql_command == SQLCOM_ALTER_TABLE && -#ifdef SPIDER_HAS_HASH_VALUE_TYPE (alter_table = (SPIDER_ALTER_TABLE*) my_hash_search_using_hash_value( &trx->trx_alter_table_hash, hash_value, (uchar*) name, name_len)) && -#else - (alter_table = - (SPIDER_ALTER_TABLE*) my_hash_search(&trx->trx_alter_table_hash, - (uchar*) name, name_len)) && -#endif alter_table->now_create ) DBUG_RETURN(0); @@ -11255,13 +11217,8 @@ int ha_spider::delete_table( } pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( name, name_len, hash_value, TRUE, FALSE, &error_num); -#else - lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share( - name, name_len, TRUE, FALSE, &error_num); -#endif if (lgtm_tblhnd_share) spider_free_lgtm_tblhnd_share_alloc(lgtm_tblhnd_share, TRUE); pthread_mutex_unlock(&spider_lgtm_tblhnd_share_mutex); diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 5549b30caa4..5912a2336d0 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -484,9 +484,7 @@ SPIDER_CONN *spider_create_conn( conn->conn_key = tmp_name; memcpy(conn->conn_key, share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx]; -#endif spider_memcpy_or_null(&conn->tgt_host, tmp_host, share->tgt_hosts[link_idx], &conn->tgt_host_length, share->tgt_hosts_lengths[link_idx]); @@ -599,14 +597,9 @@ SPIDER_CONN *spider_create_conn( pthread_mutex_unlock(&spider_conn_id_mutex); pthread_mutex_lock(&spider_ipport_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search_using_hash_value( &spider_ipport_conns, conn->conn_key_hash_value, (uchar*)conn->conn_key, conn->conn_key_length))) -#else - if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search( - &spider_ipport_conns, (uchar*)conn->conn_key, conn->conn_key_length))) -#endif { /* exists, +1 */ pthread_mutex_unlock(&spider_ipport_conn_mutex); pthread_mutex_lock(&ip_port_conn->mutex); @@ -679,7 +672,6 @@ SPIDER_CONN *spider_get_conn( #ifdef DBUG_TRACE spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]); #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( (another && !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( @@ -692,16 +684,6 @@ SPIDER_CONN *spider_get_conn( share->conn_keys_hash_value[link_idx], (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) ) -#else - if ( - (another && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_another_conn_hash, - (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || - (!another && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, - (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) - ) -#endif { if ( !trx->thd || @@ -711,16 +693,10 @@ SPIDER_CONN *spider_get_conn( ) ) { pthread_mutex_lock(&spider_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &spider_open_connections, share->conn_keys_hash_value[link_idx], (uchar*) share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_open_connections, - (uchar*) share->conn_keys[link_idx], - share->conn_keys_lengths[link_idx]))) -#endif { pthread_mutex_unlock(&spider_conn_mutex); if (spider_param_max_connections()) @@ -1140,16 +1116,10 @@ int spider_conn_queue_and_merge_loop_check( SPIDER_CONN_LOOP_CHECK *lcqptr, *lcrptr; DBUG_ENTER("spider_conn_queue_and_merge_loop_check"); DBUG_PRINT("info", ("spider conn=%p", conn)); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(lcqptr = (SPIDER_CONN_LOOP_CHECK *) my_hash_search_using_hash_value(&conn->loop_check_queue, lcptr->hash_value_to, (uchar *) lcptr->to_name.str, lcptr->to_name.length))) -#else - if (unlikely(!(lcqptr = (SPIDER_CONN_LOOP_CHECK *) my_hash_search( - &conn->loop_check_queue, - (uchar *) lcptr->to_name.str, lcptr->to_name.length)))) -#endif { /* Construct the right hand side: @@ -1196,9 +1166,7 @@ int spider_conn_queue_and_merge_loop_check( TODO: the new lcrptr has the same cur_name, to_name, full_name and from_value as lcqptr, but they do not seem to be relevant. */ -#ifdef SPIDER_HAS_HASH_VALUE_TYPE lcrptr->hash_value_to = lcqptr->hash_value_to; -#endif lcrptr->cur_name.str = cur_name; lcrptr->cur_name.length = lcqptr->cur_name.length; memcpy(cur_name, lcqptr->cur_name.str, lcqptr->cur_name.length + 1); @@ -1439,19 +1407,12 @@ int spider_conn_queue_loop_check( memcpy(tmp_name, to_str.str, to_str.length); tmp_name += to_str.length; *tmp_name = '\0'; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&conn->loop_checked, (uchar *) loop_check_buf, buf_sz - 1); -#endif pthread_mutex_lock(&conn->loop_check_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE lcptr = (SPIDER_CONN_LOOP_CHECK *) my_hash_search_using_hash_value(&conn->loop_checked, hash_value, (uchar *) loop_check_buf, buf_sz - 1); -#else - lcptr = (SPIDER_CONN_LOOP_CHECK *) my_hash_search( - &conn->loop_checked, (uchar *) loop_check_buf, buf_sz - 1); -#endif if ( !lcptr || ( @@ -1506,10 +1467,8 @@ int spider_conn_queue_loop_check( spider_conn_queue_and_merge_loop_check() */ lcptr->merged_value.str = merged_value; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE lcptr->hash_value_to = my_calc_hash(&conn->loop_check_queue, (uchar *) to_str.str, to_str.length); -#endif /* Mark as checked. It will be added to loop_check_queue in spider_conn_queue_and_merge_loop_check() below for checking @@ -4240,15 +4199,9 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( set_timespec(abstime, 0); pthread_mutex_lock(&spider_ipport_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search_using_hash_value( &spider_ipport_conns, share->conn_keys_hash_value[link_idx], (uchar*) share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]))) -#else - if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search( - &spider_ipport_conns, - (uchar*) share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]))) -#endif { /* exists */ pthread_mutex_unlock(&spider_ipport_conn_mutex); pthread_mutex_lock(&ip_port_conn->mutex); @@ -4287,16 +4240,10 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( } pthread_mutex_lock(&spider_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &spider_open_connections, share->conn_keys_hash_value[link_idx], (uchar*) share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]))) -#else - if ((conn = (SPIDER_CONN*) my_hash_search(&spider_open_connections, - (uchar*) share->conn_keys[link_idx], - share->conn_keys_lengths[link_idx]))) -#endif { /* get conn from spider_open_connections, then delete conn in spider_open_connections */ #ifdef HASH_UPDATE_WITH_HASH_VALUE @@ -4389,9 +4336,7 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn) ret->conn_id = conn->conn_id; ret->ip_port_count = 1; // init -#ifdef SPIDER_HAS_HASH_VALUE_TYPE ret->key_hash_value = conn->conn_key_hash_value; -#endif DBUG_RETURN(ret); err_malloc_key: spider_my_free(ret, MYF(0)); diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index c9eeb9d66d4..ef0c304c89f 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -50,10 +50,8 @@ typedef struct st_spider_conn_loop_check SPIDER_LOP_CHK_IGNORED */ uint flag; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE /* hash value of to_name, used for the hash conn->loop_checked */ my_hash_value_type hash_value_to; -#endif /* The fully qualified name of the current spider table, which will also be used to construct the user var name to set in the data diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 401774ed508..7ecd356873b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -60,9 +60,7 @@ extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; #define SPIDER_SQL_PING_TABLE_STR "spider_ping_table(" #define SPIDER_SQL_PING_TABLE_LEN (sizeof(SPIDER_SQL_PING_TABLE_STR) - 1) -#ifdef SPIDER_HAS_HASH_VALUE_TYPE extern HASH spider_open_connections; -#endif pthread_mutex_t spider_open_conn_mutex; const char spider_dig_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 04f4bfd22ee..c41379e26d5 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -7139,9 +7139,7 @@ spider_mbase_share::spider_mbase_share( table_names_str(NULL), db_names_str(NULL), db_table_str(NULL), -#ifdef SPIDER_HAS_HASH_VALUE_TYPE db_table_str_hash_value(NULL), -#endif table_nm_max_length(0), db_nm_max_length(0), column_name_str(NULL), @@ -7228,10 +7226,8 @@ int spider_mbase_share::init() __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), &key_select_pos, sizeof(int) * keys, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE &db_table_str_hash_value, sizeof(my_hash_value_type) * spider_share->all_link_count, -#endif NullS)) ) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -7511,10 +7507,8 @@ int spider_mbase_share::create_table_names_str() if ((error_num = append_table_name(str, roop_count))) goto error; } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE db_table_str_hash_value[roop_count] = my_calc_hash( &spider_open_connections, (uchar*) str->ptr(), str->length()); -#endif } DBUG_RETURN(0); @@ -8358,10 +8352,8 @@ int spider_mbase_handler::init() link_for_hash[roop_count].link_idx = roop_count; link_for_hash[roop_count].db_table_str = &mysql_share->db_table_str[roop_count]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE link_for_hash[roop_count].db_table_str_hash_value = mysql_share->db_table_str_hash_value[roop_count]; -#endif } DBUG_RETURN(0); } @@ -13153,7 +13145,6 @@ int spider_mbase_handler::append_lock_tables_list( &mysql_share->db_table_str[conn_link_idx]; DBUG_PRINT("info",("spider db_table_str=%s", tmp_link_for_hash2->db_table_str->c_ptr_safe())); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE tmp_link_for_hash2->db_table_str_hash_value = mysql_share->db_table_str_hash_value[conn_link_idx]; if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) @@ -13162,12 +13153,6 @@ int spider_mbase_handler::append_lock_tables_list( tmp_link_for_hash2->db_table_str_hash_value, (uchar*) tmp_link_for_hash2->db_table_str->ptr(), tmp_link_for_hash2->db_table_str->length()))) -#else - if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) my_hash_search( - &db_conn->lock_table_hash, - (uchar*) tmp_link_for_hash2->db_table_str->ptr(), - tmp_link_for_hash2->db_table_str->length()))) -#endif { if ((error_num = insert_lock_tables_list(conn, link_idx))) DBUG_RETURN(error_num); diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 0a133267e0e..9d86b837b32 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -622,9 +622,7 @@ public: spider_string *db_names_str; /* fixme: this field looks useless */ spider_string *db_table_str; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type *db_table_str_hash_value; -#endif uint table_nm_max_length; uint db_nm_max_length; spider_string *column_name_str; diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 362a77536ae..82216714a25 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -4475,9 +4475,7 @@ spider_oracle_share::spider_oracle_share( db_names_str(NULL), db_table_str(NULL), nextval_str(NULL), -#ifdef SPIDER_HAS_HASH_VALUE_TYPE db_table_str_hash_value(NULL), -#endif table_nm_max_length(0), db_nm_max_length(0), nextval_max_length(0), @@ -4530,10 +4528,8 @@ int spider_oracle_share::init() __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), &key_select_pos, sizeof(int) * keys, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE &db_table_str_hash_value, sizeof(my_hash_value_type) * spider_share->all_link_count, -#endif NullS)) ) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -4811,10 +4807,8 @@ int spider_oracle_share::create_table_names_str() if ((error_num = append_table_name(str, roop_count))) goto error; } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE db_table_str_hash_value[roop_count] = my_calc_hash( &spider_open_connections, (uchar*) str->ptr(), str->length()); -#endif } DBUG_RETURN(0); @@ -5498,10 +5492,8 @@ int spider_oracle_handler::init() link_for_hash[roop_count].link_idx = roop_count; link_for_hash[roop_count].db_table_str = &oracle_share->db_table_str[roop_count]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE link_for_hash[roop_count].db_table_str_hash_value = oracle_share->db_table_str_hash_value[roop_count]; -#endif } DBUG_RETURN(0); } @@ -10357,7 +10349,6 @@ int spider_oracle_handler::append_lock_tables_list( tmp_link_for_hash2 = &link_for_hash[link_idx]; tmp_link_for_hash2->db_table_str = &oracle_share->db_table_str[conn_link_idx]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE tmp_link_for_hash2->db_table_str_hash_value = oracle_share->db_table_str_hash_value[conn_link_idx]; if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) @@ -10366,12 +10357,6 @@ int spider_oracle_handler::append_lock_tables_list( tmp_link_for_hash2->db_table_str_hash_value, (uchar*) tmp_link_for_hash2->db_table_str->ptr(), tmp_link_for_hash2->db_table_str->length()))) -#else - if (!(tmp_link_for_hash = (SPIDER_LINK_FOR_HASH *) my_hash_search( - &db_conn->lock_table_hash, - (uchar*) tmp_link_for_hash2->db_table_str->ptr(), - tmp_link_for_hash2->db_table_str->length()))) -#endif { if ((error_num = insert_lock_tables_list(conn, link_idx))) DBUG_RETURN(error_num); diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index 357fee35c67..f9eff649692 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -523,9 +523,7 @@ public: spider_string *db_names_str; spider_string *db_table_str; spider_string *nextval_str; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type *db_table_str_hash_value; -#endif uint table_nm_max_length; uint db_nm_max_length; uint nextval_max_length; diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 0a242787e8f..49a6edc6d26 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -275,10 +275,8 @@ int spider_udf_direct_sql_create_conn_key( spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_default_group); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_dsn); tmp_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length); -#endif DBUG_RETURN(0); } @@ -443,14 +441,9 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( pthread_mutex_unlock(&spider_conn_id_mutex); pthread_mutex_lock(&spider_ipport_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search_using_hash_value( &spider_ipport_conns, conn->conn_key_hash_value, (uchar*)conn->conn_key, conn->conn_key_length))) -#else - if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search( - &spider_ipport_conns, (uchar*)conn->conn_key, conn->conn_key_length))) -#endif { /* exists, +1 */ pthread_mutex_unlock(&spider_ipport_conn_mutex); pthread_mutex_lock(&ip_port_conn->mutex); @@ -507,18 +500,11 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( SPIDER_CONN *conn = NULL; DBUG_ENTER("spider_udf_direct_sql_get_conn"); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_conn_hash, direct_sql->conn_key_hash_value, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) ) -#else - if ( - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) -#endif { if ( ( @@ -527,14 +513,9 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( ) ) { pthread_mutex_lock(&spider_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &spider_open_connections, direct_sql->conn_key_hash_value, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_open_connections, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length))) -#endif { pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider create new conn")); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 1d190ec2348..9190692223e 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -128,8 +128,6 @@ #define SPIDER_item_name_length(A) (A)->name.length const LEX_CSTRING SPIDER_empty_string = {"", 0}; -#define SPIDER_HAS_HASH_VALUE_TYPE - #define SPIDER_date_mode_t(A) date_mode_t(A) #define SPIDER_str_to_datetime(A,B,C,D,E) str_to_datetime_or_date(A,B,C,D,E) #define SPIDER_get_linkage(A) A->get_linkage() @@ -498,9 +496,7 @@ typedef struct st_spider_link_for_hash ha_spider *spider; int link_idx; spider_string *db_table_str; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type db_table_str_hash_value; -#endif } SPIDER_LINK_FOR_HASH; /* alter table */ @@ -510,9 +506,7 @@ typedef struct st_spider_alter_table char *table_name; uint table_name_length; char *tmp_char; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_name_hash_value; -#endif longlong tmp_priority; uint link_count; uint all_link_count; @@ -606,9 +600,7 @@ typedef struct st_spider_conn uint conn_kind; char *conn_key; uint conn_key_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type conn_key_hash_value; -#endif int link_idx; spider_db_conn *db_conn; uint opened_handlers; @@ -817,9 +809,7 @@ typedef struct st_spider_lgtm_tblhnd_share { char *table_name; uint table_name_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_path_hash_value; -#endif pthread_mutex_t auto_increment_mutex; volatile bool auto_increment_init; volatile ulonglong auto_increment_lclval; @@ -842,9 +832,7 @@ typedef struct st_spider_wide_share { char *table_name; uint table_name_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_path_hash_value; -#endif uint use_count; THR_LOCK lock; pthread_mutex_t sts_mutex; @@ -951,9 +939,7 @@ typedef struct st_spider_transaction bool updated_in_this_trx; THD *thd; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type thd_hash_value; -#endif XID xid; HASH trx_conn_hash; uint trx_conn_hash_id; @@ -1048,11 +1034,9 @@ typedef struct st_spider_share pthread_mutex_t crd_mutex; TABLE_SHARE *table_share; SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_name_hash_value; #ifdef WITH_PARTITION_STORAGE_ENGINE my_hash_value_type table_path_hash_value; -#endif #endif volatile bool init; @@ -1227,9 +1211,7 @@ typedef struct st_spider_share char *bka_engine; int bka_engine_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type *conn_keys_hash_value; -#endif char **server_names; char **tgt_table_names; char **tgt_dbs; @@ -1390,9 +1372,7 @@ typedef struct st_spider_init_error_table { char *table_name; uint table_name_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type table_name_hash_value; -#endif bool init_error_with_message; char init_error_msg[MYSQL_ERRMSG_SIZE]; volatile int init_error; @@ -1469,9 +1449,7 @@ typedef struct st_spider_direct_sql uint tgt_dsn_length; uint conn_key_length; uint dbton_id; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type conn_key_hash_value; -#endif pthread_mutex_t *bg_mutex; pthread_cond_t *bg_cond; @@ -1510,9 +1488,7 @@ typedef struct st_spider_table_mon_list { char *key; uint key_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type key_hash_value; -#endif uint use_count; uint mutex_hash; @@ -1667,9 +1643,7 @@ char *spider_create_string( typedef struct st_spider_ip_port_conn { char *key; size_t key_len; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type key_hash_value; -#endif char *remote_ip_str; long remote_port; ulong ip_port_count; diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 8327a2c9fea..30f2814f8e1 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -105,9 +105,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( SPIDER_TABLE_MON_LIST *table_mon_list; MEM_ROOT mem_root; ulonglong mon_table_cache_version; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value; -#endif DBUG_ENTER("spider_get_ping_table_mon_list"); /* Reset the cache if the version does not match the requirement */ if (spider_mon_table_cache_version != spider_mon_table_cache_version_req) @@ -129,27 +127,17 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( spider_param_udf_table_mon_mutex_count()); DBUG_PRINT("info",("spider hash key=%s", str->c_ptr())); DBUG_PRINT("info",("spider hash key length=%u", str->length())); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value = my_calc_hash( &spider_udf_table_mon_list_hash[mutex_hash], (uchar*) str->c_ptr(), str->length()); -#endif pthread_mutex_lock(&spider_udf_table_mon_mutexes[mutex_hash]); mon_table_cache_version = (ulonglong) spider_mon_table_cache_version; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search_using_hash_value( &spider_udf_table_mon_list_hash[mutex_hash], hash_value, (uchar*) str->c_ptr(), str->length())) || table_mon_list->mon_table_cache_version != mon_table_cache_version ) -#else - if (!(table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search( - &spider_udf_table_mon_list_hash[mutex_hash], - (uchar*) str->c_ptr(), str->length())) || - table_mon_list->mon_table_cache_version != mon_table_cache_version - ) -#endif { /* If table_mon_list is found but the cache version does not match, remove it from the hash and free it. */ @@ -171,9 +159,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( table_mon_list->mon_table_cache_version = mon_table_cache_version; uint old_elements = spider_udf_table_mon_list_hash[mutex_hash].array.max_element; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE table_mon_list->key_hash_value = hash_value; -#endif #ifdef HASH_UPDATE_WITH_HASH_VALUE if (my_hash_insert_with_hash_value( &spider_udf_table_mon_list_hash[mutex_hash], @@ -280,22 +266,14 @@ int spider_release_ping_table_mon_list( mutex_hash = spider_udf_calc_hash(conv_name_str.c_ptr_safe(), spider_param_udf_table_mon_mutex_count()); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash( &spider_udf_table_mon_list_hash[mutex_hash], (uchar*) conv_name_str.c_ptr(), conv_name_str.length()); -#endif pthread_mutex_lock(&spider_udf_table_mon_mutexes[mutex_hash]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search_using_hash_value( &spider_udf_table_mon_list_hash[mutex_hash], hash_value, (uchar*) conv_name_str.c_ptr(), conv_name_str.length()))) -#else - if ((table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_search( - &spider_udf_table_mon_list_hash[mutex_hash], - (uchar*) conv_name_str.c_ptr(), conv_name_str.length()))) -#endif spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list); pthread_mutex_unlock(&spider_udf_table_mon_mutexes[mutex_hash]); my_afree(buf); diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index c1166c4e7d5..e6947fe3d6f 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -3938,10 +3938,8 @@ int spider_create_conn_keys( __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), &share->conn_keys, sizeof(char *) * share->all_link_count, &share->conn_keys_lengths, length_base, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE &share->conn_keys_hash_value, sizeof(my_hash_value_type) * share->all_link_count, -#endif &tmp_name, sizeof(char) * share->conn_keys_charlen, &share->sql_dbton_ids, length_base, NullS)) @@ -4001,11 +3999,9 @@ int spider_create_conn_keys( spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_dsns[roop_count]); tmp_name++; tmp_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE share->conn_keys_hash_value[roop_count] = my_calc_hash( &spider_open_connections, (uchar*) share->conn_keys[roop_count], share->conn_keys_lengths[roop_count]); -#endif } for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) { @@ -4028,9 +4024,7 @@ SPIDER_SHARE *spider_create_share( #ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info, #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value, -#endif int *error_num ) { int bitmap_size, roop_count; @@ -4079,13 +4073,11 @@ SPIDER_SHARE *spider_create_share( share->table_mon_mutex_bitmap = tmp_table_mon_mutex_bitmap; share->bitmap_size = bitmap_size; share->table_share = table_share; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE share->table_name_hash_value = hash_value; #ifdef WITH_PARTITION_STORAGE_ENGINE share->table_path_hash_value = my_calc_hash(&spider_open_tables, (uchar*) table_share->path.str, table_share->path.length); #endif -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH share->table.s = table_share; share->table.field = table_share->field; @@ -4158,14 +4150,9 @@ SPIDER_SHARE *spider_create_share( goto error_init_crd_mutex; } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(share->lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share(tmp_name, length, hash_value, FALSE, TRUE, error_num))) -#else - if (!(share->lgtm_tblhnd_share = - spider_get_lgtm_tblhnd_share(tmp_name, length, FALSE, TRUE, error_num))) -#endif { goto error_get_lgtm_tblhnd_share; } @@ -4280,10 +4267,8 @@ SPIDER_SHARE *spider_get_share( DBUG_ENTER("spider_get_share"); top_share = spider->wide_handler->top_share; length = (uint) strlen(table_name); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, (uchar*) table_name, length); -#endif if (top_share) { lex_str.length = top_share->path.length + SPIDER_SQL_LOP_CHK_PRM_PRF_LEN; @@ -4328,22 +4313,15 @@ SPIDER_SHARE *spider_get_share( my_afree(loop_check_buf); } pthread_mutex_lock(&spider_tbl_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(share = (SPIDER_SHARE*) my_hash_search_using_hash_value( &spider_open_tables, hash_value, (uchar*) table_name, length))) -#else - if (!(share = (SPIDER_SHARE*) my_hash_search(&spider_open_tables, - (uchar*) table_name, length))) -#endif { if (!(share = spider_create_share( table_name, table_share, #ifdef WITH_PARTITION_STORAGE_ENGINE table->part_info, #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif error_num ))) { goto error_alloc_share; @@ -5422,19 +5400,12 @@ void spider_update_link_status_for_share( SPIDER_SHARE *share; DBUG_ENTER("spider_update_link_status_for_share"); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, (uchar*) table_name, table_name_length); -#endif pthread_mutex_lock(&spider_tbl_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((share = (SPIDER_SHARE*) my_hash_search_using_hash_value( &spider_open_tables, hash_value, (uchar*) table_name, table_name_length))) -#else - if ((share = (SPIDER_SHARE*) my_hash_search(&spider_open_tables, - (uchar*) table_name, table_name_length))) -#endif { DBUG_PRINT("info", ("spider share->link_status_init=%s", share->link_status_init ? "TRUE" : "FALSE")); @@ -5449,7 +5420,6 @@ void spider_update_link_status_for_share( DBUG_VOID_RETURN; } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( const char *table_name, uint table_name_length, @@ -5458,15 +5428,6 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( bool need_to_create, int *error_num ) -#else -SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( - const char *table_name, - uint table_name_length, - bool locked, - bool need_to_create, - int *error_num -) -#endif { SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share; char *tmp_name; @@ -5474,16 +5435,10 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( if (!locked) pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(lgtm_tblhnd_share = (SPIDER_LGTM_TBLHND_SHARE*) my_hash_search_using_hash_value( &spider_lgtm_tblhnd_share_hash, hash_value, (uchar*) table_name, table_name_length))) -#else - if (!(lgtm_tblhnd_share = (SPIDER_LGTM_TBLHND_SHARE*) my_hash_search( - &spider_lgtm_tblhnd_share_hash, - (uchar*) table_name, table_name_length))) -#endif { DBUG_PRINT("info",("spider create new lgtm tblhnd share")); if (!(lgtm_tblhnd_share = (SPIDER_LGTM_TBLHND_SHARE *) @@ -5500,9 +5455,7 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( lgtm_tblhnd_share->table_name = tmp_name; memcpy(lgtm_tblhnd_share->table_name, table_name, lgtm_tblhnd_share->table_name_length); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE lgtm_tblhnd_share->table_path_hash_value = hash_value; -#endif if (mysql_mutex_init(spd_key_mutex_share_auto_increment, &lgtm_tblhnd_share->auto_increment_mutex, MY_MUTEX_INIT_FAST)) @@ -5578,16 +5531,10 @@ SPIDER_WIDE_SHARE *spider_get_wide_share( DBUG_ENTER("spider_get_wide_share"); pthread_mutex_lock(&spider_wide_share_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(wide_share = (SPIDER_WIDE_SHARE*) my_hash_search_using_hash_value( &spider_open_wide_share, share->table_path_hash_value, (uchar*) table_share->path.str, table_share->path.length))) -#else - if (!(wide_share = (SPIDER_WIDE_SHARE*) my_hash_search( - &spider_open_wide_share, - (uchar*) table_share->path.str, table_share->path.length))) -#endif { DBUG_PRINT("info",("spider create new wide share")); if (!(wide_share = (SPIDER_WIDE_SHARE *) @@ -5607,9 +5554,7 @@ SPIDER_WIDE_SHARE *spider_get_wide_share( wide_share->table_name = tmp_name; memcpy(wide_share->table_name, table_share->path.str, wide_share->table_name_length); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE wide_share->table_path_hash_value = share->table_path_hash_value; -#endif wide_share->cardinality = tmp_cardinality; wide_share->crd_get_time = wide_share->sts_get_time = @@ -7243,16 +7188,10 @@ SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table( char *tmp_name; DBUG_ENTER("spider_get_init_error_table"); pthread_mutex_lock(&spider_init_error_tbl_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search_using_hash_value( &spider_init_error_tables, share->table_name_hash_value, (uchar*) share->table_name, share->table_name_length))) -#else - if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search( - &spider_init_error_tables, - (uchar*) share->table_name, share->table_name_length))) -#endif { if (!create) { @@ -7271,10 +7210,8 @@ SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table( memcpy(tmp_name, share->table_name, share->table_name_length); spider_init_error_table->table_name = tmp_name; spider_init_error_table->table_name_length = share->table_name_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE spider_init_error_table->table_name_hash_value = share->table_name_hash_value; -#endif uint old_elements = spider_init_error_tables.array.max_element; #ifdef HASH_UPDATE_WITH_HASH_VALUE if (my_hash_insert_with_hash_value(&spider_init_error_tables, @@ -7305,20 +7242,13 @@ void spider_delete_init_error_table( ) { SPIDER_INIT_ERROR_TABLE *spider_init_error_table; uint length = strlen(name); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, (uchar*) name, length); -#endif DBUG_ENTER("spider_delete_init_error_table"); pthread_mutex_lock(&spider_init_error_tbl_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search_using_hash_value(&spider_init_error_tables, hash_value, (uchar*) name, length))) -#else - if ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *) my_hash_search( - &spider_init_error_tables, (uchar*) name, length))) -#endif { #ifdef HASH_UPDATE_WITH_HASH_VALUE my_hash_delete_with_hash_value(&spider_init_error_tables, @@ -8422,10 +8352,8 @@ int spider_discover_table_structure( #ifdef WITH_PARTITION_STORAGE_ENGINE str_len = str.length(); #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(&spider_open_tables, (uchar*) table_name, table_name_length); -#endif if (!(trx = spider_get_trx(thd, TRUE, &error_num))) { DBUG_PRINT("info",("spider spider_get_trx error")); @@ -8442,9 +8370,7 @@ int spider_discover_table_structure( #ifdef WITH_PARTITION_STORAGE_ENGINE NULL, #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif &error_num ))) { DBUG_RETURN(error_num); @@ -8503,9 +8429,7 @@ int spider_discover_table_structure( DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); if (!(spider_share = spider_create_share(tmp_name, share, part_info, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif &error_num ))) { DBUG_RETURN(error_num); @@ -8531,9 +8455,7 @@ int spider_discover_table_structure( DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); if (!(spider_share = spider_create_share(tmp_name, share, part_info, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif &error_num ))) { DBUG_RETURN(error_num); @@ -8574,9 +8496,7 @@ int spider_discover_table_structure( DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); if (!(spider_share = spider_create_share(tmp_name, share, part_info, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif &error_num ))) { DBUG_RETURN(error_num); @@ -8612,9 +8532,7 @@ int spider_discover_table_structure( DBUG_PRINT("info",("spider tmp_name=%s", tmp_name)); if (!(spider_share = spider_create_share(tmp_name, share, part_info, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE hash_value, -#endif &error_num ))) { DBUG_RETURN(error_num); diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h index b444ba2d3d9..8bca3c047fa 100644 --- a/storage/spider/spd_table.h +++ b/storage/spider/spd_table.h @@ -175,7 +175,6 @@ int spider_create_conn_keys( SPIDER_SHARE *share ); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( const char *table_name, uint table_name_length, @@ -184,15 +183,6 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( bool need_to_create, int *error_num ); -#else -SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( - const char *table_name, - uint table_name_length, - bool locked, - bool need_to_create, - int *error_num -); -#endif void spider_free_lgtm_tblhnd_share_alloc( SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share, @@ -205,9 +195,7 @@ SPIDER_SHARE *spider_create_share( #ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info, #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value, -#endif int *error_num ); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index dabec76f4dd..05a6fead947 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -587,11 +587,9 @@ int spider_create_trx_alter_table( alter_table->table_name = tmp_name; memcpy(alter_table->table_name, share->table_name, share->table_name_length); alter_table->table_name_length = share->table_name_length; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE DBUG_PRINT("info",("spider table_name_hash_value=%u", share->table_name_hash_value)); alter_table->table_name_hash_value = share->table_name_hash_value; -#endif alter_table->tmp_priority = share->priority; alter_table->link_count = share->link_count; alter_table->all_link_count = share->all_link_count; @@ -1189,13 +1187,11 @@ SPIDER_TRX *spider_get_trx( trx->trx_ha_hash.array.size_of_element); trx->thd = (THD*) thd; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if (thd) trx->thd_hash_value = my_calc_hash(&spider_allocated_thds, (uchar*) thd, sizeof(THD *)); else trx->thd_hash_value = 0; -#endif pthread_mutex_lock(&spider_thread_id_mutex); trx->spider_thread_id = spider_thread_id; ++spider_thread_id; @@ -1526,13 +1522,11 @@ static int spider_xa_lock( DBUG_ENTER("spider_xa_lock"); #ifdef SPIDER_XID_USES_xid_cache_iterate #else -#ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache, (uchar*) xid_state->xid.key(), xid_state->xid.key_length()); #ifdef XID_CACHE_IS_SPLITTED uint idx = hash_value % *spd_db_att_xid_cache_split_num; #endif -#endif #endif old_proc_info = thd_proc_info(thd, "Locking xid by Spider"); #ifdef SPIDER_XID_USES_xid_cache_iterate @@ -1548,17 +1542,12 @@ static int spider_xa_lock( #else pthread_mutex_lock(spd_db_att_LOCK_xid_cache); #endif -#ifdef SPIDER_HAS_HASH_VALUE_TYPE #ifdef XID_CACHE_IS_SPLITTED if (my_hash_search_using_hash_value(&spd_db_att_xid_cache[idx], hash_value, xid_state->xid.key(), xid_state->xid.key_length())) #else if (my_hash_search_using_hash_value(spd_db_att_xid_cache, hash_value, xid_state->xid.key(), xid_state->xid.key_length())) -#endif -#else - if (my_hash_search(spd_db_att_xid_cache, - xid_state->xid.key(), xid_state->xid.key_length())) #endif { error_num = ER_SPIDER_XA_LOCKED_NUM; @@ -3869,14 +3858,9 @@ SPIDER_TRX_HA *spider_check_trx_ha( link_bitmap_size, which is an indication of a share that has been freed. Delete the trx_ha and return NULL on mismatch. */ -#ifdef SPIDER_HAS_HASH_VALUE_TYPE if ((trx_ha = (SPIDER_TRX_HA *) my_hash_search_using_hash_value( &trx->trx_ha_hash, share->table_name_hash_value, (uchar*) share->table_name, share->table_name_length))) -#else - if ((trx_ha = (SPIDER_TRX_HA *) my_hash_search(&trx->trx_ha_hash, - (uchar*) share->table_name, share->table_name_length))) -#endif { if (trx_ha->share == share && trx_ha->link_count == share->link_count && trx_ha->link_bitmap_size == share->link_bitmap_size) From ba9bebd7194a6bf0145c2dba4dd243baa0826088 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:33:33 +0800 Subject: [PATCH 23/54] MDEV-28892 remove #ifdef SPIDER_Item_args_arg_count_IS_PROTECTED arg_count was protected since 2015 in commit afa17734395f842f728e2539145854d3eb7cd9a8 --- storage/spider/spd_db_oracle.cc | 4 ---- storage/spider/spd_include.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 82216714a25..a4bccda1d71 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -3092,11 +3092,7 @@ int spider_db_oracle_util::open_item_func( { if ( !strncasecmp("rand", func_name, func_name_length) && -#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED !item_func->argument_count() -#else - !item_func->arg_count -#endif ) { if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 9190692223e..a99dc7e96dd 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -90,8 +90,6 @@ #define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #define SPIDER_XID_USES_xid_cache_iterate -#define SPIDER_Item_args_arg_count_IS_PROTECTED - #define SPIDER_Item_func_conv_charset_conv_charset collation.collation #define SPIDER_WITHOUT_HA_STATISTIC_INCREMENT From 64581c83e8c9414cfde39f9405285ba1c93604ab Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:34:30 +0800 Subject: [PATCH 24/54] MDEV-28893 Spider: remove #ifdef SPIDER_NET_HAS_THD net has thd since 2015 in 56aa19989f5800df8a398173727558bfb3ea1251 for MDEV-6152 --- storage/spider/spd_db_mysql.cc | 2 -- storage/spider/spd_environ.h | 1 - 2 files changed, 3 deletions(-) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index c41379e26d5..8fc3f8a6295 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2032,9 +2032,7 @@ int spider_db_mbase::connect( connect_retry_count--; my_sleep((ulong) connect_retry_interval); } else { -#ifdef SPIDER_NET_HAS_THD db_conn->net.thd = NULL; -#endif if (connect_mutex) pthread_mutex_unlock(&spider_open_conn_mutex); break; diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 826362d24c4..356dffcb6da 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -23,7 +23,6 @@ #define SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE -#define SPIDER_NET_HAS_THD #define HANDLER_HAS_TOP_TABLE_FIELDS #define HANDLER_HAS_DIRECT_UPDATE_ROWS From de3dd942c006a2e04f025716aaa2185be3957e64 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:35:05 +0800 Subject: [PATCH 25/54] MDEV-28894 Spider: remove #ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN HA_EXTRA_STARTING_ORDERED_INDEX_SCAN was added latest 2018: 921c5e93145 --- storage/spider/ha_spider.cc | 4 ---- storage/spider/spd_environ.h | 1 - 2 files changed, 5 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index fa6568a9f65..f8e5efc0f55 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1436,10 +1436,7 @@ int ha_spider::extra( if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; -#if defined(HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN) || defined(HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF) -#ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: -#endif #ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF case HA_EXTRA_USE_CMP_REF: #endif @@ -1470,7 +1467,6 @@ int ha_spider::extra( } } break; -#endif default: break; } diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 356dffcb6da..a0810955a91 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -28,7 +28,6 @@ #define HANDLER_HAS_DIRECT_UPDATE_ROWS #define HANDLER_HAS_DIRECT_AGGREGATE #define PARTITION_HAS_GET_PART_SPEC -#define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT From d5d65b948b608b5d1c041a03a4dde27b742e1ad9 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:36:03 +0800 Subject: [PATCH 26/54] MDEV-26178 Spider: remove HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF HA_EXTRA_USE_CMP_REF is undefined, and remains so as of 11.5 c96b23f99409cad9c0dac5040561136211486995 --- storage/spider/ha_spider.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index f8e5efc0f55..24c4f26d732 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1437,9 +1437,6 @@ int ha_spider::extra( DBUG_RETURN(error_num); break; case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: -#ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF - case HA_EXTRA_USE_CMP_REF: -#endif DBUG_PRINT("info",("spider HA_EXTRA_STARTING_ORDERED_INDEX_SCAN")); if (table_share->primary_key != MAX_KEY) { From 0650c87d9bbf76bf4e34355979245dd4d738b86b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:36:48 +0800 Subject: [PATCH 27/54] MDEV-27647 Spider: remove HANDLER_HAS_DIRECT_UPDATE_ROWS --- storage/spider/ha_spider.cc | 75 -------------------------- storage/spider/ha_spider.h | 14 ----- storage/spider/spd_conn.cc | 2 - storage/spider/spd_db_conn.cc | 14 ----- storage/spider/spd_db_conn.h | 6 --- storage/spider/spd_db_include.cc | 2 - storage/spider/spd_db_include.h | 4 -- storage/spider/spd_db_mysql.cc | 8 --- storage/spider/spd_db_mysql.h | 4 -- storage/spider/spd_db_oracle.cc | 2 - storage/spider/spd_db_oracle.h | 2 - storage/spider/spd_environ.h | 1 - storage/spider/spd_group_by_handler.cc | 2 - storage/spider/spd_include.h | 4 -- storage/spider/spd_param.cc | 4 -- 15 files changed, 144 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 24c4f26d732..306e223a16e 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -96,9 +96,7 @@ ha_spider::ha_spider( dml_inited = FALSE; use_pre_call = FALSE; use_pre_action = FALSE; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; synced_from_clone_source = FALSE; @@ -181,9 +179,7 @@ ha_spider::ha_spider( dml_inited = FALSE; use_pre_call = FALSE; use_pre_action = FALSE; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; synced_from_clone_source = FALSE; @@ -793,22 +789,7 @@ void ha_spider::check_access_kind( wide_handler->sql_command = thd_sql_command(thd); DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS wide_handler->update_request = FALSE; -#else - if ( - wide_handler->sql_command == SQLCOM_UPDATE || - wide_handler->sql_command == SQLCOM_UPDATE_MULTI || - /* for triggers */ - wide_handler->sql_command == SQLCOM_INSERT || - wide_handler->sql_command == SQLCOM_INSERT_SELECT || - wide_handler->sql_command == SQLCOM_DELETE || - wide_handler->sql_command == SQLCOM_DELETE_MULTI - ) - wide_handler->update_request = TRUE; - else - wide_handler->update_request = FALSE; -#endif DBUG_VOID_RETURN; } @@ -1263,9 +1244,7 @@ int ha_spider::reset() wide_handler->condition = tmp_cond; } wide_handler->cond_check = FALSE; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS wide_handler->direct_update_fields = NULL; -#endif #ifdef INFO_KIND_FORCE_LIMIT_BEGIN wide_handler->info_limit = 9223372036854775807LL; #endif @@ -1343,9 +1322,7 @@ int ha_spider::reset() ft_count = 0; ft_init_without_index_init = FALSE; sql_kinds = 0; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif prev_index_rnd_init = SPD_NONE; result_list.have_sql_kind_backup = FALSE; result_list.direct_order_limit = FALSE; @@ -1421,11 +1398,9 @@ int ha_spider::extra( case HA_EXTRA_WRITE_CANNOT_REPLACE: wide_handler->write_can_replace = FALSE; break; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS case HA_EXTRA_INSERT_WITH_UPDATE: wide_handler->insert_with_update = TRUE; break; -#endif case HA_EXTRA_ATTACH_CHILDREN: DBUG_PRINT("info",("spider HA_EXTRA_ATTACH_CHILDREN")); if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) @@ -1616,9 +1591,7 @@ int ha_spider::index_read_map_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ( find_flag >= HA_READ_MBR_CONTAIN && find_flag <= HA_READ_MBR_EQUAL @@ -2088,9 +2061,7 @@ int ha_spider::index_read_last_map_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = index_handler_init())) DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) @@ -2546,9 +2517,7 @@ int ha_spider::index_first_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = index_handler_init())) DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) @@ -2920,9 +2889,7 @@ int ha_spider::index_last_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = index_handler_init())) DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) @@ -3347,9 +3314,7 @@ int ha_spider::read_range_first_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ( start_key && start_key->flag >= HA_READ_MBR_CONTAIN && @@ -3935,9 +3900,7 @@ int ha_spider::read_multi_range_first_internal( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = index_handler_init())) DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) @@ -6809,9 +6772,7 @@ int ha_spider::rnd_next_internal( /* do not copy table data at alter table */ if (wide_handler->sql_command == SQLCOM_ALTER_TABLE) DBUG_RETURN(HA_ERR_END_OF_FILE); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if (rnd_scan_and_first) { @@ -9274,12 +9235,8 @@ int ha_spider::write_row( DBUG_RETURN(check_error_mode(error_num)); if (bulk_insert) bulk_size = -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS (wide_handler->insert_with_update && !result_list.insert_dup_update_pushdown) || -#else - wide_handler->insert_with_update || -#endif (!direct_dup_insert && wide_handler->ignore_dup_key) ? 0 : spider_param_bulk_size(wide_handler->trx->thd, share->bulk_size); else @@ -9318,7 +9275,6 @@ int ha_spider::pre_write_row( } #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS void ha_spider::direct_update_init( THD *thd, bool hs_request @@ -9328,7 +9284,6 @@ void ha_spider::direct_update_init( do_direct_update = TRUE; DBUG_VOID_RETURN; } -#endif bool ha_spider::start_bulk_update( ) { @@ -9424,9 +9379,7 @@ int ha_spider::update_row( #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_update_count); #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = spider_db_update(this, table, old_data))) DBUG_RETURN(check_error_mode(error_num)); if (table->found_next_number_field && @@ -9470,7 +9423,6 @@ int ha_spider::update_row( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool ha_spider::check_direct_update_sql_part( st_select_lex *select_lex, longlong select_limit, @@ -10006,7 +9958,6 @@ int ha_spider::pre_direct_update_rows() } #endif #endif -#endif bool ha_spider::start_bulk_delete( ) { @@ -10056,15 +10007,12 @@ int ha_spider::delete_row( #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_delete_count); #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif if ((error_num = spider_db_delete(this, table, buf))) DBUG_RETURN(check_error_mode(error_num)); DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool ha_spider::check_direct_delete_sql_part( st_select_lex *select_lex, longlong select_limit, @@ -10451,7 +10399,6 @@ int ha_spider::pre_direct_delete_rows() } #endif #endif -#endif int ha_spider::delete_all_rows() { @@ -10480,9 +10427,7 @@ int ha_spider::truncate() { DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif sql_kinds = SPIDER_SQL_KIND_SQL; for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; @@ -11453,8 +11398,6 @@ int ha_spider::info_push( #endif #ifdef HA_CAN_BULK_ACCESS if ( -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#endif info_type != INFO_KIND_BULK_ACCESS_BEGIN && info_type != INFO_KIND_BULK_ACCESS_CURRENT && info_type != INFO_KIND_BULK_ACCESS_END @@ -11476,10 +11419,8 @@ int ha_spider::info_push( } #endif -#if defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) || defined(HA_CAN_BULK_ACCESS) switch (info_type) { -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef INFO_KIND_UPDATE_FIELDS case INFO_KIND_UPDATE_FIELDS: DBUG_PRINT("info",("spider INFO_KIND_UPDATE_FIELDS")); @@ -11507,7 +11448,6 @@ int ha_spider::info_push( wide_handler->info_limit = 9223372036854775807LL; break; #endif -#endif #ifdef HA_CAN_BULK_ACCESS case INFO_KIND_BULK_ACCESS_BEGIN: DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_BEGIN")); @@ -11570,7 +11510,6 @@ int ha_spider::info_push( default: break; } -#endif DBUG_RETURN(error_num); } @@ -12379,9 +12318,7 @@ int ha_spider::index_handler_init() roop_end = search_link_idx + 1; } sql_kinds = 0; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS direct_update_kinds = 0; -#endif for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -12467,9 +12404,7 @@ int ha_spider::rnd_handler_init() roop_end = search_link_idx + 1; } sql_kinds = 0; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS direct_update_kinds = 0; -#endif for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -12695,7 +12630,6 @@ void ha_spider::check_pre_call( DBUG_VOID_RETURN; } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS void ha_spider::check_insert_dup_update_pushdown() { THD *thd = wide_handler->trx->thd; @@ -12714,7 +12648,6 @@ void ha_spider::check_insert_dup_update_pushdown() } DBUG_VOID_RETURN; } -#endif #ifdef HA_CAN_BULK_ACCESS SPIDER_BULK_ACCESS_LINK *ha_spider::create_bulk_access_link() @@ -12848,8 +12781,6 @@ int ha_spider::sync_from_clone_source( external_lock_cnt = spider->external_lock_cnt; } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#endif DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", dbton_handler)); DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", @@ -13132,7 +13063,6 @@ int ha_spider::append_update_set_sql_part() DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int ha_spider::append_direct_update_set_sql_part() { int error_num; @@ -13153,9 +13083,7 @@ int ha_spider::append_direct_update_set_sql_part() DBUG_RETURN(0); } -#endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int ha_spider::append_dup_update_pushdown_sql_part( const char *alias, uint alias_length @@ -13221,7 +13149,6 @@ int ha_spider::check_update_columns_sql_part() } DBUG_RETURN(0); } -#endif int ha_spider::append_delete_sql_part() { @@ -15030,12 +14957,10 @@ int ha_spider::dml_init() conns[roop_count]->semi_trx_isolation = -1; } } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (wide_handler->insert_with_update) { check_insert_dup_update_pushdown(); } -#endif dml_inited = TRUE; DBUG_RETURN(0); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 1bde115de6c..da1e5fd2df4 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -175,10 +175,8 @@ public: corresponding m_handler_cid is t00003 */ char **m_handler_cid; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool do_direct_update; uint direct_update_kinds; -#endif spider_index_rnd_init prev_index_rnd_init; #ifdef HANDLER_HAS_DIRECT_AGGREGATE SPIDER_ITEM_HLD *direct_aggregate_item_first; @@ -494,12 +492,10 @@ public: uchar *buf ); #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS void direct_update_init( THD *thd, bool hs_request ); -#endif bool start_bulk_update() override; int exec_bulk_update( ha_rows *dup_key_found @@ -526,7 +522,6 @@ public: uchar *new_data ); #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool check_direct_update_sql_part( st_select_lex *select_lex, longlong select_limit, @@ -648,14 +643,12 @@ public: #else int pre_direct_update_rows(); #endif -#endif #endif bool start_bulk_delete() override; int end_bulk_delete() override; int delete_row( const uchar *buf ) override; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool check_direct_delete_sql_part( st_select_lex *select_lex, longlong select_limit, @@ -724,7 +717,6 @@ public: #else int pre_direct_delete_rows(); #endif -#endif #endif int delete_all_rows() override; int truncate() override; @@ -895,9 +887,7 @@ public: void check_pre_call( bool use_parallel ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS void check_insert_dup_update_pushdown(); -#endif #ifdef HA_CAN_BULK_ACCESS SPIDER_BULK_ACCESS_LINK *create_bulk_access_link(); void delete_bulk_access_link( @@ -926,10 +916,7 @@ public: int append_insert_sql_part(); int append_update_sql_part(); int append_update_set_sql_part(); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_direct_update_set_sql_part(); -#endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_dup_update_pushdown_sql_part( const char *alias, uint alias_length @@ -939,7 +926,6 @@ public: uint alias_length ); int check_update_columns_sql_part(); -#endif int append_delete_sql_part(); int append_select_sql_part( ulong sql_type diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 5912a2336d0..6b3d90bea3d 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -4100,7 +4100,6 @@ bool spider_conn_use_handler( DBUG_PRINT("info",("spider use_handler=%d", use_handler)); DBUG_PRINT("info",("spider spider->conn_kind[link_idx]=%u", spider->conn_kind[link_idx])); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (spider->do_direct_update) { spider->sql_kinds |= SPIDER_SQL_KIND_SQL; @@ -4109,7 +4108,6 @@ bool spider_conn_use_handler( DBUG_PRINT("info",("spider FALSE by using direct_update")); DBUG_RETURN(FALSE); } -#endif if (spider->use_spatial_index) { DBUG_PRINT("info",("spider FALSE by use_spatial_index")); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 7ecd356873b..dd253822626 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -6908,7 +6908,6 @@ int spider_db_update( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_update( ha_spider *spider, @@ -6956,17 +6955,14 @@ int spider_db_direct_update( (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) */ -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (!spider->do_direct_update) { -#endif if ( (spider->sql_kinds & SPIDER_SQL_KIND_SQL) && (error_num = spider->append_update_set_sql_part()) ) { DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS } else { if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && @@ -6975,7 +6971,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } } -#endif result_list->desc_flg = FALSE; result_list->sorted = TRUE; @@ -7171,17 +7166,14 @@ int spider_db_direct_update( spider->wide_handler->direct_update_fields */ -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (!spider->do_direct_update) { -#endif if ( (spider->sql_kinds & SPIDER_SQL_KIND_SQL) && (error_num = spider->append_update_set_sql_part()) ) { DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS } else { if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && @@ -7190,7 +7182,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } } -#endif result_list->desc_flg = FALSE; result_list->sorted = TRUE; @@ -7351,7 +7342,6 @@ int spider_db_direct_update( DBUG_RETURN(0); } #endif -#endif #ifdef HA_CAN_BULK_ACCESS int spider_db_bulk_direct_update( @@ -7491,7 +7481,6 @@ int spider_db_delete( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_delete( ha_spider *spider, @@ -7858,7 +7847,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num2); } #endif -#endif int spider_db_delete_all_rows( ha_spider *spider @@ -9506,7 +9494,6 @@ int spider_db_append_condition( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int spider_db_append_update_columns( ha_spider *spider, spider_string *str, @@ -9561,7 +9548,6 @@ int spider_db_append_update_columns( str->length(str->length() - SPIDER_SQL_COMMA_LEN); DBUG_RETURN(0); } -#endif #ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_db_check_select_colum_in_group( diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index bae4ee35439..5b8dc65b262 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -799,7 +799,6 @@ int spider_db_update( const uchar *old_data ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_update( ha_spider *spider, @@ -817,7 +816,6 @@ int spider_db_direct_update( ha_rows *found_rows ); #endif -#endif #ifdef HA_CAN_BULK_ACCESS int spider_db_bulk_direct_update( @@ -838,7 +836,6 @@ int spider_db_delete( const uchar *buf ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_delete( ha_spider *spider, @@ -854,7 +851,6 @@ int spider_db_direct_delete( ha_rows *delete_rows ); #endif -#endif int spider_db_delete_all_rows( ha_spider *spider @@ -1056,7 +1052,6 @@ int spider_db_append_condition( bool test_flg ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int spider_db_append_update_columns( ha_spider *spider, spider_string *str, @@ -1066,7 +1061,6 @@ int spider_db_append_update_columns( bool use_fields, spider_fields *fields ); -#endif #ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_db_check_select_colum_in_group( diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc index 4a422e0e1f2..16a449e94cc 100644 --- a/storage/spider/spd_db_include.cc +++ b/storage/spider/spd_db_include.cc @@ -154,7 +154,6 @@ int spider_db_handler::checksum_table( } #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool spider_db_handler::check_direct_update( st_select_lex *select_lex, longlong select_limit, @@ -188,4 +187,3 @@ bool spider_db_handler::check_direct_delete( } DBUG_RETURN(FALSE); } -#endif diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 32cefbaa258..0d080249d62 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1188,7 +1188,6 @@ public: virtual int append_update_part() = 0; virtual int append_delete_part() = 0; virtual int append_update_set_part() = 0; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS virtual int append_direct_update_set_part() = 0; virtual int append_dup_update_pushdown_part( const char *alias, @@ -1199,7 +1198,6 @@ public: uint alias_length ) = 0; virtual int check_update_columns_part() = 0; -#endif virtual int append_select_part( ulong sql_type ) = 0; @@ -1591,7 +1589,6 @@ public: ulong sql_type ) = 0; #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS virtual bool check_direct_update( st_select_lex *select_lex, longlong select_limit, @@ -1602,7 +1599,6 @@ public: longlong select_limit, longlong offset_limit ); -#endif }; class spider_db_copy_table diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 8fc3f8a6295..54ad30cebd2 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -9167,11 +9167,7 @@ int spider_mbase_handler::append_insert( spider->wide_handler->ignore_dup_key && spider->direct_dup_insert && !spider->wide_handler->write_can_replace && -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS (!spider->wide_handler->insert_with_update || !dup_update_sql.length()) && -#else - !spider->wide_handler->insert_with_update && -#endif /* for direct_dup_insert without patch for partition */ spider->wide_handler->sql_command != SQLCOM_REPLACE && spider->wide_handler->sql_command != SQLCOM_REPLACE_SELECT @@ -9329,7 +9325,6 @@ int spider_mbase_handler::append_update_set( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int spider_mbase_handler::append_direct_update_set_part() { int error_num; @@ -9406,7 +9401,6 @@ int spider_mbase_handler::append_update_columns( alias, alias_length, dbton_id, FALSE, NULL); DBUG_RETURN(error_num); } -#endif int spider_mbase_handler::append_select_part( ulong sql_type @@ -15721,7 +15715,6 @@ int spider_mbase_handler::append_order_by( } #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool spider_mbase_handler::check_direct_update( st_select_lex *select_lex, longlong select_limit, @@ -15741,7 +15734,6 @@ bool spider_mbase_handler::check_direct_delete( DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(FALSE); } -#endif spider_mbase_copy_table::spider_mbase_copy_table( spider_mbase_share *db_share diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 9d86b837b32..dcc35290103 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -858,7 +858,6 @@ public: int append_update_set( spider_string *str ); - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_direct_update_set_part() override; int append_direct_update_set( spider_string *str @@ -877,7 +876,6 @@ public: const char *alias, uint alias_length ); - #endif int append_select_part( ulong sql_type ) override; @@ -1555,7 +1553,6 @@ public: spider_fields *fields ); #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool check_direct_update( st_select_lex *select_lex, longlong select_limit, @@ -1566,7 +1563,6 @@ public: longlong select_limit, longlong offset_limit ) override; -#endif }; class spider_mysql_handler: public spider_mbase_handler diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index a4bccda1d71..e0ef42793c2 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -6329,7 +6329,6 @@ int spider_oracle_handler::append_update_set( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int spider_oracle_handler::append_direct_update_set_part() { int error_num; @@ -6446,7 +6445,6 @@ int spider_oracle_handler::append_update_columns( DBUG_RETURN(error_num); */ } -#endif int spider_oracle_handler::append_select_part( ulong sql_type diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index f9eff649692..8acffb5c150 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -743,7 +743,6 @@ public: int append_update_set( spider_string *str ); - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_direct_update_set_part(); int append_direct_update_set( spider_string *str @@ -762,7 +761,6 @@ public: const char *alias, uint alias_length ); - #endif int append_select_part( ulong sql_type ); diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index a0810955a91..fbadb270f1f 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -25,7 +25,6 @@ #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define HANDLER_HAS_TOP_TABLE_FIELDS -#define HANDLER_HAS_DIRECT_UPDATE_ROWS #define HANDLER_HAS_DIRECT_AGGREGATE #define PARTITION_HAS_GET_PART_SPEC #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 953802b7a5f..37bfc7ea8a7 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1033,10 +1033,8 @@ static int spider_prepare_init_scan( for (link_idx = 0; link_idx < (int) share->link_count; ++link_idx) spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS spider->do_direct_update = FALSE; spider->direct_update_kinds = 0; -#endif spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); direct_order_limit = spider_param_direct_order_limit(thd, share->direct_order_limit); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index a99dc7e96dd..12320f73742 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -880,10 +880,8 @@ typedef struct st_spider_wide_handler #ifdef WITH_PARTITION_STORAGE_ENGINE SPIDER_PARTITION_HANDLER *partition_handler; #endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS List *direct_update_fields; List *direct_update_values; -#endif TABLE_SHARE *top_share; enum thr_lock_type lock_type; uchar lock_table_type; @@ -892,11 +890,9 @@ typedef struct st_spider_wide_handler int cond_check_error; uint sql_command; uint top_table_fields; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef INFO_KIND_FORCE_LIMIT_BEGIN longlong info_limit; #endif -#endif #ifdef HA_CAN_BULK_ACCESS ulonglong external_lock_cnt; #endif diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 12080cc2a27..371dd1215c9 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -109,7 +109,6 @@ extern volatile ulonglong spider_mon_table_cache_version_req; MYSQL_SYSVAR_NAME(param_name).def_val; \ } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS static int spider_direct_update(THD *thd, SHOW_VAR *var, void *, system_status_var *, enum_var_type) { @@ -133,7 +132,6 @@ static int spider_direct_delete(THD *thd, SHOW_VAR *var, void *, var->value = (char *) &trx->direct_delete_count; DBUG_RETURN(error_num); } -#endif static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, void *, system_status_var *, enum_var_type) @@ -178,7 +176,6 @@ struct st_mysql_show_var spider_status_variables[] = (char *) &spider_mon_table_cache_version, SHOW_LONGLONG}, {"Spider_mon_table_cache_version_req", (char *) &spider_mon_table_cache_version_req, SHOW_LONGLONG}, -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS #ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC {"Spider_direct_update", (char *) &spider_direct_update, SHOW_SIMPLE_FUNC}, {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_SIMPLE_FUNC}, @@ -186,7 +183,6 @@ struct st_mysql_show_var spider_status_variables[] = {"Spider_direct_update", (char *) &spider_direct_update, SHOW_FUNC}, {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_FUNC}, #endif -#endif #ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC {"Spider_direct_order_limit", (char *) &spider_direct_order_limit, SHOW_SIMPLE_FUNC}, From f16c037753eb23a31ed56c3ff56c95192b481870 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:37:51 +0800 Subject: [PATCH 28/54] MDEV-28895 Spider: remove #ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT handler has can_use_for_auto_inc_init() since at latest 2017: dc17ac1638ef67b5dc5956d7e4ef802b6b37fbe9 --- storage/spider/ha_spider.cc | 8 -------- storage/spider/ha_spider.h | 4 ---- storage/spider/spd_environ.h | 1 - 3 files changed, 13 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 306e223a16e..55e2f68edaa 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -7764,9 +7764,7 @@ int ha_spider::info( DBUG_ENTER("ha_spider::info"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider flag=%x", flag)); -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT auto_inc_temporary = FALSE; -#endif wide_handler->sql_command = thd_sql_command(thd); /* if ( @@ -7782,9 +7780,7 @@ int ha_spider::info( share->lgtm_tblhnd_share->auto_increment_value; else { stats.auto_increment_value = 1; -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT auto_inc_temporary = TRUE; -#endif } } if ( @@ -8059,9 +8055,7 @@ int ha_spider::info( } if (flag & HA_STATUS_AUTO) { -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT auto_inc_temporary = FALSE; -#endif if (share->wide_share && table->next_number_field) { ulonglong first_value, nb_reserved_values; @@ -8928,7 +8922,6 @@ bool ha_spider::need_info_for_auto_inc() } #endif -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT bool ha_spider::can_use_for_auto_inc_init() { DBUG_ENTER("ha_spider::can_use_for_auto_inc_init"); @@ -8940,7 +8933,6 @@ bool ha_spider::can_use_for_auto_inc_init() !auto_inc_temporary )); } -#endif int ha_spider::update_auto_increment() { diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index da1e5fd2df4..572d23af299 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -150,9 +150,7 @@ public: #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool info_auto_called; #endif -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT bool auto_inc_temporary; -#endif int bulk_size= 0; int direct_dup_insert; int store_error_num; @@ -458,9 +456,7 @@ public: #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool need_info_for_auto_inc() override; #endif -#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT bool can_use_for_auto_inc_init() override; -#endif int update_auto_increment(); void get_auto_increment( ulonglong offset, diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index fbadb270f1f..8b6eac67e7a 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -28,7 +28,6 @@ #define HANDLER_HAS_DIRECT_AGGREGATE #define PARTITION_HAS_GET_PART_SPEC #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC -#define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT #define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA From aaba68ac1ec9c5bea70df4dcfa4f4d4c8cc3d09d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:41:53 +0800 Subject: [PATCH 29/54] MDEV-28896 Spider: remove #ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA new_data is const since at least 2017: a05a610d60a --- storage/spider/ha_spider.cc | 15 --------------- storage/spider/ha_spider.h | 12 ------------ storage/spider/spd_environ.h | 2 -- 3 files changed, 29 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 55e2f68edaa..90c004cfd0b 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -9311,19 +9311,11 @@ int ha_spider::end_bulk_update( DBUG_RETURN(0); } -#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int ha_spider::bulk_update_row( const uchar *old_data, const uchar *new_data, ha_rows *dup_key_found ) -#else -int ha_spider::bulk_update_row( - const uchar *old_data, - uchar *new_data, - ha_rows *dup_key_found -) -#endif { DBUG_ENTER("ha_spider::bulk_update_row"); DBUG_PRINT("info",("spider this=%p", this)); @@ -9331,17 +9323,10 @@ int ha_spider::bulk_update_row( DBUG_RETURN(update_row(old_data, new_data)); } -#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int ha_spider::update_row( const uchar *old_data, const uchar *new_data ) -#else -int ha_spider::update_row( - const uchar *old_data, - uchar *new_data -) -#endif { int error_num; THD *thd = ha_thd(); diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 572d23af299..535724606ff 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -497,7 +497,6 @@ public: ha_rows *dup_key_found ) override; int end_bulk_update() override; -#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA int bulk_update_row( const uchar *old_data, const uchar *new_data, @@ -507,17 +506,6 @@ public: const uchar *old_data, const uchar *new_data ) override; -#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 bool check_direct_update_sql_part( st_select_lex *select_lex, longlong select_limit, diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 8b6eac67e7a..26da35b792f 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -29,8 +29,6 @@ #define PARTITION_HAS_GET_PART_SPEC #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC -#define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA - #define SPIDER_MDEV_16246 #define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM From 1cb75d9a33ad8d36832cdac4ebc0aec4448c6796 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:42:10 +0800 Subject: [PATCH 30/54] MDEV-27660 Remove #ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS The flag argument was added to handler::start_bulk_insert() in the MDEV-539 commit ca2cdaad86750509764256ff8086e031b4870b24 --- storage/spider/ha_spider.cc | 6 ------ storage/spider/ha_spider.h | 6 ------ storage/spider/spd_environ.h | 2 -- 3 files changed, 14 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 90c004cfd0b..4296a00e196 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -9075,16 +9075,10 @@ void ha_spider::release_auto_increment() DBUG_VOID_RETURN; } -#ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS void ha_spider::start_bulk_insert( ha_rows rows, uint flags ) -#else -void ha_spider::start_bulk_insert( - ha_rows rows -) -#endif { DBUG_ENTER("ha_spider::start_bulk_insert"); DBUG_PRINT("info",("spider this=%p", this)); diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 535724606ff..d2d6c911e3c 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -469,16 +469,10 @@ public: ulonglong value ) override; void release_auto_increment() override; -#ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS void start_bulk_insert( ha_rows rows, uint flags ) override; -#else - void start_bulk_insert( - ha_rows rows - ); -#endif int end_bulk_insert() override; int write_row( const uchar *buf diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 26da35b792f..2501e55a2e9 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -20,8 +20,6 @@ #ifndef SPD_ENVIRON_INCLUDED -#define SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS - #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define HANDLER_HAS_TOP_TABLE_FIELDS From 6d0d09ebc2a95c0adfa9baf494b1a456c697f27b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:42:25 +0800 Subject: [PATCH 31/54] MDEV-26178 Spider: remove HANDLER_HAS_TOP_TABLE_FIELDS This macro is unused --- storage/spider/spd_environ.h | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 2501e55a2e9..6eb1313bb00 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -22,7 +22,6 @@ #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE -#define HANDLER_HAS_TOP_TABLE_FIELDS #define HANDLER_HAS_DIRECT_AGGREGATE #define PARTITION_HAS_GET_PART_SPEC #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC From affcb0713d47b2603aaefbe746d89ce434b9ecb0 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:42:36 +0800 Subject: [PATCH 32/54] MDEV-26178 spider: remove PARTITION_HAS_GET_PART_SPEC This macro is unused, and not in 11.5 c96b23f99409cad9c0dac5040561136211486995 --- storage/spider/spd_environ.h | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 6eb1313bb00..4944aa268c9 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -23,7 +23,6 @@ #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define HANDLER_HAS_DIRECT_AGGREGATE -#define PARTITION_HAS_GET_PART_SPEC #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #define SPIDER_MDEV_16246 From 8c8684b17f40f613773daa69cb171181cd69d903 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:42:50 +0800 Subject: [PATCH 33/54] MDEV-28226 Remove HANDLER_HAS_NEED_INFO_FOR_AUTO_INC handler::need_info_for_auto_inc() was added in MDEV-7720 / MDEV-7726 in commit dc17ac1638ef67b5dc5956d7e4ef802b6b37fbe9 --- storage/spider/ha_spider.cc | 4 ---- storage/spider/ha_spider.h | 4 ---- storage/spider/spd_environ.h | 1 - 3 files changed, 9 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 4296a00e196..06a1f227771 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -7805,9 +7805,7 @@ int ha_spider::info( { tmp_auto_increment_mode = spider_param_auto_increment_mode(thd, share->auto_increment_mode); -#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC info_auto_called = TRUE; -#endif } if (!share->sts_init) { @@ -8899,7 +8897,6 @@ uint8 ha_spider::table_cache_type() DBUG_RETURN(HA_CACHE_TBL_NOCACHE); } -#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool ha_spider::need_info_for_auto_inc() { THD *thd = ha_thd(); @@ -8920,7 +8917,6 @@ bool ha_spider::need_info_for_auto_inc() ) )); } -#endif bool ha_spider::can_use_for_auto_inc_init() { diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index d2d6c911e3c..20db5349f68 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -147,9 +147,7 @@ public: bool use_pre_action; bool pre_bitmap_checked; bool bulk_insert; -#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool info_auto_called; -#endif bool auto_inc_temporary; int bulk_size= 0; int direct_dup_insert; @@ -453,9 +451,7 @@ public: uint max_supported_key_length() const override; uint max_supported_key_part_length() const override; uint8 table_cache_type() override; -#ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC bool need_info_for_auto_inc() override; -#endif bool can_use_for_auto_inc_init() override; int update_auto_increment(); void get_auto_increment( diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 4944aa268c9..34670a32ee3 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -23,7 +23,6 @@ #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define HANDLER_HAS_DIRECT_AGGREGATE -#define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #define SPIDER_MDEV_16246 From 5e98471df131a327b027d4b5976c9ca4b1cf4684 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:43:05 +0800 Subject: [PATCH 34/54] MDEV-27811: remove SPIDER_MDEV_16246 MDEV-16246 was fixed long ago. And this macro was removed in other versions too --- storage/spider/ha_spider.cc | 57 ------------------------------------ storage/spider/ha_spider.h | 36 ----------------------- storage/spider/spd_environ.h | 2 -- 3 files changed, 95 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 06a1f227771..a1d734eced8 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -9413,7 +9413,6 @@ bool ha_spider::check_direct_update_sql_part( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 int ha_spider::direct_update_rows_init( List *update_fields, uint mode, @@ -9422,15 +9421,6 @@ int ha_spider::direct_update_rows_init( bool sorted, uchar *new_data ) -#else -int ha_spider::direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#endif { st_select_lex *select_lex; longlong select_limit; @@ -9455,13 +9445,8 @@ int ha_spider::direct_update_rows_init( pre_direct_init_result)); DBUG_RETURN(pre_direct_init_result); } -#ifdef SPIDER_MDEV_16246 DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( update_fields, mode, ranges, range_count, sorted, new_data)); -#else - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( - mode, ranges, range_count, sorted, new_data)); -#endif } #endif if (!dml_inited) @@ -9538,7 +9523,6 @@ int ha_spider::direct_update_rows_init( DBUG_RETURN(HA_ERR_WRONG_COMMAND); } #else -#ifdef SPIDER_MDEV_16246 /** Perform initialization for a direct update request. @@ -9551,9 +9535,6 @@ int ha_spider::direct_update_rows_init( int ha_spider::direct_update_rows_init( List *update_fields ) -#else -int ha_spider::direct_update_rows_init() -#endif { st_select_lex *select_lex; longlong select_limit; @@ -9602,12 +9583,8 @@ int ha_spider::direct_update_rows_init() pre_direct_init_result)); DBUG_RETURN(pre_direct_init_result); } -#ifdef SPIDER_MDEV_16246 DBUG_RETURN(bulk_access_link_exec_tgt->spider-> direct_update_rows_init(update_fields)); -#else - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init()); -#endif } #endif if (!dml_inited) @@ -9682,7 +9659,6 @@ int ha_spider::direct_update_rows_init() #ifdef HA_CAN_BULK_ACCESS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 int ha_spider::pre_direct_update_rows_init( List *update_fields, uint mode, @@ -9691,30 +9667,15 @@ int ha_spider::pre_direct_update_rows_init( bool sorted, uchar *new_data ) -#else -int ha_spider::pre_direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#endif { int error_num; DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); if (bulk_access_started) { -#ifdef SPIDER_MDEV_16246 error_num = bulk_access_link_current->spider-> pre_direct_update_rows_init( update_fields, mode, ranges, range_count, sorted, new_data); -#else - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init( - mode, ranges, range_count, sorted, new_data); -#endif bulk_access_link_current->spider->bulk_access_pre_called = TRUE; bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); @@ -9726,17 +9687,11 @@ int ha_spider::pre_direct_update_rows_init( DBUG_RETURN(error_num); } } -#ifdef SPIDER_MDEV_16246 pre_direct_init_result = direct_update_rows_init( update_fields, mode, ranges, range_count, sorted, new_data); -#else - pre_direct_init_result = direct_update_rows_init( - mode, ranges, range_count, sorted, new_data); -#endif DBUG_RETURN(pre_direct_init_result); } #else -#ifdef SPIDER_MDEV_16246 /** Do initialization for performing parallel direct update for a handlersocket update request. @@ -9750,22 +9705,14 @@ int ha_spider::pre_direct_update_rows_init( int ha_spider::pre_direct_update_rows_init( List *update_fields ) -#else -int ha_spider::pre_direct_update_rows_init() -#endif { int error_num; DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); if (bulk_access_started) { -#ifdef SPIDER_MDEV_16246 error_num = bulk_access_link_current->spider-> pre_direct_update_rows_init(update_fields); -#else - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init(); -#endif bulk_access_link_current->spider->bulk_access_pre_called = TRUE; bulk_access_link_current->called = TRUE; DBUG_RETURN(error_num); @@ -9777,11 +9724,7 @@ int ha_spider::pre_direct_update_rows_init() DBUG_RETURN(error_num); } } -#ifdef SPIDER_MDEV_16246 pre_direct_init_result = direct_update_rows_init(update_fields); -#else - pre_direct_init_result = direct_update_rows_init(); -#endif DBUG_RETURN(pre_direct_init_result); } #endif diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 20db5349f68..995a5f0281c 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -502,7 +502,6 @@ public: longlong offset_limit ); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 inline int direct_update_rows_init( List *update_fields ) { @@ -517,30 +516,12 @@ public: 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 SPIDER_MDEV_16246 int direct_update_rows_init( List *update_fields ) override; -#else - int direct_update_rows_init(); -#endif #endif #ifdef HA_CAN_BULK_ACCESS #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 inline int pre_direct_update_rows_init( List *update_fields ) { @@ -555,26 +536,9 @@ public: uchar *new_data ); #else - inline int pre_direct_update_rows_init() - { - return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL); - } - int pre_direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#endif -#else -#ifdef SPIDER_MDEV_16246 int pre_direct_update_rows_init( List *update_fields ); -#else - int pre_direct_update_rows_init(); -#endif #endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 34670a32ee3..547a487af33 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -24,8 +24,6 @@ #define HANDLER_HAS_DIRECT_AGGREGATE -#define SPIDER_MDEV_16246 - #define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM #define SPIDER_SQL_CACHE_IS_IN_LEX #define SPIDER_LIKE_FUNC_HAS_GET_NEGATED From a1e5ee911170a608f2ad8ae94b7fef66640a0d3e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:43:28 +0800 Subject: [PATCH 35/54] MDEV-27663 remove SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM {STRING|INT|REAL|DECIMAL|DATE}_ITEM were replaced with CONST_ITEM in MDEV-14630 c20cd68e60465f43266fe2bc2b2190e7c1cc4983 --- storage/spider/spd_db_conn.cc | 11 ----------- storage/spider/spd_environ.h | 1 - 2 files changed, 12 deletions(-) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index dd253822626..48ac9264af8 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -8573,7 +8573,6 @@ int spider_db_print_item_type( case Item::ROW_ITEM: DBUG_RETURN(spider_db_open_item_row((Item_row *) item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); -#ifdef SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM case Item::CONST_ITEM: { switch (item->cmp_type()) { @@ -8591,16 +8590,6 @@ int spider_db_print_item_type( DBUG_RETURN(spider_db_print_item_type_default(item, spider, str)); } } -#else - case Item::STRING_ITEM: - DBUG_RETURN(spider_db_open_item_string(item, field, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item::INT_ITEM: - case Item::REAL_ITEM: - case Item::DECIMAL_ITEM: - DBUG_RETURN(spider_db_open_item_int(item, field, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); -#endif case Item::CACHE_ITEM: DBUG_RETURN(spider_db_open_item_cache((Item_cache *) item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields)); diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 547a487af33..2ca5c62a3e2 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -24,7 +24,6 @@ #define HANDLER_HAS_DIRECT_AGGREGATE -#define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM #define SPIDER_SQL_CACHE_IS_IN_LEX #define SPIDER_LIKE_FUNC_HAS_GET_NEGATED #define HA_HAS_CHECKSUM_EXTENDED From ab49b46d0148640d843391e8acc811e51636c316 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:46:46 +0800 Subject: [PATCH 36/54] MDEV-27664 remove SPIDER_SQL_CACHE_IS_IN_LEX sql_cache was moved to lex in MDEV-11953 in de745ecf29721795710910a19bd0ea3389da804c --- storage/spider/ha_spider.cc | 4 ---- storage/spider/spd_db_mysql.cc | 13 ------------- storage/spider/spd_environ.h | 1 - 3 files changed, 18 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index a1d734eced8..ac383bbc4f2 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -12506,11 +12506,7 @@ void ha_spider::check_pre_call( ) || ( (skip_parallel_search & 2) && -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_NO_CACHE // for mysqldump -#else - select_lex && select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE // for mysqldump -#endif ) ) { use_pre_call = FALSE; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 54ad30cebd2..4d57a8d41de 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -9450,29 +9450,16 @@ int spider_mbase_handler::append_select( wide_handler->lock_mode < 1) { /* no lock */ -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX LEX *lex = wide_handler->trx->thd->lex; -#else - st_select_lex *select_lex = - &wide_handler->trx->thd->lex->select_lex; -#endif if ( -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_CACHE && -#else - select_lex->sql_cache == SELECT_LEX::SQL_CACHE && -#endif (spider->share->query_cache_sync & 1) ) { if (str->reserve(SPIDER_SQL_SQL_CACHE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_SQL_CACHE_STR, SPIDER_SQL_SQL_CACHE_LEN); } else if ( -#ifdef SPIDER_SQL_CACHE_IS_IN_LEX lex->sql_cache == LEX::SQL_NO_CACHE && -#else - select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE && -#endif (spider->share->query_cache_sync & 2) ) { if (str->reserve(SPIDER_SQL_SQL_NO_CACHE_LEN)) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 2ca5c62a3e2..9de99b8f4b5 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -24,7 +24,6 @@ #define HANDLER_HAS_DIRECT_AGGREGATE -#define SPIDER_SQL_CACHE_IS_IN_LEX #define SPIDER_LIKE_FUNC_HAS_GET_NEGATED #define HA_HAS_CHECKSUM_EXTENDED From e8a5553cefd0c5c16939409633f5dec75baa6b08 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:47:07 +0800 Subject: [PATCH 37/54] MDEV-27808 remove SPIDER_LIKE_FUNC_HAS_GET_NEGATED get_negated() was introduced in MDEV-16707 --- storage/spider/spd_db_oracle.cc | 4 ---- storage/spider/spd_environ.h | 1 - 2 files changed, 5 deletions(-) diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index e0ef42793c2..f390e5d80fb 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -4094,7 +4094,6 @@ int spider_db_oracle_util::open_item_func( } break; case Item_func::LIKE_FUNC: -#ifdef SPIDER_LIKE_FUNC_HAS_GET_NEGATED if (str) { if (((Item_func_like *)item_func)->get_negated()) @@ -4109,9 +4108,6 @@ int spider_db_oracle_util::open_item_func( } } break; -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif default: THD *thd = spider->wide_handler->trx->thd; SPIDER_SHARE *share = spider->share; diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 9de99b8f4b5..faf32019824 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -24,7 +24,6 @@ #define HANDLER_HAS_DIRECT_AGGREGATE -#define SPIDER_LIKE_FUNC_HAS_GET_NEGATED #define HA_HAS_CHECKSUM_EXTENDED #define SPIDER_I_S_USE_SHOW_FOR_COLUMN From 6287fb6e1749cf471dec75f3cf2400bd879765f8 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:47:18 +0800 Subject: [PATCH 38/54] MDEV-27652 remove #ifdef HA_HAS_CHECKSUM_EXTENDED handler::pre_calculate_checksum was added in MDEV-16249 be5c432a42eed10535354f31dfd6daa07095e555 --- storage/spider/ha_spider.cc | 2 -- storage/spider/ha_spider.h | 4 ---- storage/spider/spd_conn.h | 2 -- storage/spider/spd_db_conn.cc | 2 -- storage/spider/spd_db_include.cc | 4 ---- storage/spider/spd_db_include.h | 6 ------ storage/spider/spd_db_mysql.cc | 14 -------------- storage/spider/spd_db_mysql.h | 6 ------ storage/spider/spd_environ.h | 2 -- storage/spider/spd_table.cc | 6 ------ 10 files changed, 48 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index ac383bbc4f2..60371836683 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -8658,7 +8658,6 @@ ha_rows ha_spider::records() DBUG_RETURN(table_rows); } -#ifdef HA_HAS_CHECKSUM_EXTENDED int ha_spider::pre_calculate_checksum() { int error_num; @@ -8736,7 +8735,6 @@ int ha_spider::calculate_checksum() } DBUG_RETURN(0); } -#endif const char *ha_spider::table_type() const { diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 995a5f0281c..9ebf460623e 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -179,11 +179,9 @@ public: SPIDER_ITEM_HLD *direct_aggregate_item_current; #endif ha_rows table_rows; -#ifdef HA_HAS_CHECKSUM_EXTENDED ha_checksum checksum_val; bool checksum_null; uint action_flags; -#endif /* for fulltext search */ bool ft_init_and_first; @@ -430,10 +428,8 @@ public: int check_crd(); int pre_records() override; ha_rows records() override; -#ifdef HA_HAS_CHECKSUM_EXTENDED int pre_calculate_checksum() override; int calculate_checksum() override; -#endif const char *table_type() const; ulonglong table_flags() const override; ulong table_flags_for_partition(); diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index ef0c304c89f..405832a1e7b 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -22,9 +22,7 @@ #define SPIDER_SIMPLE_CONNECT 1 #define SPIDER_SIMPLE_DISCONNECT 2 #define SPIDER_SIMPLE_RECORDS 3 -#ifdef HA_HAS_CHECKSUM_EXTENDED #define SPIDER_SIMPLE_CHECKSUM_TABLE 4 -#endif /* The SPIDER_CONN_LOOP_CHECK has been added to the loop_check queue to diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 48ac9264af8..f98d1d0283f 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -5933,14 +5933,12 @@ int spider_db_simple_action( link_idx ); break; -#ifdef HA_HAS_CHECKSUM_EXTENDED case SPIDER_SIMPLE_CHECKSUM_TABLE: DBUG_PRINT("info",("spider simple checksum_table")); error_num = db_handler->checksum_table( link_idx ); break; -#endif default: DBUG_ASSERT(0); error_num = HA_ERR_CRASHED; diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc index 16a449e94cc..d5344066017 100644 --- a/storage/spider/spd_db_include.cc +++ b/storage/spider/spd_db_include.cc @@ -40,7 +40,6 @@ spider_db_result::spider_db_result( DBUG_VOID_RETURN; } -#ifdef HA_HAS_CHECKSUM_EXTENDED int spider_db_result::fetch_table_checksum( ha_spider *spider ) { @@ -48,7 +47,6 @@ int spider_db_result::fetch_table_checksum( DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(0); } -#endif uint spider_db_result::limit_mode() { @@ -137,7 +135,6 @@ uint spider_db_util::limit_mode() DBUG_RETURN(0); } -#ifdef HA_HAS_CHECKSUM_EXTENDED bool spider_db_share::checksum_support() { DBUG_ENTER("spider_db_share::checksum_support"); @@ -152,7 +149,6 @@ int spider_db_handler::checksum_table( DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(0); } -#endif bool spider_db_handler::check_direct_update( st_select_lex *select_lex, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 0d080249d62..d6d1d514ac6 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -874,11 +874,9 @@ public: int mode, ha_rows &records ) = 0; -#ifdef HA_HAS_CHECKSUM_EXTENDED virtual int fetch_table_checksum( ha_spider *spider ); -#endif virtual int fetch_table_cardinality( int mode, TABLE *table, @@ -1119,9 +1117,7 @@ public: spider_string *str ) = 0; #endif -#ifdef HA_HAS_CHECKSUM_EXTENDED virtual bool checksum_support(); -#endif }; class spider_db_handler @@ -1463,11 +1459,9 @@ public: virtual int show_records( int link_idx ) = 0; -#ifdef HA_HAS_CHECKSUM_EXTENDED virtual int checksum_table( int link_idx ); -#endif virtual int show_last_insert_id( int link_idx, ulonglong &last_insert_id diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 4d57a8d41de..a676955d1fd 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -161,11 +161,9 @@ static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; #define SPIDER_SQL_SHOW_RECORDS_RECORDS_POS 0 #define SPIDER_SQL_EXPLAIN_SELECT_RECORDS_POS 8 -#ifdef HA_HAS_CHECKSUM_EXTENDED #define SPIDER_SQL_CHECKSUM_CHECKSUM_POS 1 #define SPIDER_SQL_CHECKSUM_TABLE_STR "checksum table " #define SPIDER_SQL_CHECKSUM_TABLE_LEN (sizeof(SPIDER_SQL_CHECKSUM_TABLE_STR) - 1) -#endif #define SPIDER_SQL_LIKE_STR " like " #define SPIDER_SQL_LIKE_LEN (sizeof(SPIDER_SQL_LIKE_STR) - 1) @@ -1119,7 +1117,6 @@ int spider_db_mbase_result::fetch_simple_action( DBUG_PRINT("info", ("spider records=%lld", *records)); break; } -#ifdef HA_HAS_CHECKSUM_EXTENDED case SPIDER_SIMPLE_CHECKSUM_TABLE: { ha_spider *spider = (ha_spider *) param; @@ -1136,7 +1133,6 @@ int spider_db_mbase_result::fetch_simple_action( } break; } -#endif default: DBUG_ASSERT(0); break; @@ -1160,7 +1156,6 @@ int spider_db_mbase_result::fetch_table_records( } } -#ifdef HA_HAS_CHECKSUM_EXTENDED int spider_db_mbase_result::fetch_table_checksum( ha_spider *spider ) { @@ -1169,7 +1164,6 @@ int spider_db_mbase_result::fetch_table_checksum( DBUG_RETURN(fetch_simple_action(SPIDER_SIMPLE_CHECKSUM_TABLE, SPIDER_SQL_CHECKSUM_CHECKSUM_POS, spider)); } -#endif int spider_db_mbase_result::fetch_table_cardinality( int mode, @@ -8191,14 +8185,12 @@ int spider_mbase_share::discover_table_structure( } #endif -#ifdef HA_HAS_CHECKSUM_EXTENDED bool spider_mbase_share::checksum_support() { DBUG_ENTER("spider_mbase_share::checksum_support"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_RETURN(TRUE); } -#endif spider_mbase_handler::spider_mbase_handler( ha_spider *spider, @@ -14239,7 +14231,6 @@ int spider_mbase_handler::simple_action( DBUG_PRINT("info",("spider simple records")); str = &mysql_share->show_records[pos]; break; -#ifdef HA_HAS_CHECKSUM_EXTENDED case SPIDER_SIMPLE_CHECKSUM_TABLE: DBUG_PRINT("info",("spider simple checksum_table")); str = &spider->result_list.sqls[link_idx]; @@ -14269,7 +14260,6 @@ int spider_mbase_handler::simple_action( SPIDER_SQL_SQL_EXTENDED_LEN); } break; -#endif default: DBUG_ASSERT(0); DBUG_RETURN(0); @@ -14393,12 +14383,10 @@ int spider_mbase_handler::simple_action( DBUG_PRINT("info",("spider simple records")); error_num = res->fetch_table_records(1, spider->table_rows); break; -#ifdef HA_HAS_CHECKSUM_EXTENDED case SPIDER_SIMPLE_CHECKSUM_TABLE: DBUG_PRINT("info",("spider simple checksum_table")); error_num = res->fetch_table_checksum(spider); break; -#endif default: DBUG_ASSERT(0); break; @@ -14427,7 +14415,6 @@ int spider_mbase_handler::show_records( DBUG_RETURN(0); } -#ifdef HA_HAS_CHECKSUM_EXTENDED int spider_mbase_handler::checksum_table( int link_idx ) { @@ -14435,7 +14422,6 @@ int spider_mbase_handler::checksum_table( DBUG_RETURN(simple_action(SPIDER_SIMPLE_CHECKSUM_TABLE, link_idx)); DBUG_RETURN(0); } -#endif int spider_mbase_handler::show_last_insert_id( int link_idx, diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index dcc35290103..5124dc61180 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -318,11 +318,9 @@ public: int mode, ha_rows &records ) override; -#ifdef HA_HAS_CHECKSUM_EXTENDED int fetch_table_checksum( ha_spider *spider ) override; -#endif int fetch_table_cardinality( int mode, TABLE *table, @@ -669,9 +667,7 @@ public: spider_string *str ) override; #endif -#ifdef HA_HAS_CHECKSUM_EXTENDED bool checksum_support() override; -#endif protected: int create_table_names_str(); void free_table_names_str(); @@ -1402,11 +1398,9 @@ public: int show_records( int link_idx ) override; -#ifdef HA_HAS_CHECKSUM_EXTENDED int checksum_table( int link_idx ) override; -#endif int show_last_insert_id( int link_idx, ulonglong &last_insert_id diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index faf32019824..3f50cfa0cc8 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -24,7 +24,5 @@ #define HANDLER_HAS_DIRECT_AGGREGATE -#define HA_HAS_CHECKSUM_EXTENDED - #define SPIDER_I_S_USE_SHOW_FOR_COLUMN #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index e6947fe3d6f..41f0668bb24 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -4036,9 +4036,7 @@ SPIDER_SHARE *spider_create_share( uchar *tmp_cardinality_upd, *tmp_table_mon_mutex_bitmap; char buf[MAX_FIELD_WIDTH], *buf_pos; char link_idx_str[SPIDER_SQL_INT_LEN]; -#ifdef HA_HAS_CHECKSUM_EXTENDED bool checksum_support = TRUE; -#endif DBUG_ENTER("spider_create_share"); length = (uint) strlen(table_name); bitmap_size = spider_bitmap_size(table_share->fields); @@ -4175,24 +4173,20 @@ SPIDER_SHARE *spider_create_share( { goto error_init_dbton; } -#ifdef HA_HAS_CHECKSUM_EXTENDED if ( spider_dbton[roop_count].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL && !share->dbton_share[roop_count]->checksum_support() ) { checksum_support = FALSE; } -#endif } } -#ifdef HA_HAS_CHECKSUM_EXTENDED if (checksum_support) { share->additional_table_flags |= HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM; } -#endif DBUG_RETURN(share); /* From 84977868b1e57c6fcef9c7e48fb4367e17ed0dcb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:50:20 +0800 Subject: [PATCH 39/54] MDEV-27809 remove SPIDER_I_S_USE_SHOW_FOR_COLUMN Show::Column() was added in MDEV-19772 4156b1a2602915d6adf983e5c8efaa4f41df3d21 --- storage/spider/spd_environ.h | 2 -- storage/spider/spd_i_s.cc | 33 --------------------------------- 2 files changed, 35 deletions(-) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 3f50cfa0cc8..696d4cc8ae9 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -23,6 +23,4 @@ #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define HANDLER_HAS_DIRECT_AGGREGATE - -#define SPIDER_I_S_USE_SHOW_FOR_COLUMN #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index 8f828939aeb..2db7bd0c374 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -41,7 +41,6 @@ static struct st_mysql_storage_engine spider_i_s_info = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; namespace Show { -#ifdef SPIDER_I_S_USE_SHOW_FOR_COLUMN static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] = { Column("ID", ULong(10), NOT_NULL, "id"), @@ -54,27 +53,6 @@ static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] = Column("FREE_MEM_COUNT", ULonglong(20), NULLABLE, "free_mem_count"), CEnd() }; -#else -static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] = -{ - {"ID", 10, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, "id", SKIP_OPEN_TABLE}, - {"FUNC_NAME", 64, MYSQL_TYPE_STRING, 0, - MY_I_S_MAYBE_NULL, "func_name", SKIP_OPEN_TABLE}, - {"FILE_NAME", 64, MYSQL_TYPE_STRING, 0, - MY_I_S_MAYBE_NULL, "file_name", SKIP_OPEN_TABLE}, - {"LINE_NO", 10, MYSQL_TYPE_LONG, 0, - MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "line_no", SKIP_OPEN_TABLE}, - {"TOTAL_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0, - MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "total_alloc_mem", SKIP_OPEN_TABLE}, - {"CURRENT_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0, - MY_I_S_MAYBE_NULL, "current_alloc_mem", SKIP_OPEN_TABLE}, - {"ALLOC_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0, - MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "alloc_mem_count", SKIP_OPEN_TABLE}, - {"FREE_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0, - MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "free_mem_count", SKIP_OPEN_TABLE}, - {NULL, 0, MYSQL_TYPE_STRING, 0, 0, NULL, 0} -}; -#endif } // namespace Show static int spider_i_s_alloc_mem_fill_table( @@ -183,7 +161,6 @@ struct st_maria_plugin spider_i_s_alloc_mem_maria = extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; namespace Show { -#ifdef SPIDER_I_S_USE_SHOW_FOR_COLUMN static ST_FIELD_INFO spider_i_s_wrapper_protocols_fields_info[] = { Column("WRAPPER_NAME", Varchar(NAME_CHAR_LEN), NOT_NULL, ""), @@ -192,16 +169,6 @@ static ST_FIELD_INFO spider_i_s_wrapper_protocols_fields_info[] = Column("WRAPPER_MATURITY", Varchar(12), NOT_NULL, ""), CEnd() }; -#else -static ST_FIELD_INFO spider_i_s_wrapper_protocols_fields_info[] = -{ - {"WRAPPER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"WRAPPER_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"WRAPPER_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, - {"WRAPPER_MATURITY", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0} -}; -#endif } // namespace Show static int spider_i_s_wrapper_protocols_fill_table( From 3a58291680cfd352276be4eca9a7588e1b6d2ce5 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:52:07 +0800 Subject: [PATCH 40/54] MDEV-27662 remove SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE --- storage/spider/ha_spider.cc | 2 -- storage/spider/spd_environ.h | 2 -- storage/spider/spd_table.cc | 12 ------------ 3 files changed, 16 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 60371836683..7f74d56cf6c 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -10597,7 +10597,6 @@ int ha_spider::create( ) { goto error; } -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE if ( thd->lex->create_info.or_replace() && (error_num = spider_delete_tables( @@ -10608,7 +10607,6 @@ int ha_spider::create( ) { goto error; } -#endif if ( (error_num = spider_insert_tables(table_tables, &tmp_share)) ) { diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 696d4cc8ae9..3ed95c168cd 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -20,7 +20,5 @@ #ifndef SPD_ENVIRON_INCLUDED -#define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE - #define HANDLER_HAS_DIRECT_AGGREGATE #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 41f0668bb24..ca23be650bc 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -8380,7 +8380,6 @@ int spider_discover_table_structure( SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, FALSE, &error_num)) ) { -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE if (thd->lex->create_info.or_replace()) { error_num = spider_delete_tables(table_tables, @@ -8388,11 +8387,8 @@ int spider_discover_table_structure( } if (!error_num) { -#endif error_num = spider_insert_tables(table_tables, spider_share); -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE } -#endif spider_close_sys_table(thd, table_tables, &open_tables_backup, FALSE); } @@ -8496,7 +8492,6 @@ int spider_discover_table_structure( DBUG_RETURN(error_num); } -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE if (thd->lex->create_info.or_replace()) { error_num = spider_delete_tables(table_tables, @@ -8504,11 +8499,8 @@ int spider_discover_table_structure( } if (!error_num) { -#endif error_num = spider_insert_tables(table_tables, spider_share); -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE } -#endif spider_free_share_resource_only(spider_share); if (error_num) @@ -8532,7 +8524,6 @@ int spider_discover_table_structure( DBUG_RETURN(error_num); } -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE if (thd->lex->create_info.or_replace()) { error_num = spider_delete_tables(table_tables, @@ -8540,11 +8531,8 @@ int spider_discover_table_structure( } if (!error_num) { -#endif error_num = spider_insert_tables(table_tables, spider_share); -#ifdef SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE } -#endif spider_free_share_resource_only(spider_share); if (error_num) From 869c501ac363ba009a1a0b090eb56b95aeaab5e1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:52:29 +0800 Subject: [PATCH 41/54] MDEV-27644 Spider: remove HANDLER_HAS_DIRECT_AGGREGATE --- storage/spider/ha_spider.cc | 36 ------------------- storage/spider/ha_spider.h | 8 ----- storage/spider/spd_conn.cc | 2 -- storage/spider/spd_db_conn.cc | 48 ------------------------- storage/spider/spd_db_conn.h | 6 ---- storage/spider/spd_db_include.h | 10 ------ storage/spider/spd_db_mysql.cc | 64 --------------------------------- storage/spider/spd_db_mysql.h | 6 ---- storage/spider/spd_db_oracle.cc | 20 ----------- storage/spider/spd_db_oracle.h | 6 ---- storage/spider/spd_environ.h | 2 -- storage/spider/spd_table.cc | 16 --------- storage/spider/spd_table.h | 2 -- 13 files changed, 226 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 7f74d56cf6c..6f96da80ac5 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -26,9 +26,7 @@ #include "probes_mysql.h" #include "sql_class.h" #include "key.h" -#ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" -#endif #include "ha_partition.h" #include "spd_param.h" #include "spd_err.h" @@ -109,9 +107,7 @@ ha_spider::ha_spider( */ #endif prev_index_rnd_init = SPD_NONE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE direct_aggregate_item_first = NULL; -#endif result_link_idx = 0; result_list.have_sql_kind_backup = FALSE; result_list.sqls = NULL; @@ -125,10 +121,8 @@ ha_spider::ha_spider( result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE result_list.direct_aggregate = FALSE; result_list.snap_direct_aggregate = FALSE; -#endif result_list.direct_distinct = FALSE; result_list.casual_read = NULL; result_list.use_both_key = FALSE; @@ -192,9 +186,7 @@ ha_spider::ha_spider( */ #endif prev_index_rnd_init = SPD_NONE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE direct_aggregate_item_first = NULL; -#endif result_link_idx = 0; result_list.have_sql_kind_backup = FALSE; result_list.sqls = NULL; @@ -208,10 +200,8 @@ ha_spider::ha_spider( result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE result_list.direct_aggregate = FALSE; result_list.snap_direct_aggregate = FALSE; -#endif result_list.direct_distinct = FALSE; result_list.casual_read = NULL; result_list.use_both_key = FALSE; @@ -634,7 +624,6 @@ int ha_spider::close() } while (bulk_access_link_first); } #endif -#ifdef HANDLER_HAS_DIRECT_AGGREGATE while (direct_aggregate_item_first) { direct_aggregate_item_current = direct_aggregate_item_first->next; @@ -645,7 +634,6 @@ int ha_spider::close() spider_free(spider_current_trx, direct_aggregate_item_first, MYF(0)); direct_aggregate_item_first = direct_aggregate_item_current; } -#endif if (is_clone) { for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) @@ -1191,7 +1179,6 @@ int ha_spider::reset() } while (bulk_access_link_first); } #endif -#ifdef HANDLER_HAS_DIRECT_AGGREGATE direct_aggregate_item_current = direct_aggregate_item_first; while (direct_aggregate_item_current) { @@ -1211,7 +1198,6 @@ int ha_spider::reset() } result_list.direct_aggregate = FALSE; result_list.snap_direct_aggregate = FALSE; -#endif result_list.direct_distinct = FALSE; store_error_num = 0; if (wide_handler) @@ -4784,10 +4770,8 @@ int ha_spider::read_multi_range_first_internal( DBUG_RETURN(error_num); result_list.use_union = TRUE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool direct_aggregate_backup = result_list.direct_aggregate; result_list.direct_aggregate = FALSE; -#endif if (result_list.direct_order_limit) { if ((error_num = @@ -4799,9 +4783,7 @@ int ha_spider::read_multi_range_first_internal( NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE result_list.direct_aggregate = direct_aggregate_backup; -#endif if ((error_num = append_limit_sql_part( result_list.internal_offset, result_list.limit_num, @@ -6199,10 +6181,8 @@ int ha_spider::read_multi_range_next( DBUG_RETURN(error_num); result_list.use_union = TRUE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool direct_aggregate_backup = result_list.direct_aggregate; result_list.direct_aggregate = FALSE; -#endif if (result_list.direct_order_limit) { if ((error_num = @@ -6214,9 +6194,7 @@ int ha_spider::read_multi_range_next( NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE result_list.direct_aggregate = direct_aggregate_backup; -#endif if ((error_num = append_limit_sql_part( result_list.internal_offset, result_list.limit_num, @@ -6844,14 +6822,12 @@ int ha_spider::rnd_next_internal( NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (result_list.direct_aggregate) { if ((error_num = append_group_by_sql_part(NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#endif result_list.desc_flg = FALSE; result_list.sorted = FALSE; result_list.key_info = NULL; @@ -7476,14 +7452,12 @@ int ha_spider::ft_read_internal( SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (result_list.direct_aggregate) { if ((error_num = append_group_by_sql_part(NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } -#endif if (sql_kinds & SPIDER_SQL_KIND_SQL) { if ((error_num = append_limit_sql_part( @@ -11419,7 +11393,6 @@ int ha_spider::info_push( DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE void ha_spider::return_record_by_parent() { DBUG_ENTER("ha_spider::return_record_by_parent"); @@ -11427,7 +11400,6 @@ void ha_spider::return_record_by_parent() spider_db_refetch_for_item_sum_funcs(this); DBUG_VOID_RETURN; } -#endif TABLE *ha_spider::get_table() { @@ -13459,7 +13431,6 @@ int ha_spider::append_condition_sql_part( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int ha_spider::append_sum_select_sql_part( ulong sql_type, const char *alias, @@ -13483,7 +13454,6 @@ int ha_spider::append_sum_select_sql_part( } DBUG_RETURN(0); } -#endif int ha_spider::append_match_select_sql_part( ulong sql_type, @@ -13541,7 +13511,6 @@ void ha_spider::set_order_to_pos_sql( DBUG_VOID_RETURN; } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int ha_spider::append_group_by_sql_part( const char *alias, uint alias_length, @@ -13565,7 +13534,6 @@ int ha_spider::append_group_by_sql_part( } DBUG_RETURN(0); } -#endif int ha_spider::append_key_order_for_merge_with_alias_sql_part( const char *alias, @@ -13576,7 +13544,6 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::append_key_order_for_merge_with_alias_sql_part"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (result_list.direct_aggregate) { st_select_lex *select_lex = spider_get_select_lex(this); @@ -13587,7 +13554,6 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part( DBUG_RETURN(0); } } -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; @@ -13637,7 +13603,6 @@ int ha_spider::append_key_order_with_alias_sql_part( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::append_key_order_with_alias_sql_part"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (result_list.direct_aggregate) { st_select_lex *select_lex = spider_get_select_lex(this); @@ -13648,7 +13613,6 @@ int ha_spider::append_key_order_with_alias_sql_part( DBUG_RETURN(0); } } -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 9ebf460623e..a57359ce025 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -174,10 +174,8 @@ public: bool do_direct_update; uint direct_update_kinds; spider_index_rnd_init prev_index_rnd_init; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE SPIDER_ITEM_HLD *direct_aggregate_item_first; SPIDER_ITEM_HLD *direct_aggregate_item_current; -#endif ha_rows table_rows; ha_checksum checksum_val; bool checksum_null; @@ -734,9 +732,7 @@ public: uint info_type, void *info ) override; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE void return_record_by_parent() override; -#endif TABLE *get_table(); void set_ft_discard_bitmap(); void set_searched_bitmap(); @@ -923,13 +919,11 @@ public: ulong sql_type, bool test_flg ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_sum_select_sql_part( ulong sql_type, const char *alias, uint alias_length ); -#endif int append_match_select_sql_part( ulong sql_type, const char *alias, @@ -941,13 +935,11 @@ public: void set_order_to_pos_sql( ulong sql_type ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_group_by_sql_part( const char *alias, uint alias_length, ulong sql_type ); -#endif int append_key_order_for_merge_with_alias_sql_part( const char *alias, uint alias_length, diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 6b3d90bea3d..3be95db5e42 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -928,9 +928,7 @@ int spider_check_and_init_casual_read( (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && ( result_list->direct_order_limit -#ifdef HANDLER_HAS_DIRECT_AGGREGATE || result_list->direct_aggregate -#endif ) ) { if (!result_list->casual_read[link_idx]) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index f98d1d0283f..17ac2398e7a 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -26,9 +26,7 @@ #include "sql_base.h" #include "tztime.h" #include "errmsg.h" -#ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" -#endif #include "sql_common.h" #include #include "spd_err.h" @@ -1390,14 +1388,12 @@ int spider_db_append_select_columns( DBUG_ENTER("spider_db_append_select_columns"); if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) { -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if ( result_list->direct_aggregate && (error_num = spider->append_sum_select_sql_part( SPIDER_SQL_TYPE_SELECT_SQL, NULL, 0)) ) DBUG_RETURN(error_num); -#endif if ((error_num = spider->append_match_select_sql_part( SPIDER_SQL_TYPE_SELECT_SQL, NULL, 0))) DBUG_RETURN(error_num); @@ -2536,7 +2532,6 @@ int spider_db_append_charset_name_before_string( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_refetch_for_item_sum_funcs( ha_spider *spider ) { @@ -2752,7 +2747,6 @@ int spider_db_fetch_for_item_sum_func( spider->wide_handler->trx->direct_aggregate_count++; DBUG_RETURN(0); } -#endif int spider_db_append_match_fetch( ha_spider *spider, @@ -2951,13 +2945,11 @@ int spider_db_fetch_table( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE DBUG_PRINT("info", ("spider direct_aggregate=%s", result_list->direct_aggregate ? "TRUE" : "FALSE")); result_list->snap_mrr_with_cnt = spider->mrr_with_cnt; result_list->snap_direct_aggregate = result_list->direct_aggregate; result_list->snap_row = row; -#endif /* for mrr */ if (spider->mrr_with_cnt) @@ -2967,32 +2959,26 @@ int spider_db_fetch_table( { if (!row->is_null()) spider->multi_range_hit_point = row->val_int(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (result_list->direct_aggregate) { table->status = STATUS_NOT_FOUND; DBUG_RETURN(HA_ERR_END_OF_FILE); } -#endif else DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); row->next(); } else { spider->multi_range_hit_point = 0; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE result_list->snap_mrr_with_cnt = FALSE; -#endif } } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (result_list->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER if (!spider->use_fields) @@ -3081,13 +3067,11 @@ int spider_db_fetch_key( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE DBUG_PRINT("info", ("spider direct_aggregate=%s", result_list->direct_aggregate ? "TRUE" : "FALSE")); result_list->snap_mrr_with_cnt = spider->mrr_with_cnt; result_list->snap_direct_aggregate = result_list->direct_aggregate; result_list->snap_row = row; -#endif /* for mrr */ if (spider->mrr_with_cnt) @@ -3095,26 +3079,22 @@ int spider_db_fetch_key( DBUG_PRINT("info", ("spider mrr_with_cnt")); if (!row->is_null()) spider->multi_range_hit_point = row->val_int(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (result_list->direct_aggregate) { table->status = STATUS_NOT_FOUND; DBUG_RETURN(HA_ERR_END_OF_FILE); } -#endif else DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); row->next(); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (result_list->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif if ((error_num = spider_db_append_match_fetch(spider, spider->ft_first, spider->ft_current, row))) @@ -3198,13 +3178,11 @@ int spider_db_fetch_minimum_columns( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE DBUG_PRINT("info", ("spider direct_aggregate=%s", result_list->direct_aggregate ? "TRUE" : "FALSE")); result_list->snap_mrr_with_cnt = spider->mrr_with_cnt; result_list->snap_direct_aggregate = result_list->direct_aggregate; result_list->snap_row = row; -#endif /* for mrr */ if (spider->mrr_with_cnt) @@ -3212,26 +3190,22 @@ int spider_db_fetch_minimum_columns( DBUG_PRINT("info", ("spider mrr_with_cnt")); if (!row->is_null()) spider->multi_range_hit_point = row->val_int(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (result_list->direct_aggregate) { table->status = STATUS_NOT_FOUND; DBUG_RETURN(HA_ERR_END_OF_FILE); } -#endif else DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); row->next(); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (result_list->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif if ((error_num = spider_db_append_match_fetch(spider, spider->ft_first, spider->ft_current, row))) @@ -5580,9 +5554,7 @@ void spider_db_create_position( current->use_position = TRUE; pos->use_position = TRUE; pos->mrr_with_cnt = spider->mrr_with_cnt; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE pos->direct_aggregate = result_list->direct_aggregate; -#endif pos->sql_kind = spider->sql_kind[spider->result_link_idx]; pos->position_bitmap = spider->wide_handler->position_bitmap; pos->ft_first = spider->ft_first; @@ -5648,7 +5620,6 @@ int spider_db_seek_tmp_table( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (!spider->result_list.in_cmp_ref) { DBUG_PRINT("info", ("spider direct_aggregate=%s", @@ -5657,7 +5628,6 @@ int spider_db_seek_tmp_table( spider->result_list.snap_direct_aggregate = pos->direct_aggregate; spider->result_list.snap_row = row; } -#endif /* for mrr */ if (pos->mrr_with_cnt) @@ -5667,20 +5637,16 @@ int spider_db_seek_tmp_table( { row->next(); } else { -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.snap_mrr_with_cnt = FALSE; -#endif } } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (pos->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif if ((error_num = spider_db_append_match_fetch(spider, pos->ft_first, pos->ft_current, row))) @@ -5740,7 +5706,6 @@ int spider_db_seek_tmp_key( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (!spider->result_list.in_cmp_ref) { DBUG_PRINT("info", ("spider direct_aggregate=%s", @@ -5749,7 +5714,6 @@ int spider_db_seek_tmp_key( spider->result_list.snap_direct_aggregate = pos->direct_aggregate; spider->result_list.snap_row = row; } -#endif /* for mrr */ if (pos->mrr_with_cnt) @@ -5758,14 +5722,12 @@ int spider_db_seek_tmp_key( row->next(); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (pos->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif if ((error_num = spider_db_append_match_fetch(spider, pos->ft_first, pos->ft_current, row))) @@ -5825,7 +5787,6 @@ int spider_db_seek_tmp_minimum_columns( } DBUG_PRINT("info", ("spider row=%p", row)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (!spider->result_list.in_cmp_ref) { DBUG_PRINT("info", ("spider direct_aggregate=%s", @@ -5834,7 +5795,6 @@ int spider_db_seek_tmp_minimum_columns( spider->result_list.snap_direct_aggregate = pos->direct_aggregate; spider->result_list.snap_row = row; } -#endif /* for mrr */ if (pos->mrr_with_cnt) @@ -5843,14 +5803,12 @@ int spider_db_seek_tmp_minimum_columns( row->next(); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE /* for direct_aggregate */ if (pos->direct_aggregate) { if ((error_num = spider_db_fetch_for_item_sum_funcs(row, spider))) DBUG_RETURN(error_num); } -#endif if ((error_num = spider_db_append_match_fetch(spider, pos->ft_first, pos->ft_current, row))) @@ -8554,11 +8512,9 @@ int spider_db_print_item_type( case Item::FUNC_ITEM: DBUG_RETURN(spider_db_open_item_func((Item_func *) item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE case Item::SUM_FUNC_ITEM: DBUG_RETURN(spider_db_open_item_sum_func((Item_sum *)item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); -#endif case Item::COND_ITEM: DBUG_RETURN(spider_db_open_item_cond((Item_cond *) item, spider, str, alias, alias_length, dbton_id, use_fields, fields)); @@ -8731,7 +8687,6 @@ int spider_db_open_item_func( item_func, spider, str, alias, alias_length, use_fields, fields)); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -8746,7 +8701,6 @@ int spider_db_open_item_sum_func( DBUG_RETURN(spider_dbton[dbton_id].db_util->open_item_sum_func( item_sum, spider, str, alias, alias_length, use_fields, fields)); } -#endif int spider_db_open_item_ident( Item_ident *item_ident, @@ -9536,7 +9490,6 @@ int spider_db_append_update_columns( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_db_check_select_colum_in_group( st_select_lex *select_lex, Field *field @@ -9559,7 +9512,6 @@ bool spider_db_check_select_colum_in_group( } DBUG_RETURN(FALSE); } -#endif uint spider_db_check_ft_idx( Item_func *item_func, diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index 5b8dc65b262..aa451b861d2 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -496,7 +496,6 @@ int spider_db_append_charset_name_before_string( CHARSET_INFO *cs ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_refetch_for_item_sum_funcs( ha_spider *spider ); @@ -511,7 +510,6 @@ int spider_db_fetch_for_item_sum_func( Item_sum *item_sum, ha_spider *spider ); -#endif int spider_db_append_match_fetch( ha_spider *spider, @@ -940,7 +938,6 @@ int spider_db_open_item_func( spider_fields *fields ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -951,7 +948,6 @@ int spider_db_open_item_sum_func( bool use_fields, spider_fields *fields ); -#endif int spider_db_open_item_ident( Item_ident *item_ident, @@ -1062,12 +1058,10 @@ int spider_db_append_update_columns( spider_fields *fields ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_db_check_select_colum_in_group( st_select_lex *select_lex, Field *field ); -#endif uint spider_db_check_ft_idx( Item_func *item_func, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index d6d1d514ac6..3946ea4911d 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -765,7 +765,6 @@ public: bool use_fields, spider_fields *fields ) = 0; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE virtual int open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -775,7 +774,6 @@ public: bool use_fields, spider_fields *fields ) = 0; -#endif virtual int append_escaped_util( spider_string *to, String *from @@ -1275,26 +1273,22 @@ public: const char *alias, uint alias_length ) = 0; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE virtual int append_sum_select_part( ulong sql_type, const char *alias, uint alias_length ) = 0; -#endif virtual void set_order_pos( ulong sql_type ) = 0; virtual void set_order_to_pos( ulong sql_type ) = 0; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE virtual int append_group_by_part( const char *alias, uint alias_length, ulong sql_type ) = 0; -#endif virtual int append_key_order_for_merge_with_alias_part( const char *alias, uint alias_length, @@ -1717,9 +1711,7 @@ typedef struct st_spider_position uint pos_mode; bool use_position; bool mrr_with_cnt; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool direct_aggregate; -#endif uint sql_kind; uchar *position_bitmap; st_spider_ft_info *ft_first; @@ -1822,12 +1814,10 @@ typedef struct st_spider_result_list /* the limit_offeset, without where condition */ bool direct_limit_offset; bool direct_distinct; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool direct_aggregate; bool snap_mrr_with_cnt; bool snap_direct_aggregate; SPIDER_DB_ROW *snap_row; -#endif bool in_cmp_ref; bool set_split_read; bool insert_dup_update_pushdown; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index a676955d1fd..848e484e454 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -25,9 +25,7 @@ #include "sql_analyse.h" #include "sql_base.h" #include "tztime.h" -#ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" -#endif #include "sql_common.h" #include #include @@ -6688,7 +6686,6 @@ int spider_db_mbase_util::print_item_func( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_mbase_util::open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -6804,7 +6801,6 @@ int spider_db_mbase_util::open_item_sum_func( } DBUG_RETURN(0); } -#endif int spider_db_mbase_util::append_escaped_util( spider_string *to, @@ -8643,14 +8639,12 @@ int spider_mbase_handler::append_tmp_table_and_sql_for_bka( SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(&sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#endif DBUG_RETURN(0); } @@ -8889,14 +8883,12 @@ int spider_mbase_handler::append_union_table_and_sql_for_bka( ) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(&tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#endif DBUG_RETURN(0); } @@ -9504,13 +9496,10 @@ int spider_mbase_handler::append_table_select_part( int spider_mbase_handler::append_table_select( spider_string *str ) { -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_table_select"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9549,13 +9538,10 @@ int spider_mbase_handler::append_table_select( } str->length(str->length() - SPIDER_SQL_COMMA_LEN); } else { -#endif table_name_pos = str->length() + mysql_share->table_select_pos; if (str->append(*(mysql_share->table_select))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif DBUG_RETURN(0); } @@ -9583,13 +9569,10 @@ int spider_mbase_handler::append_key_select( spider_string *str, uint idx ) { -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_key_select"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9633,13 +9616,10 @@ int spider_mbase_handler::append_key_select( } str->length(str->length() - SPIDER_SQL_COMMA_LEN); } else { -#endif table_name_pos = str->length() + mysql_share->key_select_pos[idx]; if (str->append(mysql_share->key_select[idx])) DBUG_RETURN(HA_ERR_OUT_OF_MEM); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif DBUG_RETURN(0); } @@ -9670,13 +9650,10 @@ int spider_mbase_handler::append_minimum_select( Field **field; int field_length; bool appended = FALSE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_minimum_select"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9686,7 +9663,6 @@ int spider_mbase_handler::append_minimum_select( select_lex = NULL; } } -#endif minimum_select_bitmap_create(); for (field = table->field; *field; field++) { @@ -9697,7 +9673,6 @@ int spider_mbase_handler::append_minimum_select( */ field_length = mysql_share->column_name_str[(*field)->field_index].length(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (select_lex && !spider_db_check_select_colum_in_group(select_lex, *field)) { @@ -9710,14 +9685,11 @@ int spider_mbase_handler::append_minimum_select( mysql_share->append_column_name(str, (*field)->field_index); str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); } else { -#endif if (str->reserve(field_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); mysql_share->append_column_name(str, (*field)->field_index); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); appended = TRUE; } @@ -9740,13 +9712,10 @@ int spider_mbase_handler::append_table_select_with_alias( TABLE *table = spider->get_table(); Field **field; int field_length; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_table_select_with_alias"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9756,12 +9725,10 @@ int spider_mbase_handler::append_table_select_with_alias( select_lex = NULL; } } -#endif for (field = table->field; *field; field++) { field_length = mysql_share->column_name_str[(*field)->field_index].length(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (select_lex && !spider_db_check_select_colum_in_group(select_lex, *field)) { @@ -9775,15 +9742,12 @@ int spider_mbase_handler::append_table_select_with_alias( mysql_share->append_column_name(str, (*field)->field_index); str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); } else { -#endif if (str->reserve(alias_length + field_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); mysql_share->append_column_name(str, (*field)->field_index); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } str->length(str->length() - SPIDER_SQL_COMMA_LEN); @@ -9800,13 +9764,10 @@ int spider_mbase_handler::append_key_select_with_alias( Field *field; uint part_num; int field_length; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_key_select_with_alias"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9816,13 +9777,11 @@ int spider_mbase_handler::append_key_select_with_alias( select_lex = NULL; } } -#endif for (key_part = key_info->key_part, part_num = 0; part_num < spider_user_defined_key_parts(key_info); key_part++, part_num++) { field = key_part->field; field_length = mysql_share->column_name_str[field->field_index].length(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (select_lex && !spider_db_check_select_colum_in_group(select_lex, field)) { @@ -9836,15 +9795,12 @@ int spider_mbase_handler::append_key_select_with_alias( mysql_share->append_column_name(str, field->field_index); str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); } else { -#endif if (str->reserve(alias_length + field_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); mysql_share->append_column_name(str, field->field_index); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); } str->length(str->length() - SPIDER_SQL_COMMA_LEN); @@ -9860,13 +9816,10 @@ int spider_mbase_handler::append_minimum_select_with_alias( Field **field; int field_length; bool appended = FALSE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE st_select_lex *select_lex = NULL; bool sgb = (spider->result_list.direct_aggregate && spider_param_strict_group_by(current_thd, (strict_group_by ? 1 : 0)) == 1); -#endif DBUG_ENTER("spider_mbase_handler::append_minimum_select_with_alias"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (sgb) { select_lex = spider_get_select_lex(spider); @@ -9876,7 +9829,6 @@ int spider_mbase_handler::append_minimum_select_with_alias( select_lex = NULL; } } -#endif minimum_select_bitmap_create(); for (field = table->field; *field; field++) { @@ -9887,7 +9839,6 @@ int spider_mbase_handler::append_minimum_select_with_alias( */ field_length = mysql_share->column_name_str[(*field)->field_index].length(); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (select_lex && !spider_db_check_select_colum_in_group(select_lex, *field)) { @@ -9901,15 +9852,12 @@ int spider_mbase_handler::append_minimum_select_with_alias( mysql_share->append_column_name(str, (*field)->field_index); str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); } else { -#endif if (str->reserve(alias_length + field_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + SPIDER_SQL_COMMA_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); mysql_share->append_column_name(str, (*field)->field_index); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE } -#endif str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); appended = TRUE; } @@ -9932,13 +9880,11 @@ int spider_mbase_handler::append_select_columns_with_alias( int error_num; SPIDER_RESULT_LIST *result_list = &spider->result_list; DBUG_ENTER("spider_mbase_handler::append_select_columns_with_alias"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if ( result_list->direct_aggregate && (error_num = append_sum_select(str, alias, alias_length)) ) DBUG_RETURN(error_num); -#endif if ((error_num = append_match_select(str, alias, alias_length))) DBUG_RETURN(error_num); if (!spider->select_column_mode) @@ -11098,7 +11044,6 @@ int spider_mbase_handler::append_match_select( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_mbase_handler::append_sum_select_part( ulong sql_type, const char *alias, @@ -11145,7 +11090,6 @@ int spider_mbase_handler::append_sum_select( } DBUG_RETURN(0); } -#endif void spider_mbase_handler::set_order_pos( ulong sql_type @@ -11199,7 +11143,6 @@ void spider_mbase_handler::set_order_to_pos( DBUG_VOID_RETURN; } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_mbase_handler::append_group_by_part( const char *alias, uint alias_length, @@ -11262,7 +11205,6 @@ int spider_mbase_handler::append_group_by( } DBUG_RETURN(0); } -#endif int spider_mbase_handler::append_key_order_for_merge_with_alias_part( const char *alias, @@ -11308,14 +11250,12 @@ int spider_mbase_handler::append_key_order_for_merge_with_alias( uint key_name_length; DBUG_ENTER("spider_mbase_handler::append_key_order_for_merge_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { int error_num; if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif if (table->s->primary_key < MAX_KEY) { /* sort by primary key */ @@ -11424,13 +11364,11 @@ int spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias( longlong offset_limit; DBUG_ENTER("spider_mbase_handler::append_key_order_for_direct_order_limit_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); if (select_lex->order_list.first) @@ -11526,14 +11464,12 @@ int spider_mbase_handler::append_key_order_with_alias( uint key_name_length; DBUG_ENTER("spider_mbase_handler::append_key_order_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { int error_num; if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif if (result_list->sorted == TRUE) { if (result_list->desc_flg == TRUE) diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 5124dc61180..7eeb5bed7fb 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -145,7 +145,6 @@ protected: spider_fields *fields ); public: -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -155,7 +154,6 @@ public: bool use_fields, spider_fields *fields ) override; -#endif int append_escaped_util( spider_string *to, String *from @@ -1068,7 +1066,6 @@ public: const char *alias, uint alias_length ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_sum_select_part( ulong sql_type, const char *alias, @@ -1079,14 +1076,12 @@ public: const char *alias, uint alias_length ); -#endif void set_order_pos( ulong sql_type ) override; void set_order_to_pos( ulong sql_type ) override; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_group_by_part( const char *alias, uint alias_length, @@ -1097,7 +1092,6 @@ public: const char *alias, uint alias_length ); -#endif int append_key_order_for_merge_with_alias_part( const char *alias, uint alias_length, diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index f390e5d80fb..34d0ff58fcc 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -22,9 +22,7 @@ #include "probes_mysql.h" #include "sql_partition.h" #include "sql_analyse.h" -#ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" -#endif #ifdef HAVE_ORACLE_OCI #if (defined(WIN32) || defined(_WIN32) || defined(WINDOWS) || defined(_WINDOWS)) @@ -4221,7 +4219,6 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_db_oracle_util::open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -4296,7 +4293,6 @@ int spider_db_oracle_util::open_item_sum_func( } DBUG_RETURN(0); } -#endif size_t spider_db_oracle_util::escape_string( char *to, @@ -5731,14 +5727,12 @@ int spider_oracle_handler::append_tmp_table_and_sql_for_bka( SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(&sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#endif DBUG_RETURN(0); } @@ -5971,14 +5965,12 @@ int spider_oracle_handler::append_union_table_and_sql_for_bka( &tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE else if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(&tmp_sql, SPIDER_SQL_B_DOT_STR, SPIDER_SQL_B_DOT_LEN))) DBUG_RETURN(error_num); } -#endif DBUG_RETURN(0); } @@ -6702,13 +6694,11 @@ int spider_oracle_handler::append_select_columns_with_alias( int error_num; SPIDER_RESULT_LIST *result_list = &spider->result_list; DBUG_ENTER("spider_oracle_handler::append_select_columns_with_alias"); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if ( result_list->direct_aggregate && (error_num = append_sum_select(str, alias, alias_length)) ) DBUG_RETURN(error_num); -#endif if ((error_num = append_match_select(str, alias, alias_length))) DBUG_RETURN(error_num); if (!spider->select_column_mode) @@ -7826,7 +7816,6 @@ int spider_oracle_handler::append_match_select( DBUG_RETURN(0); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_oracle_handler::append_sum_select_part( ulong sql_type, const char *alias, @@ -7873,7 +7862,6 @@ int spider_oracle_handler::append_sum_select( } DBUG_RETURN(0); } -#endif void spider_oracle_handler::set_order_pos( ulong sql_type @@ -7927,7 +7915,6 @@ void spider_oracle_handler::set_order_to_pos( DBUG_VOID_RETURN; } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int spider_oracle_handler::append_group_by_part( const char *alias, uint alias_length, @@ -7990,7 +7977,6 @@ int spider_oracle_handler::append_group_by( } DBUG_RETURN(0); } -#endif int spider_oracle_handler::append_key_order_for_merge_with_alias_part( const char *alias, @@ -8036,14 +8022,12 @@ int spider_oracle_handler::append_key_order_for_merge_with_alias( uint key_name_length; DBUG_ENTER("spider_oracle_handler::append_key_order_for_merge_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { int error_num; if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif if ( spider->result_list.direct_order_limit || spider->result_list.internal_limit < 9223372036854775807LL || @@ -8266,13 +8250,11 @@ int spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias( longlong offset_limit; DBUG_ENTER("spider_oracle_handler::append_key_order_for_direct_order_limit_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); if ( @@ -8491,14 +8473,12 @@ int spider_oracle_handler::append_key_order_with_alias( uint key_name_length; DBUG_ENTER("spider_oracle_handler::append_key_order_with_alias"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE if (spider->result_list.direct_aggregate) { int error_num; if ((error_num = append_group_by(str, alias, alias_length))) DBUG_RETURN(error_num); } -#endif if ( spider->result_list.direct_order_limit || spider->result_list.internal_limit < 9223372036854775807LL || diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index 8acffb5c150..d47bc9f7ea6 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -125,7 +125,6 @@ public: bool use_fields, spider_fields *fields ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int open_item_sum_func( Item_sum *item_sum, ha_spider *spider, @@ -135,7 +134,6 @@ public: bool use_fields, spider_fields *fields ); -#endif size_t escape_string( char *to, const char *from, @@ -957,7 +955,6 @@ public: const char *alias, uint alias_length ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_sum_select_part( ulong sql_type, const char *alias, @@ -968,14 +965,12 @@ public: const char *alias, uint alias_length ); -#endif void set_order_pos( ulong sql_type ); void set_order_to_pos( ulong sql_type ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE int append_group_by_part( const char *alias, uint alias_length, @@ -986,7 +981,6 @@ public: const char *alias, uint alias_length ); -#endif int append_key_order_for_merge_with_alias_part( const char *alias, uint alias_length, diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 3ed95c168cd..8d6e7327919 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -19,6 +19,4 @@ */ #ifndef SPD_ENVIRON_INCLUDED - -#define HANDLER_HAS_DIRECT_AGGREGATE #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index ca23be650bc..05603a5dd7e 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -7840,9 +7840,7 @@ bool spider_check_direct_order_limit( DBUG_PRINT("info",("spider with distinct")); spider->result_list.direct_distinct = TRUE; } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate = spider_param_direct_aggregate(thd); -#endif DBUG_PRINT("info",("spider select_limit=%lld", select_limit)); DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); if ( @@ -7861,22 +7859,17 @@ bool spider_check_direct_order_limit( DBUG_PRINT("info",("spider first_check is FALSE")); first_check = FALSE; spider->result_list.direct_distinct = FALSE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate = FALSE; -#endif } else if (spider_db_append_condition(spider, NULL, 0, TRUE)) { DBUG_PRINT("info",("spider FALSE by condition")); first_check = FALSE; spider->result_list.direct_distinct = FALSE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate = FALSE; -#endif } else if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) { DBUG_PRINT("info",("spider sql_kinds with SPIDER_SQL_KIND_HANDLER")); spider->result_list.direct_distinct = FALSE; -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate = FALSE; } else if ( !select_lex->group_list.elements && @@ -7914,7 +7907,6 @@ bool spider_check_direct_order_limit( first_check = FALSE; spider->result_list.direct_distinct = FALSE; } -#endif } longlong direct_order_limit = spider_param_direct_order_limit(thd, @@ -7926,10 +7918,8 @@ bool spider_check_direct_order_limit( first_check ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider (select_lex->options & OPTION_FOUND_ROWS)=%s", select_lex && (select_lex->options & OPTION_FOUND_ROWS) ? "TRUE" : "FALSE")); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE DBUG_PRINT("info",("spider direct_aggregate=%s", spider->result_list.direct_aggregate ? "TRUE" : "FALSE")); -#endif DBUG_PRINT("info",("spider select_lex->group_list.elements=%u", select_lex ? select_lex->group_list.elements : 0)); DBUG_PRINT("info",("spider select_lex->with_sum_func=%s", @@ -7943,9 +7933,7 @@ bool spider_check_direct_order_limit( !select_lex->explicit_limit || (select_lex->options & OPTION_FOUND_ROWS) || ( -#ifdef HANDLER_HAS_DIRECT_AGGREGATE !spider->result_list.direct_aggregate && -#endif ( select_lex->group_list.elements || select_lex->with_sum_func @@ -7979,7 +7967,6 @@ bool spider_check_direct_order_limit( DBUG_RETURN(FALSE); } -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_all_part_in_order( ORDER *order, TABLE *table @@ -8056,7 +8043,6 @@ Field *spider_field_exchange( DBUG_PRINT("info",("spider out field=%p", field)); DBUG_RETURN(field); } -#endif int spider_set_direct_limit_offset( ha_spider *spider @@ -8089,9 +8075,7 @@ int spider_set_direct_limit_offset( if ( spider->wide_handler->sql_command != SQLCOM_SELECT || -#ifdef HANDLER_HAS_DIRECT_AGGREGATE spider->result_list.direct_aggregate || -#endif spider->result_list.direct_order_limit || spider->prev_index_rnd_init != SPD_RND // must be RND_INIT and not be INDEX_INIT ) diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h index 8bca3c047fa..e6230110dd6 100644 --- a/storage/spider/spd_table.h +++ b/storage/spider/spd_table.h @@ -431,7 +431,6 @@ bool spider_check_direct_order_limit( ha_spider *spider ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE bool spider_all_part_in_order( ORDER *order, TABLE *table @@ -441,7 +440,6 @@ Field *spider_field_exchange( handler *handler, Field *field ); -#endif int spider_set_direct_limit_offset( ha_spider *spider From 5d54e86c22000244cc09bd1fffbfa0674f81fcb8 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 17 Jun 2024 10:19:30 +0800 Subject: [PATCH 42/54] MDEV-26178 spider: delete spd_environ.h It's virtually empty now --- storage/spider/ha_spider.cc | 1 - storage/spider/spd_conn.cc | 1 - storage/spider/spd_copy_tables.cc | 1 - storage/spider/spd_db_conn.cc | 1 - storage/spider/spd_db_include.cc | 1 - storage/spider/spd_db_mysql.cc | 1 - storage/spider/spd_db_oracle.cc | 1 - storage/spider/spd_direct_sql.cc | 1 - storage/spider/spd_environ.h | 22 ---------------------- storage/spider/spd_group_by_handler.cc | 1 - storage/spider/spd_i_s.cc | 1 - storage/spider/spd_malloc.cc | 1 - storage/spider/spd_param.cc | 1 - storage/spider/spd_ping_table.cc | 1 - storage/spider/spd_sys_table.cc | 1 - storage/spider/spd_table.cc | 1 - storage/spider/spd_trx.cc | 1 - storage/spider/spd_udf.cc | 1 - 18 files changed, 39 deletions(-) delete mode 100644 storage/spider/spd_environ.h diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 6f96da80ac5..814eee073be 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -21,7 +21,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 3be95db5e42..29c8635e98d 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 2a3b848c3ce..d76c8e425ec 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 17ac2398e7a..046e024522f 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc index d5344066017..b082f2d3c8b 100644 --- a/storage/spider/spd_db_include.cc +++ b/storage/spider/spd_db_include.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 848e484e454..9118e3fb7c1 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 34d0ff58fcc..b06be249a4f 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_partition.h" diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 49a6edc6d26..e136c302126 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h deleted file mode 100644 index 8d6e7327919..00000000000 --- a/storage/spider/spd_environ.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2008-2020 Kentoku Shiba - Copyright (C) 2017-2020 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 SPD_ENVIRON_INCLUDED -#endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 37bfc7ea8a7..9b71f5bc13f 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index 2db7bd0c374..0b44c9440e3 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc index 395fde5fd8d..96fa4cf89b9 100644 --- a/storage/spider/spd_malloc.cc +++ b/storage/spider/spd_malloc.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 371dd1215c9..41a065bfd29 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -37,7 +37,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 30f2814f8e1..055501925b5 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index d4c453bba87..9e39ffc8d90 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -16,7 +16,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 05603a5dd7e..03ff98740b7 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "my_getopt.h" diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 05a6fead947..f04c3659d6f 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -17,7 +17,6 @@ #define MYSQL_SERVER 1 #include #include "mysql_version.h" -#include "spd_environ.h" #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" diff --git a/storage/spider/spd_udf.cc b/storage/spider/spd_udf.cc index 3f7cc65477f..023285cb4f1 100644 --- a/storage/spider/spd_udf.cc +++ b/storage/spider/spd_udf.cc @@ -15,7 +15,6 @@ #define MYSQL_SERVER 1 #include -#include "spd_environ.h" #include "mysql.h" #include "spd_udf.h" From a81f419b06df996e047d33c24db9a5cf695e6ded Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 13:55:02 +0800 Subject: [PATCH 43/54] MDEV-27648 remove #define HASH_UPDATE_WITH_HASH_VALUE The functions called in blocks protected by this macro remain undefined as of 11.5 c96b23f99409cad9c0dac5040561136211486995 --- storage/spider/spd_conn.cc | 197 ------------------------------- storage/spider/spd_db_include.h | 3 - storage/spider/spd_db_mysql.cc | 26 ---- storage/spider/spd_db_oracle.cc | 26 ---- storage/spider/spd_direct_sql.cc | 10 -- storage/spider/spd_ping_table.cc | 11 -- storage/spider/spd_table.cc | 79 ------------- storage/spider/spd_trx.cc | 57 --------- 8 files changed, 409 deletions(-) diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 29c8635e98d..7c65f1d02eb 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -309,12 +309,7 @@ void spider_free_conn_from_trx( if (another) { ha_spider *next_spider; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_another_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&trx->trx_another_conn_hash, (uchar*) conn); -#endif spider = (ha_spider*) conn->another_ha_first; while (spider) { @@ -329,12 +324,7 @@ void spider_free_conn_from_trx( conn->another_ha_first = NULL; conn->another_ha_last = NULL; } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&trx->trx_conn_hash, (uchar*) conn); -#endif } if ( @@ -354,12 +344,7 @@ void spider_free_conn_from_trx( } else { pthread_mutex_lock(&spider_conn_mutex); uint old_elements = spider_open_connections.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_open_connections, - conn->conn_key_hash_value, (uchar*) conn)) -#else if (my_hash_insert(&spider_open_connections, (uchar*) conn)) -#endif { pthread_mutex_unlock(&spider_conn_mutex); spider_free_conn(conn); @@ -721,12 +706,7 @@ SPIDER_CONN *spider_get_conn( } } } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_connections, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&spider_open_connections, (uchar*) conn); -#endif pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider get global conn")); if (spider) @@ -756,13 +736,7 @@ SPIDER_CONN *spider_get_conn( if (another) { uint old_elements = trx->trx_another_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_another_conn_hash, - share->conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else if (my_hash_insert(&trx->trx_another_conn_hash, (uchar*) conn)) -#endif { spider_free_conn(conn); *error_num = HA_ERR_OUT_OF_MEM; @@ -777,13 +751,7 @@ SPIDER_CONN *spider_get_conn( } } else { uint old_elements = trx->trx_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, - share->conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else if (my_hash_insert(&trx->trx_conn_hash, (uchar*) conn)) -#endif { spider_free_conn(conn); *error_num = HA_ERR_OUT_OF_MEM; @@ -1133,12 +1101,7 @@ int spider_conn_queue_and_merge_loop_check( *tmp_name = '-'; ++tmp_name; memcpy(tmp_name, lcptr->from_value.str, lcptr->from_value.length + 1); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (unlikely(my_hash_insert_with_hash_value(&conn->loop_check_queue, - lcptr->hash_value_to, (uchar *) lcptr))) -#else if (unlikely(my_hash_insert(&conn->loop_check_queue, (uchar *) lcptr))) -#endif { goto error_hash_insert_queue; } @@ -1196,33 +1159,16 @@ int spider_conn_queue_and_merge_loop_check( memcpy(merged_value, lcptr->from_value.str, lcptr->from_value.length + 1); DBUG_PRINT("info", ("spider free lcqptr")); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&conn->loop_checked, - lcqptr->hash_value_full, (uchar *) lcqptr); - my_hash_delete_with_hash_value(&conn->loop_check_queue, - lcqptr->hash_value_to, (uchar *) lcqptr); -#else my_hash_delete(&conn->loop_checked, (uchar*) lcqptr); my_hash_delete(&conn->loop_check_queue, (uchar*) lcqptr); -#endif spider_free(spider_current_trx, lcqptr, MYF(0)); lcptr = lcrptr; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (unlikely(my_hash_insert_with_hash_value(&conn->loop_checked, - lcptr->hash_value_full, (uchar *) lcptr))) -#else if (unlikely(my_hash_insert(&conn->loop_checked, (uchar *) lcptr))) -#endif { goto error_hash_insert; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (unlikely(my_hash_insert_with_hash_value(&conn->loop_check_queue, - lcptr->hash_value_to, (uchar *) lcptr))) -#else if (unlikely(my_hash_insert(&conn->loop_check_queue, (uchar *) lcptr))) -#endif { goto error_hash_insert_queue; } @@ -1232,12 +1178,7 @@ int spider_conn_queue_and_merge_loop_check( error_alloc_loop_check_replace: error_hash_insert_queue: -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&conn->loop_checked, - lcptr->hash_value_full, (uchar *) lcptr); -#else my_hash_delete(&conn->loop_checked, (uchar*) lcptr); -#endif error_hash_insert: spider_free(spider_current_trx, lcptr, MYF(0)); pthread_mutex_unlock(&conn->loop_check_mutex); @@ -1257,12 +1198,7 @@ int spider_conn_reset_queue_loop_check( if (!lcptr->flag) { DBUG_PRINT("info", ("spider free lcptr")); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&conn->loop_checked, - lcptr->hash_value_full, (uchar *) lcptr); -#else my_hash_delete(&conn->loop_checked, (uchar*) lcptr); -#endif spider_free(spider_current_trx, lcptr, MYF(0)); } ++l; @@ -1424,12 +1360,7 @@ int spider_conn_queue_loop_check( if (unlikely(lcptr)) { DBUG_PRINT("info", ("spider free lcptr")); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&conn->loop_checked, - lcptr->hash_value_full, (uchar *) lcptr); -#else my_hash_delete(&conn->loop_checked, (uchar*) lcptr); -#endif spider_free(spider_current_trx, lcptr, MYF(0)); } DBUG_PRINT("info", ("spider alloc_lcptr")); @@ -1466,16 +1397,7 @@ int spider_conn_queue_loop_check( lcptr->merged_value.str = merged_value; lcptr->hash_value_to = my_calc_hash(&conn->loop_check_queue, (uchar *) to_str.str, to_str.length); - /* - Mark as checked. It will be added to loop_check_queue in - spider_conn_queue_and_merge_loop_check() below for checking - */ -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (unlikely(my_hash_insert_with_hash_value(&conn->loop_checked, - lcptr->hash_value_full, (uchar *) lcptr))) -#else if (unlikely(my_hash_insert(&conn->loop_checked, (uchar *) lcptr))) -#endif { my_afree(loop_check_buf); goto error_hash_insert; @@ -3154,32 +3076,6 @@ void *spider_bg_sts_action( trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num); conns[spider.search_link_idx]->error_mode = 0; -/* - if ( - error_num && - share->monitoring_kind[spider.search_link_idx] && - need_mons[spider.search_link_idx] - ) { - lex_start(thd); - error_num = spider_ping_table_mon_from_table( - trx, - thd, - share, - spider.search_link_idx, - (uint32) share->monitoring_sid[spider.search_link_idx], - share->table_name, - share->table_name_length, - spider.conn_link_idx[spider.search_link_idx], - NULL, - 0, - share->monitoring_kind[spider.search_link_idx], - share->monitoring_limit[spider.search_link_idx], - share->monitoring_flag[spider.search_link_idx], - TRUE - ); - lex_end(thd->lex); - } -*/ spider.search_link_idx = -1; } if (spider.search_link_idx != -1 && conns[spider.search_link_idx]) @@ -3197,31 +3093,6 @@ void *spider_bg_sts_action( 2, HA_STATUS_CONST | HA_STATUS_VARIABLE)) #endif { -/* - if ( - share->monitoring_kind[spider.search_link_idx] && - need_mons[spider.search_link_idx] - ) { - lex_start(thd); - error_num = spider_ping_table_mon_from_table( - trx, - thd, - share, - spider.search_link_idx, - (uint32) share->monitoring_sid[spider.search_link_idx], - share->table_name, - share->table_name_length, - spider.conn_link_idx[spider.search_link_idx], - NULL, - 0, - share->monitoring_kind[spider.search_link_idx], - share->monitoring_limit[spider.search_link_idx], - share->monitoring_flag[spider.search_link_idx], - TRUE - ); - lex_end(thd->lex); - } -*/ spider.search_link_idx = -1; } } @@ -3464,12 +3335,6 @@ void *spider_bg_crd_action( if (spider.search_link_idx < 0) { spider_trx_set_link_idx_for_all(&spider); -/* - spider.search_link_idx = spider_conn_next_link_idx( - thd, share->link_statuses, share->access_balances, - spider.conn_link_idx, spider.search_link_idx, share->link_count, - SPIDER_LINK_STATUS_OK); -*/ spider.search_link_idx = spider_conn_first_link_idx(thd, share->link_statuses, share->access_balances, spider.conn_link_idx, share->link_count, SPIDER_LINK_STATUS_OK); @@ -3486,32 +3351,6 @@ void *spider_bg_crd_action( trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num); conns[spider.search_link_idx]->error_mode = 0; -/* - if ( - error_num && - share->monitoring_kind[spider.search_link_idx] && - need_mons[spider.search_link_idx] - ) { - lex_start(thd); - error_num = spider_ping_table_mon_from_table( - trx, - thd, - share, - spider.search_link_idx, - (uint32) share->monitoring_sid[spider.search_link_idx], - share->table_name, - share->table_name_length, - spider.conn_link_idx[spider.search_link_idx], - NULL, - 0, - share->monitoring_kind[spider.search_link_idx], - share->monitoring_limit[spider.search_link_idx], - share->monitoring_flag[spider.search_link_idx], - TRUE - ); - lex_end(thd->lex); - } -*/ spider.search_link_idx = -1; } if (spider.search_link_idx != -1 && conns[spider.search_link_idx]) @@ -3529,31 +3368,6 @@ void *spider_bg_crd_action( 2)) #endif { -/* - if ( - share->monitoring_kind[spider.search_link_idx] && - need_mons[spider.search_link_idx] - ) { - lex_start(thd); - error_num = spider_ping_table_mon_from_table( - trx, - thd, - share, - spider.search_link_idx, - (uint32) share->monitoring_sid[spider.search_link_idx], - share->table_name, - share->table_name_length, - spider.conn_link_idx[spider.search_link_idx], - NULL, - 0, - share->monitoring_kind[spider.search_link_idx], - share->monitoring_limit[spider.search_link_idx], - share->monitoring_flag[spider.search_link_idx], - TRUE - ); - lex_end(thd->lex); - } -*/ spider.search_link_idx = -1; } } @@ -3858,17 +3672,11 @@ void *spider_bg_mon_action( share->monitoring_bg_interval[link_idx] * 1000); pthread_cond_timedwait(&share->bg_mon_sleep_conds[link_idx], &share->bg_mon_mutexes[link_idx], &abstime); -/* - my_sleep((ulong) share->monitoring_bg_interval[link_idx]); -*/ } DBUG_PRINT("info",("spider bg mon roop start")); if (share->bg_mon_kill) { DBUG_PRINT("info",("spider bg mon kill start")); -/* - pthread_mutex_lock(&share->bg_mon_mutexes[link_idx]); -*/ pthread_cond_signal(&share->bg_mon_conds[link_idx]); pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]); spider_free_trx(trx, TRUE); @@ -4241,12 +4049,7 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( share->conn_keys_lengths[link_idx]))) { /* get conn from spider_open_connections, then delete conn in spider_open_connections */ -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_connections, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&spider_open_connections, (uchar*) conn); -#endif pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider get global conn")); if (spider) diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 3946ea4911d..50974269e0c 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -26,9 +26,6 @@ #define SPIDER_DB_WRAPPER_MARIADB "mariadb" #define PLUGIN_VAR_CAN_MEMALLOC -/* -#define HASH_UPDATE_WITH_HASH_VALUE -*/ #define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE #define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 9118e3fb7c1..ed92a5d2e64 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3630,12 +3630,7 @@ int spider_db_mbase::append_lock_tables( my_hash_reset(&lock_table_hash); DBUG_RETURN(error_num); } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&lock_table_hash, - tmp_link_for_hash->db_table_str_hash_value, (uchar*) tmp_link_for_hash); -#else my_hash_delete(&lock_table_hash, (uchar*) tmp_link_for_hash); -#endif } if ((error_num = spider_db_mbase_utility->append_lock_table_tail(str))) { @@ -13012,15 +13007,8 @@ int spider_mbase_handler::insert_lock_tables_list( DBUG_PRINT("info",("spider this=%p", this)); uint old_elements = db_conn->lock_table_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash2->db_table_str_hash_value, - (uchar*) tmp_link_for_hash2)) -#else if (my_hash_insert(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash2)) -#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -13067,26 +13055,12 @@ int spider_mbase_handler::append_lock_tables_list( if (tmp_link_for_hash->spider->wide_handler->lock_type < spider->wide_handler->lock_type) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash->db_table_str_hash_value, - (uchar*) tmp_link_for_hash); -#else my_hash_delete(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash); -#endif uint old_elements = db_conn->lock_table_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash2->db_table_str_hash_value, - (uchar*) tmp_link_for_hash2)) -#else if (my_hash_insert(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash2)) -#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index b06be249a4f..e0eeaf2975b 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2350,12 +2350,7 @@ int spider_db_oracle::append_lock_tables( my_hash_reset(&lock_table_hash); DBUG_RETURN(error_num); } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&lock_table_hash, - tmp_link_for_hash->db_table_str_hash_value, (uchar*) tmp_link_for_hash); -#else my_hash_delete(&lock_table_hash, (uchar*) tmp_link_for_hash); -#endif if ((error_num = spider_db_oracle_utility.append_lock_table_tail(str))) { @@ -10282,15 +10277,8 @@ int spider_oracle_handler::insert_lock_tables_list( DBUG_PRINT("info",("spider this=%p", this)); uint old_elements = db_conn->lock_table_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash2->db_table_str_hash_value, - (uchar*) tmp_link_for_hash2)) -#else if (my_hash_insert(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash2)) -#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -10334,26 +10322,12 @@ int spider_oracle_handler::append_lock_tables_list( if (tmp_link_for_hash->spider->wide_handler->lock_type < spider->wide_handler->lock_type) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash->db_table_str_hash_value, - (uchar*) tmp_link_for_hash); -#else my_hash_delete(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash); -#endif uint old_elements = db_conn->lock_table_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value( - &db_conn->lock_table_hash, - tmp_link_for_hash2->db_table_str_hash_value, - (uchar*) tmp_link_for_hash2)) -#else if (my_hash_insert(&db_conn->lock_table_hash, (uchar*) tmp_link_for_hash2)) -#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index e136c302126..0d12b3b25b3 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -522,12 +522,7 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( error_num))) goto error; } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_connections, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&spider_open_connections, (uchar*) conn); -#endif pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider get global conn")); } @@ -541,12 +536,7 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( conn->priority = direct_sql->priority; uint old_elements = trx->trx_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, - direct_sql->conn_key_hash_value, (uchar*) conn)) -#else if (my_hash_insert(&trx->trx_conn_hash, (uchar*) conn)) -#endif { spider_free_conn(conn); *error_num = HA_ERR_OUT_OF_MEM; diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 055501925b5..2795f8a3bb6 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -159,14 +159,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( uint old_elements = spider_udf_table_mon_list_hash[mutex_hash].array.max_element; table_mon_list->key_hash_value = hash_value; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value( - &spider_udf_table_mon_list_hash[mutex_hash], - hash_value, (uchar*) table_mon_list)) -#else if (my_hash_insert(&spider_udf_table_mon_list_hash[mutex_hash], (uchar*) table_mon_list)) -#endif { spider_ping_table_free_mon_list(table_mon_list); *error_num = HA_ERR_OUT_OF_MEM; @@ -215,13 +209,8 @@ void spider_release_ping_table_mon_list_loop( SPIDER_TABLE_MON_LIST *table_mon_list ) { DBUG_ENTER("spider_release_ping_table_mon_list_loop"); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_udf_table_mon_list_hash[mutex_hash], - table_mon_list->key_hash_value, (uchar*) table_mon_list); -#else my_hash_delete(&spider_udf_table_mon_list_hash[mutex_hash], (uchar*) table_mon_list); -#endif while (TRUE) { if (table_mon_list->use_count) diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 03ff98740b7..145d9dc9c40 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -4321,12 +4321,7 @@ SPIDER_SHARE *spider_get_share( } uint old_elements = spider_open_tables.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_open_tables, hash_value, - (uchar*) share)) -#else if (my_hash_insert(&spider_open_tables, (uchar*) share)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_hash_insert; @@ -4479,14 +4474,9 @@ SPIDER_SHARE *spider_get_share( spider_free_share(share); goto error_sts_spider_init; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - share->sts_thread = &spider_table_sts_threads[ - hash_value % spider_param_table_sts_thread_count()]; -#else share->sts_thread = &spider_table_sts_threads[ my_calc_hash(&spider_open_tables, (uchar*) table_name, length) % spider_param_table_sts_thread_count()]; -#endif share->sts_spider_init = TRUE; } pthread_mutex_unlock(&share->mutex); @@ -4507,14 +4497,9 @@ SPIDER_SHARE *spider_get_share( spider_free_share(share); goto error_crd_spider_init; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - share->crd_thread = &spider_table_crd_threads[ - hash_value % spider_param_table_crd_thread_count()]; -#else share->crd_thread = &spider_table_crd_threads[ my_calc_hash(&spider_open_tables, (uchar*) table_name, length) % spider_param_table_crd_thread_count()]; -#endif share->crd_spider_init = TRUE; } pthread_mutex_unlock(&share->mutex); @@ -4973,14 +4958,9 @@ SPIDER_SHARE *spider_get_share( spider_free_share(share); goto error_sts_spider_init; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - share->sts_thread = &spider_table_sts_threads[ - hash_value % spider_param_table_sts_thread_count()]; -#else share->sts_thread = &spider_table_sts_threads[ my_calc_hash(&spider_open_tables, (uchar*) table_name, length) % spider_param_table_sts_thread_count()]; -#endif share->sts_spider_init = TRUE; } pthread_mutex_unlock(&share->mutex); @@ -4998,14 +4978,9 @@ SPIDER_SHARE *spider_get_share( spider_free_share(share); goto error_crd_spider_init; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE - share->crd_thread = &spider_table_crd_threads[ - hash_value % spider_param_table_crd_thread_count()]; -#else share->crd_thread = &spider_table_crd_threads[ my_calc_hash(&spider_open_tables, (uchar*) table_name, length) % spider_param_table_crd_thread_count()]; -#endif share->crd_spider_init = TRUE; } pthread_mutex_unlock(&share->mutex); @@ -5368,12 +5343,7 @@ int spider_free_share( } #endif spider_free_share_alloc(share); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_tables, - share->table_name_hash_value, (uchar*) share); -#else my_hash_delete(&spider_open_tables, (uchar*) share); -#endif pthread_mutex_destroy(&share->crd_mutex); pthread_mutex_destroy(&share->sts_mutex); pthread_mutex_destroy(&share->mutex); @@ -5458,13 +5428,8 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( } uint old_elements = spider_lgtm_tblhnd_share_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_lgtm_tblhnd_share_hash, - hash_value, (uchar*) lgtm_tblhnd_share)) -#else if (my_hash_insert(&spider_lgtm_tblhnd_share_hash, (uchar*) lgtm_tblhnd_share)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_hash_insert; @@ -5500,12 +5465,7 @@ void spider_free_lgtm_tblhnd_share_alloc( DBUG_ENTER("spider_free_lgtm_tblhnd_share"); if (!locked) pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_lgtm_tblhnd_share_hash, - lgtm_tblhnd_share->table_path_hash_value, (uchar*) lgtm_tblhnd_share); -#else my_hash_delete(&spider_lgtm_tblhnd_share_hash, (uchar*) lgtm_tblhnd_share); -#endif pthread_mutex_destroy(&lgtm_tblhnd_share->auto_increment_mutex); spider_free(spider_current_trx, lgtm_tblhnd_share, MYF(0)); if (!locked) @@ -5570,13 +5530,7 @@ SPIDER_WIDE_SHARE *spider_get_wide_share( thr_lock_init(&wide_share->lock); uint old_elements = spider_open_wide_share.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_open_wide_share, - share->table_path_hash_value, - (uchar*) wide_share)) -#else if (my_hash_insert(&spider_open_wide_share, (uchar*) wide_share)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_hash_insert; @@ -5614,12 +5568,7 @@ int spider_free_wide_share( if (!--wide_share->use_count) { thr_lock_delete(&wide_share->lock); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_wide_share, - wide_share->table_path_hash_value, (uchar*) wide_share); -#else my_hash_delete(&spider_open_wide_share, (uchar*) wide_share); -#endif pthread_mutex_destroy(&wide_share->crd_mutex); pthread_mutex_destroy(&wide_share->sts_mutex); spider_free(spider_current_trx, wide_share, MYF(0)); @@ -6087,14 +6036,8 @@ int spider_db_done( while ((table_mon_list = (SPIDER_TABLE_MON_LIST *) my_hash_element( &spider_udf_table_mon_list_hash[roop_count], 0))) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value( - &spider_udf_table_mon_list_hash[roop_count], - table_mon_list->key_hash_value, (uchar*) table_mon_list); -#else my_hash_delete(&spider_udf_table_mon_list_hash[roop_count], (uchar*) table_mon_list); -#endif spider_ping_table_free_mon_list(table_mon_list); } spider_free_mem_calc(spider_current_trx, @@ -6130,12 +6073,7 @@ int spider_db_done( pthread_mutex_lock(&spider_conn_mutex); while ((conn = (SPIDER_CONN*) my_hash_element(&spider_open_connections, 0))) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_open_connections, - conn->conn_key_hash_value, (uchar*) conn); -#else my_hash_delete(&spider_open_connections, (uchar*) conn); -#endif spider_free_conn(conn); } pthread_mutex_unlock(&spider_conn_mutex); @@ -6178,14 +6116,8 @@ int spider_db_done( while ((spider_init_error_table = (SPIDER_INIT_ERROR_TABLE*) my_hash_element(&spider_init_error_tables, 0))) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_init_error_tables, - spider_init_error_table->table_name_hash_value, - (uchar*) spider_init_error_table); -#else my_hash_delete(&spider_init_error_tables, (uchar*) spider_init_error_table); -#endif spider_free(NULL, spider_init_error_table, MYF(0)); } pthread_mutex_unlock(&spider_init_error_tbl_mutex); @@ -7206,13 +7138,8 @@ SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table( spider_init_error_table->table_name_hash_value = share->table_name_hash_value; uint old_elements = spider_init_error_tables.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_init_error_tables, - share->table_name_hash_value, (uchar*) spider_init_error_table)) -#else if (my_hash_insert(&spider_init_error_tables, (uchar*) spider_init_error_table)) -#endif { spider_free(trx, spider_init_error_table, MYF(0)); pthread_mutex_unlock(&spider_init_error_tbl_mutex); @@ -7243,14 +7170,8 @@ void spider_delete_init_error_table( my_hash_search_using_hash_value(&spider_init_error_tables, hash_value, (uchar*) name, length))) { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_init_error_tables, - spider_init_error_table->table_name_hash_value, - (uchar*) spider_init_error_table); -#else my_hash_delete(&spider_init_error_tables, (uchar*) spider_init_error_table); -#endif spider_free(spider_current_trx, spider_init_error_table, MYF(0)); } pthread_mutex_unlock(&spider_init_error_tbl_mutex); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index f04c3659d6f..11dc7a81ad8 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -378,12 +378,7 @@ void spider_free_trx_alter_table_alloc( SPIDER_ALTER_TABLE *alter_table ) { DBUG_ENTER("spider_free_trx_alter_table_alloc"); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_alter_table_hash, - alter_table->table_name_hash_value, (uchar*) alter_table); -#else my_hash_delete(&trx->trx_alter_table_hash, (uchar*) alter_table); -#endif if (alter_table->tmp_char) spider_free(trx, alter_table->tmp_char, MYF(0)); spider_free(trx, alter_table, MYF(0)); @@ -799,12 +794,7 @@ int spider_create_trx_alter_table( share_alter->tmp_link_statuses_length; old_elements = trx->trx_alter_table_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_alter_table_hash, - alter_table->table_name_hash_value, (uchar*) alter_table)) -#else if (my_hash_insert(&trx->trx_alter_table_hash, (uchar*) alter_table)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error; @@ -1277,12 +1267,7 @@ SPIDER_TRX *spider_get_trx( { pthread_mutex_lock(&spider_allocated_thds_mutex); uint old_elements = spider_allocated_thds.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_allocated_thds, - trx->thd_hash_value, (uchar*) thd)) -#else if (my_hash_insert(&spider_allocated_thds, (uchar*) thd)) -#endif { pthread_mutex_unlock(&spider_allocated_thds_mutex); goto error_allocated_thds_insert; @@ -1388,12 +1373,7 @@ int spider_free_trx( { if (need_lock) pthread_mutex_lock(&spider_allocated_thds_mutex); -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_allocated_thds, - trx->thd_hash_value, (uchar*) trx->thd); -#else my_hash_delete(&spider_allocated_thds, (uchar*) trx->thd); -#endif if (need_lock) pthread_mutex_unlock(&spider_allocated_thds_mutex); } @@ -1552,17 +1532,7 @@ static int spider_xa_lock( error_num = ER_SPIDER_XA_LOCKED_NUM; goto error; } -#ifdef HASH_UPDATE_WITH_HASH_VALUE -#ifdef XID_CACHE_IS_SPLITTED - if (my_hash_insert_with_hash_value(&spd_db_att_xid_cache[idx], hash_value, - (uchar*)xid_state)) -#else - if (my_hash_insert_with_hash_value(spd_db_att_xid_cache, hash_value, - (uchar*)xid_state)) -#endif -#else if (my_hash_insert(spd_db_att_xid_cache, (uchar*)xid_state)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error; @@ -1597,13 +1567,6 @@ static int spider_xa_unlock( DBUG_ENTER("spider_xa_unlock"); #ifdef SPIDER_XID_USES_xid_cache_iterate #else -#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE) - my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache, - (uchar*) xid_state->xid.key(), xid_state->xid.key_length()); -#ifdef XID_CACHE_IS_SPLITTED - uint idx = hash_value % *spd_db_att_xid_cache_split_num; -#endif -#endif #endif old_proc_info = thd_proc_info(thd, "Unlocking xid by Spider"); #ifdef SPIDER_XID_USES_xid_cache_iterate @@ -1614,17 +1577,7 @@ static int spider_xa_unlock( #else pthread_mutex_lock(spd_db_att_LOCK_xid_cache); #endif -#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE) -#ifdef XID_CACHE_IS_SPLITTED - my_hash_delete_with_hash_value(&spd_db_att_xid_cache[idx], - hash_value, (uchar *)xid_state); -#else - my_hash_delete_with_hash_value(spd_db_att_xid_cache, - hash_value, (uchar *)xid_state); -#endif -#else my_hash_delete(spd_db_att_xid_cache, (uchar *)xid_state); -#endif #ifdef XID_CACHE_IS_SPLITTED pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]); #else @@ -3785,12 +3738,7 @@ int spider_create_trx_ha( ) { DBUG_PRINT("info",("spider need recreate")); need_create = TRUE; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_ha_hash, - share->table_name_hash_value, (uchar*) trx_ha); -#else my_hash_delete(&trx->trx_ha_hash, (uchar*) trx_ha); -#endif spider_free(trx, trx_ha, MYF(0)); } else { DBUG_PRINT("info",("spider use this")); @@ -3820,12 +3768,7 @@ int spider_create_trx_ha( trx_ha->conn_can_fo = conn_can_fo; trx_ha->wait_for_reusing = FALSE; uint old_elements = trx->trx_ha_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_ha_hash, - share->table_name_hash_value, (uchar*) trx_ha)) -#else if (my_hash_insert(&trx->trx_ha_hash, (uchar*) trx_ha)) -#endif { spider_free(trx, trx_ha, MYF(0)); DBUG_RETURN(HA_ERR_OUT_OF_MEM); From e7570c7759ea5bb13b64e8dafec176cbbda97adb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 17 Jun 2024 13:15:42 +0800 Subject: [PATCH 44/54] MDEV-31788 Remove spider_file_pos They are for unnecessary debugging purposes only. --- storage/spider/ha_spider.cc | 47 ---------- storage/spider/spd_conn.cc | 10 -- storage/spider/spd_db_conn.cc | 123 ------------------------ storage/spider/spd_db_mysql.cc | 124 ------------------------- storage/spider/spd_db_oracle.cc | 64 ------------- storage/spider/spd_direct_sql.cc | 1 - storage/spider/spd_group_by_handler.cc | 3 - storage/spider/spd_include.h | 14 --- storage/spider/spd_table.cc | 3 - 9 files changed, 389 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 814eee073be..8fff0c5b673 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1761,7 +1761,6 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if ( @@ -1771,7 +1770,6 @@ int ha_spider::index_read_map_internal( ) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -1787,7 +1785,6 @@ int ha_spider::index_read_map_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -1884,7 +1881,6 @@ int ha_spider::index_read_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -2221,14 +2217,12 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -2244,7 +2238,6 @@ int ha_spider::index_read_last_map_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -2341,7 +2334,6 @@ int ha_spider::index_read_last_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -2676,14 +2668,12 @@ int ha_spider::index_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -2699,7 +2689,6 @@ int ha_spider::index_first_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -2796,7 +2785,6 @@ int ha_spider::index_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -3048,14 +3036,12 @@ int ha_spider::index_last_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -3071,7 +3057,6 @@ int ha_spider::index_last_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -3168,7 +3153,6 @@ int ha_spider::index_last_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -3478,14 +3462,12 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -3501,7 +3483,6 @@ int ha_spider::read_range_first_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -3598,7 +3579,6 @@ int ha_spider::read_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -4091,14 +4071,12 @@ int ha_spider::read_multi_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = (char *) mrr_cur_range.ptr; @@ -4120,7 +4098,6 @@ int ha_spider::read_multi_range_first_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -4218,7 +4195,6 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -4867,7 +4843,6 @@ int ha_spider::read_multi_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -4875,7 +4850,6 @@ int ha_spider::read_multi_range_first_internal( { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -4897,7 +4871,6 @@ int ha_spider::read_multi_range_first_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -5039,7 +5012,6 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -5502,14 +5474,12 @@ int ha_spider::read_multi_range_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -5531,7 +5501,6 @@ int ha_spider::read_multi_range_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -5629,7 +5598,6 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -6277,7 +6245,6 @@ int ha_spider::read_multi_range_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -6285,7 +6252,6 @@ int ha_spider::read_multi_range_next( { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -6307,7 +6273,6 @@ int ha_spider::read_multi_range_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -6449,7 +6414,6 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -6934,7 +6898,6 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -6948,7 +6911,6 @@ int ha_spider::rnd_next_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7045,7 +7007,6 @@ int ha_spider::rnd_next_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -7552,7 +7513,6 @@ int ha_spider::ft_read_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7564,7 +7524,6 @@ int ha_spider::ft_read_internal( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7661,7 +7620,6 @@ int ha_spider::ft_read_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -10350,7 +10308,6 @@ void ha_spider::bulk_req_exec() spider_bg_conn_wait(conn); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10375,7 +10332,6 @@ void ha_spider::bulk_req_exec() DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } conn = conn->bulk_access_next; @@ -11998,7 +11954,6 @@ int ha_spider::drop_tmp_tables() DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12010,7 +11965,6 @@ int ha_spider::drop_tmp_tables() DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -12077,7 +12031,6 @@ int ha_spider::drop_tmp_tables() DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 7c65f1d02eb..434a20e9e3e 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -276,7 +276,6 @@ int spider_free_conn_alloc( conn->db_conn = NULL; } spider_conn_done(conn); - DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); pthread_mutex_destroy(&conn->mta_conn_mutex); conn->default_database.free(); DBUG_RETURN(0); @@ -1458,10 +1457,6 @@ void spider_conn_clear_queue( ) { DBUG_ENTER("spider_conn_clear_queue"); DBUG_PRINT("info", ("spider conn=%p", conn)); -/* - conn->queued_connect = FALSE; - conn->queued_ping = FALSE; -*/ conn->queued_trx_isolation = FALSE; conn->queued_semi_trx_isolation = FALSE; conn->queued_autocommit = FALSE; @@ -2593,7 +2588,6 @@ void *spider_bg_conn_action( } } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -2689,10 +2683,8 @@ void *spider_bg_conn_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } else { @@ -2770,7 +2762,6 @@ void *spider_bg_conn_action( spider = (ha_spider*) conn->bg_target; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[conn->link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2786,7 +2777,6 @@ void *spider_bg_conn_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); conn->bg_exec_sql = FALSE; continue; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 046e024522f..7d786492bfe 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -179,7 +179,6 @@ int spider_db_ping_internal( int error_num; DBUG_ENTER("spider_db_ping_internal"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if (conn->server_lost || conn->queued_connect) { if ((error_num = spider_db_connect(share, conn, all_link_idx))) @@ -570,7 +569,6 @@ int spider_db_before_query( #endif conn->in_before_query = TRUE; pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ((error_num = spider_db_conn_queue_action(conn))) { conn->in_before_query = FALSE; @@ -676,7 +674,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); @@ -698,7 +695,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); @@ -711,7 +707,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); @@ -737,7 +732,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(error_num); @@ -759,7 +753,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(error_num); @@ -767,7 +760,6 @@ int spider_db_errorno( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(0); @@ -791,7 +783,6 @@ int spider_db_set_names_internal( ) { DBUG_ENTER("spider_db_set_names_internal"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); if ( @@ -944,7 +935,6 @@ int spider_db_query_for_bulk_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[link_idx] && @@ -1032,7 +1022,6 @@ int spider_db_query_for_bulk_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[link_idx] && @@ -1061,7 +1050,6 @@ int spider_db_query_for_bulk_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -3594,7 +3582,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); @@ -3611,7 +3598,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3643,7 +3629,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3688,7 +3673,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3729,7 +3713,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(error_num); @@ -3758,7 +3741,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later && !call_db_errorno) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(HA_ERR_END_OF_FILE); @@ -3766,7 +3748,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } current->record_num = current->result->num_rows(); @@ -3810,7 +3791,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } else { @@ -3835,7 +3815,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -3847,7 +3826,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -4760,7 +4738,6 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if (conn->db_conn->limit_mode() == 1) { conn->db_conn->set_limit(result_list->limit_num); @@ -4769,12 +4746,10 @@ int spider_db_seek_next( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, link_idx, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[link_idx]; @@ -4788,7 +4763,6 @@ int spider_db_seek_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( spider->need_mons[link_idx] @@ -4842,7 +4816,6 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, link_idx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -4872,7 +4845,6 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if (conn->db_conn->limit_mode() == 1) { conn->db_conn->set_limit(result_list->limit_num); @@ -4881,12 +4853,10 @@ int spider_db_seek_next( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, link_idx, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[roop_count]; @@ -4900,7 +4870,6 @@ int spider_db_seek_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -5001,7 +4970,6 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -5145,7 +5113,6 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (conn->db_conn->limit_mode() == 1) { @@ -5155,12 +5122,10 @@ int spider_db_seek_last( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, roop_count, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[roop_count]; @@ -5174,7 +5139,6 @@ int spider_db_seek_last( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -5272,7 +5236,6 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -5367,7 +5330,6 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -5380,7 +5342,6 @@ int spider_db_seek_last( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -5478,7 +5439,6 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -6138,7 +6098,6 @@ int spider_db_bulk_insert( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count2]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6152,7 +6111,6 @@ int spider_db_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count2] && @@ -6197,7 +6155,6 @@ int spider_db_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( error_num != ER_DUP_ENTRY && @@ -6234,7 +6191,6 @@ int spider_db_bulk_insert( insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) { @@ -6246,7 +6202,6 @@ int spider_db_bulk_insert( conn = first_insert_conn; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[first_insert_link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6275,7 +6230,6 @@ int spider_db_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -6290,7 +6244,6 @@ int spider_db_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -6299,7 +6252,6 @@ int spider_db_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); spider->store_last_insert_id = 0; #ifdef HA_CAN_BULK_ACCESS @@ -6337,7 +6289,6 @@ int spider_db_bulk_bulk_insert( conn = spider->conns[roop_count2]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -6351,7 +6302,6 @@ int spider_db_bulk_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) { @@ -6363,7 +6313,6 @@ int spider_db_bulk_bulk_insert( conn = first_insert_conn; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[first_insert_link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6397,7 +6346,6 @@ int spider_db_bulk_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); spider->store_last_insert_id = 0; DBUG_RETURN(error_num); @@ -6512,7 +6460,6 @@ int spider_db_bulk_update_size_limit( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, &dup_key_found))) { @@ -6596,7 +6543,6 @@ int spider_db_bulk_update_end( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, dup_key_found))) { @@ -6635,7 +6581,6 @@ int spider_db_bulk_update_end( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, dup_key_found))) { @@ -6715,7 +6660,6 @@ int spider_db_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6727,7 +6671,6 @@ int spider_db_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -6806,7 +6749,6 @@ int spider_db_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -6855,7 +6797,6 @@ int spider_db_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); result_list->update_sqls[roop_count].length(0); } @@ -6976,7 +6917,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -6995,7 +6935,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7078,7 +7017,6 @@ int spider_db_direct_update( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7187,7 +7125,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7206,7 +7143,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7290,7 +7226,6 @@ int spider_db_direct_update( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7322,7 +7257,6 @@ int spider_db_bulk_direct_update( conn = spider->conns[roop_count]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -7344,7 +7278,6 @@ int spider_db_bulk_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(error_num); @@ -7405,7 +7338,6 @@ int spider_db_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -7417,7 +7349,6 @@ int spider_db_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -7425,7 +7356,6 @@ int spider_db_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); result_list->update_sqls[roop_count].length(0); } @@ -7517,7 +7447,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7536,7 +7465,6 @@ int spider_db_direct_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7611,7 +7539,6 @@ int spider_db_direct_delete( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7696,7 +7623,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7715,7 +7641,6 @@ int spider_db_direct_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7790,7 +7715,6 @@ int spider_db_direct_delete( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7833,7 +7757,6 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7864,7 +7787,6 @@ int spider_db_delete_all_rows( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7895,7 +7817,6 @@ int spider_db_delete_all_rows( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7962,7 +7883,6 @@ int spider_db_delete_all_rows( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7992,7 +7912,6 @@ int spider_db_delete_all_rows( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) @@ -9803,7 +9722,6 @@ int spider_db_udf_direct_sql( pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10034,7 +9952,6 @@ int spider_db_udf_direct_sql( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (need_trx_end && insert_start) { @@ -10068,7 +9985,6 @@ int spider_db_udf_direct_sql_select_db( if ( spider_dbton[conn->dbton_id].db_util->database_has_default_value() ) { - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->default_database.length() || conn->default_database.length() != @@ -10111,7 +10027,6 @@ int spider_db_udf_direct_sql_set_names( int error_num, need_mon = 0; DBUG_ENTER("spider_db_udf_direct_sql_set_names"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->access_charset || trx->udf_access_charset->cset != conn->access_charset->cset @@ -10198,7 +10113,6 @@ int spider_db_udf_ping_table( spider.db_request_id = &db_request_id; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10210,7 +10124,6 @@ int spider_db_udf_ping_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); @@ -10227,7 +10140,6 @@ int spider_db_udf_ping_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (!ping_only) { @@ -10273,7 +10185,6 @@ int spider_db_udf_ping_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10285,7 +10196,6 @@ int spider_db_udf_ping_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); @@ -10317,7 +10227,6 @@ int spider_db_udf_ping_table( conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; spider_db_discard_result(&spider, 0, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); } @@ -10536,7 +10445,6 @@ int spider_db_udf_ping_table_mon_next( pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10548,7 +10456,6 @@ int spider_db_udf_ping_table_mon_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); @@ -10561,7 +10468,6 @@ int spider_db_udf_ping_table_mon_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); DBUG_RETURN(error_num); @@ -10595,7 +10501,6 @@ int spider_db_udf_ping_table_mon_next( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); DBUG_RETURN(error_num); @@ -10613,7 +10518,6 @@ int spider_db_udf_ping_table_mon_next( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); error_num = res->fetch_table_mon_status(mon_table_result->result_status); @@ -10699,7 +10603,6 @@ int spider_db_udf_copy_tables( { pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &tmp_spider->need_mons[0]; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10711,7 +10614,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); @@ -10727,7 +10629,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_start_transaction; } @@ -10735,7 +10636,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -10758,7 +10658,6 @@ int spider_db_udf_copy_tables( tmp_conn = tmp_spider->conns[0]; pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &tmp_spider->need_mons[0]; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10770,7 +10669,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); @@ -10788,7 +10686,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); tmp_conn->table_lock = 0; if (error_num == HA_ERR_OUT_OF_MEM) @@ -10799,7 +10696,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); tmp_conn->table_lock = 1; } @@ -10810,7 +10706,6 @@ int spider_db_udf_copy_tables( copy_tables->trx->thd, src_tbl_conn->share); pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &src_tbl_conn->need_mon; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10857,7 +10752,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10876,7 +10770,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10906,7 +10799,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10925,7 +10817,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); error_num = ER_OUT_OF_RESOURCES; goto error_db_query; @@ -10941,7 +10832,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10951,7 +10841,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; dst_tbl_conn = dst_tbl_conn->next) @@ -10975,7 +10864,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -10988,7 +10876,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -11032,7 +10919,6 @@ int spider_db_udf_copy_tables( insert_ct = dst_tbl_conn->copy_table; pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &dst_tbl_conn->need_mon; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -11059,7 +10945,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -11205,9 +11090,7 @@ int spider_db_open_handler( DBUG_ENTER("spider_db_open_handler"); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -11251,7 +11134,6 @@ int spider_db_open_handler( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); @@ -11260,7 +11142,6 @@ error: DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11292,7 +11173,6 @@ int spider_db_close_handler( DBUG_PRINT("info",("spider conn=%p", conn)); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11308,7 +11188,6 @@ int spider_db_close_handler( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11335,7 +11214,6 @@ int spider_db_close_handler( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); @@ -11344,7 +11222,6 @@ error: DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ed92a5d2e64..62fb57c8724 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2496,7 +2496,6 @@ int spider_db_mbase::consistent_snapshot( DBUG_PRINT("info",("spider this=%p", this)); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2519,7 +2518,6 @@ int spider_db_mbase::consistent_snapshot( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2558,7 +2556,6 @@ int spider_db_mbase::commit( DBUG_PRINT("info",("spider this=%p", this)); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2581,7 +2578,6 @@ int spider_db_mbase::commit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2595,7 +2591,6 @@ int spider_db_mbase::rollback( DBUG_PRINT("info",("spider this=%p", this)); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2620,7 +2615,6 @@ int spider_db_mbase::rollback( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -2629,7 +2623,6 @@ int spider_db_mbase::rollback( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2666,7 +2659,6 @@ int spider_db_mbase::xa_end( spider_db_append_xid_str(&sql_str, xid); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2689,7 +2681,6 @@ int spider_db_mbase::xa_end( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2709,7 +2700,6 @@ int spider_db_mbase::xa_prepare( spider_db_append_xid_str(&sql_str, xid); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2732,7 +2722,6 @@ int spider_db_mbase::xa_prepare( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2752,7 +2741,6 @@ int spider_db_mbase::xa_commit( spider_db_append_xid_str(&sql_str, xid); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2775,7 +2763,6 @@ int spider_db_mbase::xa_commit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2795,7 +2782,6 @@ int spider_db_mbase::xa_rollback( spider_db_append_xid_str(&sql_str, xid); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2818,7 +2804,6 @@ int spider_db_mbase::xa_rollback( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -2841,7 +2826,6 @@ int spider_db_mbase::set_trx_isolation( case ISO_READ_UNCOMMITTED: pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2864,13 +2848,11 @@ int spider_db_mbase::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; case ISO_READ_COMMITTED: pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2893,13 +2875,11 @@ int spider_db_mbase::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; case ISO_REPEATABLE_READ: pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2922,13 +2902,11 @@ int spider_db_mbase::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; case ISO_SERIALIZABLE: pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2951,7 +2929,6 @@ int spider_db_mbase::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; default: @@ -2977,7 +2954,6 @@ int spider_db_mbase::set_autocommit( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3000,12 +2976,10 @@ int spider_db_mbase::set_autocommit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3028,7 +3002,6 @@ int spider_db_mbase::set_autocommit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(0); @@ -3051,7 +3024,6 @@ int spider_db_mbase::set_sql_log_off( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3074,12 +3046,10 @@ int spider_db_mbase::set_sql_log_off( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3102,7 +3072,6 @@ int spider_db_mbase::set_sql_log_off( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(0); @@ -3135,7 +3104,6 @@ int spider_db_mbase::set_wait_timeout( sql_str.q_append(timeout_str, timeout_str_length); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3158,7 +3126,6 @@ int spider_db_mbase::set_wait_timeout( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -3200,7 +3167,6 @@ int spider_db_mbase::set_sql_mode( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3223,7 +3189,6 @@ int spider_db_mbase::set_sql_mode( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -3254,7 +3219,6 @@ int spider_db_mbase::set_time_zone( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3277,7 +3241,6 @@ int spider_db_mbase::set_time_zone( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -3295,7 +3258,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result"); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3328,7 +3290,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -3340,7 +3301,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -3366,7 +3326,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -3380,7 +3339,6 @@ int spider_db_mbase::exec_simple_sql_with_result( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -3399,7 +3357,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -7955,7 +7912,6 @@ int spider_mbase_share::discover_table_structure( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7979,7 +7935,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8004,7 +7959,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8025,7 +7979,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8035,7 +7988,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8049,7 +8001,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), @@ -8067,7 +8018,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8081,7 +8031,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8091,7 +8040,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8105,7 +8053,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8118,7 +8065,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8132,7 +8078,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8142,7 +8087,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8156,7 +8100,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); continue; } @@ -8166,7 +8109,6 @@ int spider_mbase_share::discover_table_structure( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (!error_num) break; @@ -13473,7 +13415,6 @@ int spider_mbase_handler::show_table_status( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13507,7 +13448,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13518,7 +13458,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13545,7 +13484,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13563,7 +13501,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -13576,7 +13513,6 @@ int spider_mbase_handler::show_table_status( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13596,7 +13532,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_status( sts_mode, @@ -13631,7 +13566,6 @@ int spider_mbase_handler::show_table_status( } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13665,7 +13599,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13676,7 +13609,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13703,7 +13635,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13721,7 +13652,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -13742,7 +13672,6 @@ int spider_mbase_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_status( sts_mode, @@ -13822,7 +13751,6 @@ int spider_mbase_handler::show_index( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13854,7 +13782,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13864,7 +13791,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13889,7 +13815,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13908,7 +13833,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13918,7 +13842,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (res) { @@ -13972,7 +13895,6 @@ int spider_mbase_handler::show_index( } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14004,7 +13926,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14014,7 +13935,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14039,7 +13959,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14058,7 +13977,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14068,7 +13986,6 @@ int spider_mbase_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (res) { @@ -14175,7 +14092,6 @@ int spider_mbase_handler::simple_action( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14207,7 +14123,6 @@ int spider_mbase_handler::simple_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -14218,7 +14133,6 @@ int spider_mbase_handler::simple_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -14245,7 +14159,6 @@ int spider_mbase_handler::simple_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -14265,7 +14178,6 @@ int spider_mbase_handler::simple_action( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -14284,7 +14196,6 @@ int spider_mbase_handler::simple_action( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); switch (simple_action) { @@ -14364,7 +14275,6 @@ ha_rows spider_mbase_handler::explain_select( pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14398,7 +14308,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -14410,7 +14319,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -14431,7 +14339,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -14442,7 +14349,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -14463,7 +14369,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } else { @@ -14472,7 +14377,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -14481,7 +14385,6 @@ ha_rows spider_mbase_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 2, @@ -14513,7 +14416,6 @@ int spider_mbase_handler::lock_tables( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14525,7 +14427,6 @@ int spider_mbase_handler::lock_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14549,7 +14450,6 @@ int spider_mbase_handler::lock_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } if (!conn->table_locked) @@ -14584,7 +14484,6 @@ int spider_mbase_handler::unlock_tables( spider->share); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14607,7 +14506,6 @@ int spider_mbase_handler::unlock_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -14630,7 +14528,6 @@ int spider_mbase_handler::disable_keys( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14642,7 +14539,6 @@ int spider_mbase_handler::disable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14667,7 +14563,6 @@ int spider_mbase_handler::disable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14688,7 +14583,6 @@ int spider_mbase_handler::enable_keys( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14700,7 +14594,6 @@ int spider_mbase_handler::enable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14725,7 +14618,6 @@ int spider_mbase_handler::enable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14747,7 +14639,6 @@ int spider_mbase_handler::check_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14759,7 +14650,6 @@ int spider_mbase_handler::check_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14784,7 +14674,6 @@ int spider_mbase_handler::check_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14806,7 +14695,6 @@ int spider_mbase_handler::repair_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14818,7 +14706,6 @@ int spider_mbase_handler::repair_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14843,7 +14730,6 @@ int spider_mbase_handler::repair_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14864,7 +14750,6 @@ int spider_mbase_handler::analyze_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14876,7 +14761,6 @@ int spider_mbase_handler::analyze_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14901,7 +14785,6 @@ int spider_mbase_handler::analyze_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14922,7 +14805,6 @@ int spider_mbase_handler::optimize_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14934,7 +14816,6 @@ int spider_mbase_handler::optimize_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -14959,7 +14840,6 @@ int spider_mbase_handler::optimize_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -14984,7 +14864,6 @@ int spider_mbase_handler::flush_tables( share); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -15008,7 +14887,6 @@ int spider_mbase_handler::flush_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -15026,7 +14904,6 @@ int spider_mbase_handler::flush_logs( share); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -15050,7 +14927,6 @@ int spider_mbase_handler::flush_logs( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index e0eeaf2975b..9ed1aa32a96 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2011,7 +2011,6 @@ int spider_db_oracle::set_trx_isolation( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2034,7 +2033,6 @@ int spider_db_oracle::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; case ISO_REPEATABLE_READ: @@ -2046,7 +2044,6 @@ int spider_db_oracle::set_trx_isolation( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2069,7 +2066,6 @@ int spider_db_oracle::set_trx_isolation( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); break; default: @@ -2100,7 +2096,6 @@ int spider_db_oracle::set_autocommit( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2123,7 +2118,6 @@ int spider_db_oracle::set_autocommit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { if (conn->in_before_query) @@ -2133,7 +2127,6 @@ int spider_db_oracle::set_autocommit( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2156,7 +2149,6 @@ int spider_db_oracle::set_autocommit( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } DBUG_RETURN(0); @@ -10844,7 +10836,6 @@ int spider_oracle_handler::show_table_status( } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10876,7 +10867,6 @@ int spider_oracle_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -10886,7 +10876,6 @@ int spider_oracle_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -10911,7 +10900,6 @@ int spider_oracle_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -10937,7 +10925,6 @@ int spider_oracle_handler::show_table_status( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_status( sts_mode, @@ -10996,7 +10983,6 @@ int spider_oracle_handler::show_index( } else { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11028,7 +11014,6 @@ int spider_oracle_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11038,7 +11023,6 @@ int spider_oracle_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11063,7 +11047,6 @@ int spider_oracle_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11082,7 +11065,6 @@ int spider_oracle_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11092,7 +11074,6 @@ int spider_oracle_handler::show_index( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (res) { @@ -11137,7 +11118,6 @@ int spider_oracle_handler::show_records( DBUG_ENTER("spider_oracle_handler::show_records"); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11169,7 +11149,6 @@ int spider_oracle_handler::show_records( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -11180,7 +11159,6 @@ int spider_oracle_handler::show_records( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -11207,7 +11185,6 @@ int spider_oracle_handler::show_records( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -11227,7 +11204,6 @@ int spider_oracle_handler::show_records( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -11246,7 +11222,6 @@ int spider_oracle_handler::show_records( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 1, @@ -11278,7 +11253,6 @@ int spider_oracle_handler::show_autoinc( pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11310,7 +11284,6 @@ int spider_oracle_handler::show_autoinc( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -11321,7 +11294,6 @@ int spider_oracle_handler::show_autoinc( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -11348,7 +11320,6 @@ int spider_oracle_handler::show_autoinc( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -11368,7 +11339,6 @@ int spider_oracle_handler::show_autoinc( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -11387,7 +11357,6 @@ int spider_oracle_handler::show_autoinc( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 1, @@ -11496,7 +11465,6 @@ ha_rows spider_oracle_handler::explain_select( pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11530,7 +11498,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -11542,7 +11509,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -11563,7 +11529,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -11574,7 +11539,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -11595,7 +11559,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } else { @@ -11604,7 +11567,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(HA_POS_ERROR); } @@ -11613,7 +11575,6 @@ ha_rows spider_oracle_handler::explain_select( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 2, @@ -11646,7 +11607,6 @@ int spider_oracle_handler::lock_tables( { pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11658,7 +11618,6 @@ int spider_oracle_handler::lock_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11682,7 +11641,6 @@ int spider_oracle_handler::lock_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } if (!conn->table_locked) @@ -11727,7 +11685,6 @@ int spider_oracle_handler::disable_keys( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11739,7 +11696,6 @@ int spider_oracle_handler::disable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11764,7 +11720,6 @@ int spider_oracle_handler::disable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -11786,7 +11741,6 @@ int spider_oracle_handler::enable_keys( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11798,7 +11752,6 @@ int spider_oracle_handler::enable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11823,7 +11776,6 @@ int spider_oracle_handler::enable_keys( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -11846,7 +11798,6 @@ int spider_oracle_handler::check_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11858,7 +11809,6 @@ int spider_oracle_handler::check_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11883,7 +11833,6 @@ int spider_oracle_handler::check_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -11906,7 +11855,6 @@ int spider_oracle_handler::repair_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11918,7 +11866,6 @@ int spider_oracle_handler::repair_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -11943,7 +11890,6 @@ int spider_oracle_handler::repair_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -11965,7 +11911,6 @@ int spider_oracle_handler::analyze_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11977,7 +11922,6 @@ int spider_oracle_handler::analyze_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -12002,7 +11946,6 @@ int spider_oracle_handler::analyze_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -12024,7 +11967,6 @@ int spider_oracle_handler::optimize_table( } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12036,7 +11978,6 @@ int spider_oracle_handler::optimize_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -12061,7 +12002,6 @@ int spider_oracle_handler::optimize_table( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -12087,7 +12027,6 @@ int spider_oracle_handler::flush_tables( share); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12111,7 +12050,6 @@ int spider_oracle_handler::flush_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } @@ -12129,7 +12067,6 @@ int spider_oracle_handler::flush_logs( share); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12153,7 +12090,6 @@ int spider_oracle_handler::flush_logs( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(0); } diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 0d12b3b25b3..7c7f9aa7558 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -477,7 +477,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( DBUG_RETURN(conn); error: - DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); error_too_many_ipport_count: spider_conn_done(conn); error_conn_init: diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 9b71f5bc13f..fa9f041c83b 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1196,7 +1196,6 @@ static int spider_send_query( SPIDER_SQL_TYPE_SELECT_SQL, link_idx, link_idx_chain))) DBUG_RETURN(error_num); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -1210,7 +1209,6 @@ static int spider_send_query( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); @@ -1268,7 +1266,6 @@ static int spider_send_query( } else { spider_db_discard_result(spider, link_idx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 12320f73742..5627f15bd4f 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -453,11 +453,6 @@ enum spider_malloc_id { #define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM \ if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;} -#define SPIDER_SET_FILE_POS(A) \ - {(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;} -#define SPIDER_CLEAR_FILE_POS(A) \ - {DBUG_PRINT("info", ("spider thd=%p func_name=%s file_name=%s line_no=%lu", (A)->thd, (A)->func_name ? (A)->func_name : "NULL", (A)->file_name ? (A)->file_name : "NULL", (A)->line_no)); (A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;} - class ha_spider; typedef struct st_spider_share SPIDER_SHARE; typedef struct st_spider_table_mon_list SPIDER_TABLE_MON_LIST; @@ -481,14 +476,6 @@ typedef struct st_spider_thread } SPIDER_THREAD; #endif -typedef struct st_spider_file_pos -{ - THD *thd; - const char *func_name; - const char *file_name; - ulong line_no; -} SPIDER_FILE_POS; - typedef struct st_spider_link_for_hash { ha_spider *spider; @@ -610,7 +597,6 @@ typedef struct st_spider_conn pthread_mutex_t mta_conn_mutex; volatile bool mta_conn_mutex_lock_already; volatile bool mta_conn_mutex_unlock_later; - SPIDER_FILE_POS mta_conn_mutex_file_pos; uint join_trx; int trx_isolation; bool semi_trx_isolation_chk; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 145d9dc9c40..1503c61b1bb 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -5741,7 +5741,6 @@ int spider_open_all_tables( conn->error_mode &= spider_param_error_write_mode(thd, 0); pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &mon_val; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5753,7 +5752,6 @@ int spider_open_all_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); spider_sys_index_end(table_tables); spider_close_sys_table(thd, table_tables, @@ -5767,7 +5765,6 @@ int spider_open_all_tables( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2) From f5b7c25e1e2ca9f86a4679422eff16d3e3db45f9 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 18 Jun 2024 10:21:38 +0800 Subject: [PATCH 45/54] MDEV-27643 Spider: remove #ifdef HA_CAN_BULK_ACCESS --- storage/spider/ha_spider.cc | 1242 ------------------------------- storage/spider/ha_spider.h | 141 ---- storage/spider/spd_conn.cc | 14 - storage/spider/spd_db_conn.cc | 232 ------ storage/spider/spd_db_conn.h | 26 - storage/spider/spd_db_include.h | 2 - storage/spider/spd_db_mysql.cc | 4 - storage/spider/spd_db_oracle.cc | 4 - storage/spider/spd_include.h | 27 - storage/spider/spd_param.cc | 25 - storage/spider/spd_param.h | 5 - storage/spider/spd_table.cc | 28 - storage/spider/spd_trx.cc | 41 - storage/spider/spd_trx.h | 6 - 14 files changed, 1797 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 8fff0c5b673..e910ffcff56 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -94,17 +94,6 @@ ha_spider::ha_spider( use_pre_call = FALSE; use_pre_action = FALSE; do_direct_update = FALSE; -#ifdef HA_CAN_BULK_ACCESS - is_bulk_access_clone = FALSE; - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - bulk_access_link_first = NULL; -/* - init_ha_mem_root = FALSE; -*/ -#endif prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; @@ -173,17 +162,6 @@ ha_spider::ha_spider( use_pre_call = FALSE; use_pre_action = FALSE; do_direct_update = FALSE; -#ifdef HA_CAN_BULK_ACCESS - is_bulk_access_clone = FALSE; - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - bulk_access_link_first = NULL; -/* - init_ha_mem_root = FALSE; -*/ -#endif prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; @@ -514,9 +492,6 @@ int ha_spider::open( } else wide_handler->semi_table_lock = spider_param_semi_table_lock(thd, share->semi_table_lock); -#ifdef HA_CAN_BULK_ACCESS - external_lock_cnt = 0; -#endif if (reset()) { @@ -606,22 +581,6 @@ int ha_spider::close() delete [] mrr_key_buff; mrr_key_buff = NULL; } -#endif -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_link_first) - { - do { - DBUG_PRINT("info",("spider bulk_access_link->spider=%p", - bulk_access_link_first->spider)); - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=" - "%p", &bulk_access_link_first->spider->dbton_handler)); - bulk_access_link_current = bulk_access_link_first->next; - delete_bulk_access_link(bulk_access_link_first); - bulk_access_link_first = bulk_access_link_current; - } while (bulk_access_link_first); - } #endif while (direct_aggregate_item_first) { @@ -780,33 +739,6 @@ void ha_spider::check_access_kind( DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::additional_lock( - THD *thd, - enum thr_lock_type lock_type -) { - DBUG_ENTER("ha_spider::additional_lock"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_executing) - { - if (is_bulk_access_clone) - { - check_access_kind(thd); - DBUG_RETURN(check_access_kind_for_connection(thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))); - } else if (bulk_access_link_exec_tgt->called) - { - bulk_access_link_exec_tgt->spider->check_access_kind(thd); - DBUG_RETURN(bulk_access_link_exec_tgt->spider-> - check_access_kind_for_connection( - thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); - } - } - check_access_kind(thd); - DBUG_RETURN(check_access_kind_for_connection(thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))); -} -#endif THR_LOCK_DATA **ha_spider::store_lock( THD *thd, @@ -1144,40 +1076,6 @@ int ha_spider::reset() backup_error_status(); DBUG_ENTER("ha_spider::reset"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_BULK_ACCESS_LINK *tmp_bulk_access_link = bulk_access_link_first; - while (tmp_bulk_access_link) - { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - tmp_bulk_access_link->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &tmp_bulk_access_link->spider->dbton_handler)); - if (!tmp_bulk_access_link->used) - break; - if ((error_num2 = tmp_bulk_access_link->spider->ha_reset())) - error_num = error_num2; - tmp_bulk_access_link->used = FALSE; - tmp_bulk_access_link = tmp_bulk_access_link->next; - } - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - if ( - bulk_access_link_first && - !spider_param_bulk_access_free(share->bulk_access_free) - ) { - do { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &bulk_access_link_first->spider->dbton_handler)); - bulk_access_link_current = bulk_access_link_first->next; - delete_bulk_access_link(bulk_access_link_first); - bulk_access_link_first = bulk_access_link_current; - } while (bulk_access_link_first); - } -#endif direct_aggregate_item_current = direct_aggregate_item_first; while (direct_aggregate_item_current) { @@ -1319,17 +1217,6 @@ int ha_spider::reset() use_fields = FALSE; #endif error_mode = 0; -#ifdef HA_CAN_BULK_ACCESS -#ifndef DBUG_OFF - if (bulk_access_link_first) - { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &bulk_access_link_first->spider->dbton_handler)); - } -#endif -#endif DBUG_RETURN(error_num); } @@ -1438,19 +1325,6 @@ int ha_spider::index_init( DBUG_ENTER("ha_spider::index_init"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider idx=%u", idx)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_index_init( - idx, sorted)); - } - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -1499,16 +1373,6 @@ int ha_spider::index_init( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_index_init( - uint idx, - bool sorted -) { - DBUG_ENTER("ha_spider::pre_index_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_index_init(idx, sorted)); -} -#endif int ha_spider::index_end() { @@ -1516,21 +1380,6 @@ int ha_spider::index_end() backup_error_status(); DBUG_ENTER("ha_spider::index_end"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->ha_index_end(); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif active_index = MAX_KEY; /* #ifdef INFO_KIND_FORCE_LIMIT_BEGIN @@ -1550,14 +1399,6 @@ int ha_spider::index_end() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_index_end() -{ - DBUG_ENTER("ha_spider::pre_index_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_index_end()); -} -#endif int ha_spider::index_read_map_internal( uchar *buf, @@ -1762,17 +1603,6 @@ int ha_spider::index_read_map_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if ( - is_bulk_access_clone && - !bulk_access_executing && - conn_kind[roop_count] != SPIDER_CONN_KIND_MYSQL - ) { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -1883,9 +1713,6 @@ int ha_spider::index_read_map_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -1901,42 +1728,13 @@ int ha_spider::pre_index_read_map( enum ha_rkey_function find_flag, bool use_parallel ) { -#ifdef HA_CAN_BULK_ACCESS - int error_num; -#endif DBUG_ENTER("ha_spider::pre_index_read_map"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider->pre_index_read_map(key, - keypart_map, find_flag, TRUE); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } else if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->pre_index_read_map(key, - keypart_map, find_flag, TRUE)); - } -#endif check_pre_call(use_parallel); if (use_pre_call) { store_error_num = index_read_map_internal(NULL, key, keypart_map, find_flag); -#ifdef HA_CAN_BULK_ACCESS - if ( - !store_error_num && - bulk_access_executing && - is_bulk_access_clone && - !bulk_access_pre_called - ) { - bulk_req_exec(); - } -#endif DBUG_RETURN(store_error_num); } DBUG_RETURN(0); @@ -1951,59 +1749,6 @@ int ha_spider::index_read_map( int error_num; DBUG_ENTER("ha_spider::index_read_map"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if (is_bulk_access_clone) - { - if (bulk_access_pre_called) - { - SPIDER_CONN *conn; - int roop_count, roop_start, roop_end, tmp_lock_mode, link_ok, - tmp_error_num; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - for (roop_count = roop_start; roop_count < roop_end; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - conn = conns[roop_count]; - if ((tmp_error_num = spider_db_bulk_store_result(this, conn, - roop_count, (roop_count != link_ok)))) - { - store_error_num = tmp_error_num; - } else { - result_link_idx = link_ok; - } - } - use_pre_call = TRUE; - bulk_access_pre_called = FALSE; - } else { - /* do access normally */ - } - } else if (bulk_access_link_exec_tgt->called) - { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->index_read_map(buf, key, - keypart_map, find_flag)); - } - } -#endif if (use_pre_call) { if (store_error_num) @@ -2218,14 +1963,6 @@ int ha_spider::index_read_last_map_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2336,9 +2073,6 @@ int ha_spider::index_read_last_map_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2401,21 +2135,6 @@ int ha_spider::index_next( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_next(buf); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -2447,21 +2166,6 @@ int ha_spider::index_prev( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_prev(buf); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -2669,14 +2373,6 @@ int ha_spider::index_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2787,9 +2483,6 @@ int ha_spider::index_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3037,14 +2730,6 @@ int ha_spider::index_last_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3155,9 +2840,6 @@ int ha_spider::index_last_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3231,22 +2913,6 @@ int ha_spider::index_next_same( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_next_same(buf, key, - keylen); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -3463,14 +3129,6 @@ int ha_spider::read_range_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3581,9 +3239,6 @@ int ha_spider::read_range_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -4072,20 +3727,6 @@ int ha_spider::read_multi_range_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = (char *) mrr_cur_range.ptr; -#else - *found_range_p = multi_range_curr; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -4198,9 +3839,6 @@ int ha_spider::read_multi_range_first_internal( pthread_mutex_unlock(&conn->mta_conn_mutex); } } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -4845,20 +4483,6 @@ int ha_spider::read_multi_range_first_internal( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5014,9 +4638,6 @@ int ha_spider::read_multi_range_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -5475,20 +5096,6 @@ int ha_spider::read_multi_range_next( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5601,9 +5208,6 @@ int ha_spider::read_multi_range_next( pthread_mutex_unlock(&conn->mta_conn_mutex); } } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6247,20 +5851,6 @@ int ha_spider::read_multi_range_next( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6416,9 +6006,6 @@ int ha_spider::read_multi_range_next( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6655,15 +6242,6 @@ int ha_spider::rnd_init( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_rnd_init( - bool scan -) { - DBUG_ENTER("ha_spider::pre_rnd_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_init(scan)); -} -#endif int ha_spider::rnd_end() { @@ -6687,14 +6265,6 @@ int ha_spider::rnd_end() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_rnd_end() -{ - DBUG_ENTER("ha_spider::pre_rnd_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_end()); -} -#endif int ha_spider::rnd_next_internal( uchar *buf @@ -8700,8 +8270,6 @@ ulonglong ha_spider::table_flags() const #endif #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON HA_CAN_TABLE_CONDITION_PUSHDOWN | -#endif -#ifdef HA_CAN_BULK_ACCESS #endif SPIDER_CAN_BG_SEARCH | SPIDER_CAN_BG_INSERT | @@ -9046,30 +8614,6 @@ int ha_spider::write_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - ulonglong option_backup = 0; - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_bulk_insert(this)); - } - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_write_row(buf); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9156,35 +8700,9 @@ int ha_spider::write_row( if ((error_num = spider_db_bulk_insert(this, table, ©_info, FALSE))) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - /* bulk access disabled case (like using partitioning) */ - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_bulk_insert(this)); - } -#endif DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_write_row( - uchar *buf -) { - int error_num; - ulonglong option_backup = 0; - THD *thd = wide_handler->trx->thd; - DBUG_ENTER("ha_spider::pre_write_row"); - DBUG_PRINT("info",("spider this=%p", this)); - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_current->spider->ha_write_row(buf); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); -} -#endif void ha_spider::direct_update_init( THD *thd, @@ -9258,20 +8776,6 @@ int ha_spider::update_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - ulonglong option_backup = 0; - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_update_row( - old_data, new_data); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_update_count); #endif @@ -9357,27 +8861,6 @@ int ha_spider::direct_update_rows_init( THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_PRINT("info",("spider return pre_direct_init_result %d", - pre_direct_init_result)); - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data)); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9495,27 +8978,6 @@ int ha_spider::direct_update_rows_init( } } } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_PRINT("info",("spider return pre_direct_init_result %d", - pre_direct_init_result)); - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider-> - direct_update_rows_init(update_fields)); - } -#endif if (!dml_inited) { if (unlikely(dml_init())) @@ -9586,78 +9048,6 @@ int ha_spider::direct_update_rows_init( } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_update_rows_init( - List *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); - DBUG_RETURN(pre_direct_init_result); -} -#else -/** - Do initialization for performing parallel direct update - for a handlersocket update request. - - @param update fields Pointer to the list of fields to update. - - @return >0 Error. - 0 Success. -*/ - -int ha_spider::pre_direct_update_rows_init( - List *update_fields -) -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init(update_fields); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_update_rows_init(update_fields); - DBUG_RETURN(pre_direct_init_result); -} -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int ha_spider::direct_update_rows( @@ -9679,26 +9069,6 @@ int ha_spider::direct_update_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_update_rows( - ranges, range_count, sorted, new_data, update_rows, found_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -9707,13 +9077,6 @@ int ha_spider::direct_update_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } -#endif DBUG_RETURN(0); } #else @@ -9732,26 +9095,6 @@ int ha_spider::direct_update_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_update_rows( - update_rows, found_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -9759,44 +9102,10 @@ int ha_spider::direct_update_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } -#endif DBUG_RETURN(0); } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_update_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data, - ha_rows *update_rows, - ha_rows *found_rows -) { - DBUG_ENTER("ha_spider::pre_direct_update_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_update_rows(ranges, - range_count, sorted, new_data, update_rows, found_rows)); -} -#else -int ha_spider::pre_direct_update_rows() -{ - uint update_rows; - uint found_rows; - DBUG_ENTER("ha_spider::pre_direct_update_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_update_rows( - &update_rows, &found_rows)); -} -#endif -#endif bool ha_spider::start_bulk_delete( ) { @@ -9830,19 +9139,6 @@ int ha_spider::delete_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - ulonglong option_backup = 0; - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_delete_row(buf); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_delete_count); #endif @@ -9887,25 +9183,6 @@ int ha_spider::direct_delete_rows_init( THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init( - mode, ranges, range_count, sorted)); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9980,24 +9257,6 @@ int ha_spider::direct_delete_rows_init() THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init()); - } -#endif if (!dml_inited) { if (unlikely(dml_init())) @@ -10048,63 +9307,6 @@ int ha_spider::direct_delete_rows_init() } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_delete_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted -) { - int error_num; - DBUG_ENTER("ha_spider::pre_direct_delete_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_delete_rows_init( - mode, ranges, range_count, sorted); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_delete_rows_init( - mode, ranges, range_count, sorted); - DBUG_RETURN(pre_direct_init_result); -} -#else -int ha_spider::pre_direct_delete_rows_init() -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_delete_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_delete_rows_init(); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_delete_rows_init(); - DBUG_RETURN(pre_direct_init_result); -} -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int ha_spider::direct_delete_rows( @@ -10124,26 +9326,6 @@ int ha_spider::direct_delete_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_delete_rows( - ranges, range_count, sorted, delete_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -10152,13 +9334,6 @@ int ha_spider::direct_delete_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } -#endif DBUG_RETURN(0); } #else @@ -10176,26 +9351,6 @@ int ha_spider::direct_delete_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_delete_rows( - delete_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -10203,41 +9358,10 @@ int ha_spider::direct_delete_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } -#endif DBUG_RETURN(0); } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_delete_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - ha_rows *delete_rows -) { - DBUG_ENTER("ha_spider::pre_direct_delete_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_delete_rows( - ranges, range_count, sorted, delete_rows)); -} -#else -int ha_spider::pre_direct_delete_rows() -{ - uint delete_rows; - DBUG_ENTER("ha_spider::pre_direct_delete_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_delete_rows( - &delete_rows)); -} -#endif -#endif int ha_spider::delete_all_rows() { @@ -10289,57 +9413,6 @@ int ha_spider::truncate() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -void ha_spider::bulk_req_exec() -{ - int need_mon; - SPIDER_CONN *conn = wide_handler->trx->bulk_access_conn_first; - DBUG_ENTER("ha_spider::bulk_req_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider trx=%p", wide_handler->trx)); - DBUG_PRINT("info",("spider first_conn=%p", conn)); - while (conn) - { - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - if (conn->bulk_access_requests) - { - spider_bg_conn_wait(conn); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - /* currently only used for HS */ - conn->bulk_access_error_num = 0; - if (spider_db_query( - conn, - NULL, - 0, - -1, - &need_mon) - ) { - conn->bulk_access_error_num = spider_db_errorno(conn); - } -/* - conn->bulk_access_sended += conn->bulk_access_requests; -*/ - conn->bulk_access_requests = 0; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - conn = conn->bulk_access_next; - } - wide_handler->trx->bulk_access_conn_first = NULL; - DBUG_VOID_RETURN; -} -#endif double ha_spider::scan_time() { @@ -11148,12 +10221,6 @@ Field *ha_spider::field_exchange( Field *field ) { DBUG_ENTER("ha_spider::field_exchange"); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - DBUG_RETURN(pt_clone_source_handler->field_exchange(field)); - } -#endif DBUG_PRINT("info",("spider in field=%p", field)); DBUG_PRINT("info",("spider in field->table=%p", field->table)); DBUG_PRINT("info",("spider table=%p", table)); @@ -11231,28 +10298,6 @@ int ha_spider::info_push( wide_handler->stage = SPD_HND_STAGE_INFO_PUSH; wide_handler->stage_executor = this; #endif -#ifdef HA_CAN_BULK_ACCESS - if ( - info_type != INFO_KIND_BULK_ACCESS_BEGIN && - info_type != INFO_KIND_BULK_ACCESS_CURRENT && - info_type != INFO_KIND_BULK_ACCESS_END - ) { - if (!is_bulk_access_clone) - { - if ( - bulk_access_executing && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->info_push(info_type, - info)); - } else if (bulk_access_started) - { - DBUG_RETURN(bulk_access_link_current->spider->info_push(info_type, - info)); - } - } - } -#endif switch (info_type) { @@ -11282,65 +10327,6 @@ int ha_spider::info_push( DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_END")); wide_handler->info_limit = 9223372036854775807LL; break; -#endif -#ifdef HA_CAN_BULK_ACCESS - case INFO_KIND_BULK_ACCESS_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_BEGIN")); - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->bulk_access_begin(info))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = bulk_access_begin(info))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_BULK_ACCESS_CURRENT: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_CURRENT")); - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->bulk_access_current(info))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = bulk_access_current(info))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_BULK_ACCESS_END: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_END")); - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - handlers[roop_count]->bulk_access_end(); - } - } else { - bulk_access_end(); - } - break; #endif default: break; @@ -12475,145 +11461,6 @@ void ha_spider::check_insert_dup_update_pushdown() DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -SPIDER_BULK_ACCESS_LINK *ha_spider::create_bulk_access_link() -{ - uchar *ref; - ha_spider *spider; - SPIDER_BULK_ACCESS_LINK *bulk_access_link; - DBUG_ENTER("ha_spider::create_bulk_access_link"); - DBUG_PRINT("info",("spider this=%p", this)); -/* - if (!init_ha_mem_root) - { - SPD_INIT_ALLOC_ROOT(&ha_mem_root, sizeof(ha_spider) * 16, - sizeof(ha_spider) * 16, MYF(MY_WME)); - init_ha_mem_root = TRUE; - } -*/ - if (!(bulk_access_link = (SPIDER_BULK_ACCESS_LINK *) - spider_bulk_malloc(spider_current_trx, SPD_MID_HA_SPIDER_CREATE_BULK_ACCESS_LINK_1, MYF(MY_WME), - &bulk_access_link, (uint) (sizeof(SPIDER_BULK_ACCESS_LINK)), - &ref, (uint) (ALIGN_SIZE(ref_length) * 2), - NullS)) - ) { - goto error_bulk_malloc; - } - SPD_INIT_ALLOC_ROOT(&bulk_access_link->mem_root, sizeof(ha_spider), 0, - MYF(MY_WME)); -/* - if (!(spider = new ha_spider(spider_hton_ptr, table_share))) - if (!(spider = (ha_spider *) spider_create_handler( - spider_hton_ptr, table_share, &ha_mem_root))) -*/ - if (!(spider = (ha_spider *) spider_create_handler( - spider_hton_ptr, table_share, &bulk_access_link->mem_root))) - { - goto error_new_spider; - } - DBUG_PRINT("info",("spider spider=%p", spider)); - bulk_access_link->spider = spider; - spider->ref = ref; - bulk_access_link->next = NULL; - spider->is_clone = TRUE; - spider->is_bulk_access_clone = TRUE; - spider->pt_clone_source_handler = this; - if (spider->ha_open(table, share->table_name, table->db_stat, - HA_OPEN_IGNORE_IF_LOCKED)) - { - goto error_ha_open; - } - DBUG_RETURN(bulk_access_link); - -error_ha_open: - delete spider; -error_new_spider: - free_root(&bulk_access_link->mem_root, MYF(0)); - spider_free(spider_current_trx, bulk_access_link, MYF(0)); -error_bulk_malloc: - DBUG_RETURN(NULL); -} - -void ha_spider::delete_bulk_access_link( - SPIDER_BULK_ACCESS_LINK *bulk_access_link -) { - ha_spider *spider = bulk_access_link->spider; - DBUG_ENTER("ha_spider::delete_bulk_access_link"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider spider=%p", spider)); - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &spider->dbton_handler)); - spider->close(); - delete spider; - free_root(&bulk_access_link->mem_root, MYF(0)); - spider_free(spider_current_trx, bulk_access_link, MYF(0)); - DBUG_VOID_RETURN; -} - -int ha_spider::sync_from_clone_source( - ha_spider *spider -) { - int error_num; - DBUG_ENTER("ha_spider::sync_from_clone_source"); - sync_from_clone_source_base(spider); - if (!synced_from_clone_source) - { - DBUG_PRINT("info",("spider synced from clone source all")); - wide_handler->trx = spider->wide_handler->trx; - sql_command = spider->sql_command; - wide_handler->external_lock_type = - spider->wide_handler->external_lock_type; - selupd_lock_mode = spider->selupd_lock_mode; - update_request = spider->update_request; - lock_mode = spider->lock_mode; - high_priority = spider->high_priority; - low_priority = spider->low_priority; - memcpy(conns, spider->conns, - sizeof(SPIDER_CONN *) * share->link_count); - spider_thread_id = spider->spider_thread_id; - trx_conn_adjustment = spider->trx_conn_adjustment; - search_link_idx = spider->search_link_idx; - external_lock_cnt = spider->external_lock_cnt; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl, *dbton_hdl2; - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - dbton_hdl2 = spider->dbton_handler[dbton_id]; - dbton_hdl->sync_from_clone_source(dbton_hdl2); - } - synced_from_clone_source = TRUE; - } else if (external_lock_cnt != spider->external_lock_cnt) - { - DBUG_PRINT("info",("spider synced from clone source")); - sql_command = spider->sql_command; - wide_handler->external_lock_type = - spider->wide_handler->external_lock_type; - selupd_lock_mode = spider->selupd_lock_mode; - update_request = spider->update_request; - lock_mode = spider->lock_mode; - high_priority = spider->high_priority; - low_priority = spider->low_priority; - - if ((error_num = spider_check_trx_and_get_conn( - spider->wide_handler->trx->thd, - this, TRUE))) - { - DBUG_RETURN(error_num); - } - external_lock_cnt = spider->external_lock_cnt; - } - - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &dbton_handler)); - DBUG_RETURN(0); -} -#endif void ha_spider::sync_from_clone_source_base( ha_spider *spider @@ -14783,92 +13630,3 @@ int ha_spider::dml_init() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::bulk_access_begin( - void *info -) { - DBUG_ENTER("ha_spider::bulk_access_begin"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - if (!bulk_access_link_current->next) - { - if (!(bulk_access_link_current->next = create_bulk_access_link())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - bulk_access_link_current->next->sequence_num = - bulk_access_link_current->sequence_num + 1; - } - bulk_access_link_current = bulk_access_link_current->next; - } else { - if (!bulk_access_link_first) - { - if (!(bulk_access_link_first = create_bulk_access_link())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - bulk_access_link_first->sequence_num = 0; - } - bulk_access_link_current = bulk_access_link_first; - bulk_access_started = TRUE; - bulk_access_executing = FALSE; - } - bulk_access_link_current->spider-> - check_access_kind(wide_handler->trx->thd); - if ( - (error_num = bulk_access_link_current->spider-> - sync_from_clone_source(this)) || - (error_num = bulk_access_link_current->spider-> - check_access_kind_for_connection(wide_handler->trx->thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))) - ) { - DBUG_RETURN(error_num); - } - bulk_access_link_current->spider->bulk_access_executing = FALSE; - bulk_access_link_current->spider->bulk_access_pre_called = FALSE; - bulk_access_link_current->used = TRUE; - bulk_access_link_current->called = FALSE; - *((void **) info) = bulk_access_link_current; - DBUG_RETURN(0); -} - -int ha_spider::bulk_access_current( - void *info -) { - DBUG_ENTER("ha_spider::bulk_access_current"); - DBUG_PRINT("info",("spider this=%p", this)); - bulk_access_executing = TRUE; - bulk_access_link_exec_tgt = (SPIDER_BULK_ACCESS_LINK *) info; - if (bulk_access_link_exec_tgt->spider->pt_clone_source_handler != this) - { - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider pt_clone_source_handler=%p", - bulk_access_link_exec_tgt->spider->pt_clone_source_handler)); - /* partitioned */ - uint sequence_num = bulk_access_link_exec_tgt->sequence_num; - for ( - bulk_access_link_exec_tgt = bulk_access_link_first; - bulk_access_link_exec_tgt; - bulk_access_link_exec_tgt = bulk_access_link_exec_tgt->next - ) { - if (bulk_access_link_exec_tgt->sequence_num >= sequence_num) - { - DBUG_ASSERT( - bulk_access_link_exec_tgt->sequence_num == sequence_num); - break; - } - } - } - bulk_access_link_exec_tgt->spider->bulk_access_executing = TRUE; - DBUG_RETURN(0); -} - -void ha_spider::bulk_access_end() -{ - DBUG_ENTER("ha_spider::bulk_access_end"); - DBUG_PRINT("info",("spider this=%p", this)); - bulk_access_started = FALSE; - DBUG_VOID_RETURN; -} -#endif diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index a57359ce025..446bbbc4d94 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -88,21 +88,6 @@ public: bool wide_handler_owner = FALSE; SPIDER_WIDE_HANDLER *wide_handler = NULL; -#ifdef HA_CAN_BULK_ACCESS - int pre_direct_init_result; - bool is_bulk_access_clone; - bool synced_from_clone_source; - bool bulk_access_started; - bool bulk_access_executing; - bool bulk_access_pre_called; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_first; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_current; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_exec_tgt; -/* - bool init_ha_mem_root; - MEM_ROOT ha_mem_root; -*/ -#endif bool is_clone; ha_spider *pt_clone_source_handler; ha_spider *pt_clone_last_searcher; @@ -221,12 +206,6 @@ public: void check_access_kind( THD *thd ); -#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, @@ -248,16 +227,7 @@ public: uint idx, bool sorted ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_index_init( - uint idx, - bool sorted - ); -#endif int index_end() override; -#ifdef HA_CAN_BULK_ACCESS - int pre_index_end(); -#endif int index_read_map( uchar *buf, const uchar *key, @@ -345,15 +315,7 @@ public: int rnd_init( bool scan ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_rnd_init( - bool scan - ); -#endif int rnd_end() override; -#ifdef HA_CAN_BULK_ACCESS - int pre_rnd_end(); -#endif int rnd_next( uchar *buf ) override; @@ -467,11 +429,6 @@ public: int write_row( const uchar *buf ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_write_row( - uchar *buf - ); -#endif void direct_update_init( THD *thd, bool hs_request @@ -514,27 +471,6 @@ public: List *update_fields ) override; #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_update_rows_init( - List *update_fields - ) { - return pre_direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); - } - int pre_direct_update_rows_init( - List *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#else - int pre_direct_update_rows_init( - List *update_fields - ); -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS inline int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) { @@ -553,28 +489,6 @@ public: ha_rows *update_rows, ha_rows *found_row ) override; -#endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_update_rows() - { - ha_rows update_rows; - ha_rows found_rows; - - return pre_direct_update_rows(NULL, 0, FALSE, NULL, &update_rows, - &found_rows); - } - int pre_direct_update_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data, - ha_rows *update_rows, - ha_rows *found_row - ); -#else - int pre_direct_update_rows(); -#endif #endif bool start_bulk_delete() override; int end_bulk_delete() override; @@ -600,22 +514,6 @@ public: #else int direct_delete_rows_init() override; #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) { @@ -631,24 +529,6 @@ public: int direct_delete_rows( ha_rows *delete_rows ) override; -#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, - ha_rows *delete_rows - ); -#else - int pre_direct_delete_rows(); -#endif #endif int delete_all_rows() override; int truncate() override; @@ -658,9 +538,6 @@ public: uint ranges, ha_rows rows ) override; -#ifdef HA_CAN_BULK_ACCESS - void bulk_req_exec(); -#endif const key_map *keys_to_use_for_scanning() override; ha_rows estimate_rows_upper_bound() override; void print_error( @@ -818,15 +695,6 @@ public: bool use_parallel ); void check_insert_dup_update_pushdown(); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_BULK_ACCESS_LINK *create_bulk_access_link(); - void delete_bulk_access_link( - SPIDER_BULK_ACCESS_LINK *bulk_access_link - ); - int sync_from_clone_source( - ha_spider *spider - ); -#endif void sync_from_clone_source_base( ha_spider *spider ); @@ -1044,15 +912,6 @@ public: int append_lock_tables_list(); int lock_tables(); int dml_init(); -#ifdef HA_CAN_BULK_ACCESS - int bulk_access_begin( - void *info - ); - int bulk_access_current( - void *info - ); - void bulk_access_end(); -#endif }; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 434a20e9e3e..cc3a6b52719 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2590,13 +2590,6 @@ void *spider_bg_conn_action( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[conn->link_idx] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); - } -#endif if (!result_list->bgs_error) { conn->need_mon = &spider->need_mons[conn->link_idx]; @@ -2604,10 +2597,6 @@ void *spider_bg_conn_action( DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif if (!(result_list->bgs_error = spider_db_set_names(spider, conn, conn->link_idx))) { @@ -2676,9 +2665,6 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 7d786492bfe..4319616961b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -4476,42 +4476,6 @@ void spider_db_discard_multiple_result( DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_store_result( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx, - bool discard_result -) { - int error_num, tmp_error_num; - DBUG_ENTER("spider_db_bulk_store_result"); - DBUG_PRINT("info",("spider spider=%p", spider)); - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider link_idx=%d", link_idx)); - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { - /* already stored */ - DBUG_RETURN(0); - } - error_num = spider_db_bulk_open_handler(spider, conn, link_idx); - if (!discard_result) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_store_result(spider, link_idx, - spider->get_table()))) - { - error_num = tmp_error_num; - } - conn->mta_conn_mutex_unlock_later = FALSE; - } else { - if (spider->connection_ids[link_idx] == conn->connection_id) - spider_db_discard_result(spider, link_idx, conn); - } - DBUG_RETURN(error_num); -} -#endif int spider_db_fetch( uchar *buf, @@ -6070,10 +6034,6 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif bool insert_info = FALSE; for ( roop_count2 = spider_conn_link_idx_next(share->link_statuses, @@ -6254,9 +6214,6 @@ int spider_db_bulk_insert( conn->mta_conn_mutex_unlock_later = FALSE; pthread_mutex_unlock(&conn->mta_conn_mutex); spider->store_last_insert_id = 0; -#ifdef HA_CAN_BULK_ACCESS - } -#endif } if ( (bulk_end || !spider->bulk_insert) && @@ -6266,91 +6223,6 @@ int spider_db_bulk_insert( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_bulk_insert( - ha_spider *spider -) { - int error_num = 0, first_insert_link_idx = -1, tmp_error_num; - int roop_count2; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn, *first_insert_conn = NULL; - TABLE *table = spider->get_table(); - THD *thd = spider->wide_handler->trx->thd; - DBUG_ENTER("spider_db_bulk_bulk_insert"); - for ( - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count2 < (int) share->link_count; - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, roop_count2, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - conn = spider->conns[roop_count2]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, - roop_count2))) - { - error_num = tmp_error_num; - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - if (first_insert_link_idx == -1) - { - first_insert_link_idx = roop_count2; - first_insert_conn = conn; - } - } - - conn = first_insert_conn; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[first_insert_link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (table->next_number_field && - ( - !table->auto_increment_field_not_null || - ( - !table->next_number_field->val_int() && - !(thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) - ) - ) - ) { - ulonglong last_insert_id; - if (spider->store_last_insert_id) - last_insert_id = spider->store_last_insert_id; - else - last_insert_id = conn->db_conn->last_insert_id(); - table->next_number_field->set_notnull(); - if ( - (tmp_error_num = spider_db_update_auto_increment(spider, - first_insert_link_idx)) || - (tmp_error_num = table->next_number_field->store( - last_insert_id, TRUE)) - ) { - error_num = tmp_error_num; - } - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - spider->store_last_insert_id = 0; - DBUG_RETURN(error_num); -} -#endif int spider_db_update_auto_increment( ha_spider *spider, @@ -6917,13 +6789,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7014,9 +6879,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7125,13 +6987,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7223,9 +7078,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7233,56 +7085,6 @@ int spider_db_direct_update( } #endif -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_direct_update( - ha_spider *spider, - ha_rows *update_rows, - ha_rows *found_rows -) { - int error_num = 0, roop_count, tmp_error_num; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn; - bool counted = FALSE; - DBUG_ENTER("spider_db_bulk_direct_update"); - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - DBUG_PRINT("info", ("spider exec sql")); - conn = spider->conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, - roop_count))) - { - error_num = tmp_error_num; - } - if (!counted) - { - *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = spider->conns[roop_count]->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(error_num); -} -#endif int spider_db_bulk_delete( ha_spider *spider, @@ -7447,13 +7249,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7536,9 +7331,6 @@ int spider_db_direct_delete( DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7623,13 +7415,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7712,9 +7497,6 @@ int spider_db_direct_delete( DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -11146,20 +10928,6 @@ error: DBUG_RETURN(error_num); } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_open_handler( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx -) { - int error_num = 0; - DBUG_ENTER("spider_db_bulk_open_handler"); - DBUG_PRINT("info",("spider spider=%p", spider)); - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider link_idx=%d", link_idx)); - DBUG_RETURN(error_num); -} -#endif int spider_db_close_handler( ha_spider *spider, diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index aa451b861d2..6e94e2d1517 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -634,14 +634,6 @@ void spider_db_discard_multiple_result( SPIDER_CONN *conn ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_store_result( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx, - bool discard_result -); -#endif int spider_db_fetch( uchar *buf, @@ -764,11 +756,6 @@ int spider_db_bulk_insert( bool bulk_end ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_bulk_insert( - ha_spider *spider -); -#endif int spider_db_update_auto_increment( ha_spider *spider, @@ -815,12 +802,6 @@ int spider_db_direct_update( ); #endif -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_direct_update( - ha_spider *spider, - ha_rows *update_rows -); -#endif int spider_db_bulk_delete( ha_spider *spider, @@ -1190,13 +1171,6 @@ int spider_db_open_handler( int link_idx ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_open_handler( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx -); -#endif int spider_db_close_handler( ha_spider *spider, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 50974269e0c..ac031dfe64d 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1766,8 +1766,6 @@ typedef struct st_spider_result_list SPIDER_RESULT *current; KEY *key_info; int key_order; -#ifdef HA_CAN_BULK_ACCESS -#endif spider_string *sqls; int ha_read_kind; bool have_sql_kind_backup; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 62fb57c8724..8c8ed349d32 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -15005,11 +15005,7 @@ void spider_mbase_handler::minimum_select_bitmap_create() memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set)); if ( spider->use_index_merge || -#ifdef HA_CAN_BULK_ACCESS - (spider->is_clone && !spider->is_bulk_access_clone) -#else spider->is_clone -#endif ) { /* need preparing for cmp_ref */ TABLE_SHARE *table_share = table->s; diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 9ed1aa32a96..c5bf59b8df8 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -12167,11 +12167,7 @@ void spider_oracle_handler::minimum_select_bitmap_create() memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set)); if ( spider->use_index_merge || -#ifdef HA_CAN_BULK_ACCESS - (spider->is_clone && !spider->is_bulk_access_clone) -#else spider->is_clone -#endif ) { /* need preparing for cmp_ref */ TABLE_SHARE *table_share = table->s; diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 5627f15bd4f..d06d0d7be8b 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -745,12 +745,6 @@ typedef struct st_spider_conn Time_zone *queued_time_zone_val; XID *queued_xa_start_xid; -#ifdef HA_CAN_BULK_ACCESS - uint bulk_access_requests; - uint bulk_access_sended; - int bulk_access_error_num; - st_spider_conn *bulk_access_next; -#endif bool disable_connect_retry; /* TRUE if it is unnecessary to retry to connect after a @@ -878,9 +872,6 @@ typedef struct st_spider_wide_handler uint top_table_fields; #ifdef INFO_KIND_FORCE_LIMIT_BEGIN longlong info_limit; -#endif -#ifdef HA_CAN_BULK_ACCESS - ulonglong external_lock_cnt; #endif bool between_flg; bool idx_bitmap_is_set; @@ -954,10 +945,6 @@ typedef struct st_spider_transaction ulonglong direct_aggregate_count; ulonglong parallel_search_count; -#ifdef HA_CAN_BULK_ACCESS - SPIDER_CONN *bulk_access_conn_first; - SPIDER_CONN *bulk_access_conn_last; -#endif pthread_mutex_t *udf_table_mutexes; CHARSET_INFO *udf_access_charset; @@ -1175,9 +1162,6 @@ typedef struct st_spider_share int error_read_mode; int error_write_mode; int active_link_count; -#ifdef HA_CAN_BULK_ACCESS - int bulk_access_free; -#endif #ifdef HA_CAN_FORCE_BULK_UPDATE int force_bulk_update; #endif @@ -1583,17 +1567,6 @@ typedef struct st_spider_trx_ha bool wait_for_reusing; } SPIDER_TRX_HA; -#ifdef HA_CAN_BULK_ACCESS -typedef struct st_spider_bulk_access_link -{ - ha_spider *spider; - uint sequence_num; - bool used; - bool called; - MEM_ROOT mem_root; - st_spider_bulk_access_link *next; -} SPIDER_BULK_ACCESS_LINK; -#endif #define SPIDER_INT_HLD_TGT_SIZE 100 typedef struct st_spider_int_hld diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 41a065bfd29..55842682782 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -2033,28 +2033,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, read_only_mode) -#ifdef HA_CAN_BULK_ACCESS -static int spider_bulk_access_free; -/* - -1 :fallback to default - 0 :in reset - 1 :in close - */ -static MYSQL_SYSVAR_INT( - bulk_access_free, - spider_bulk_access_free, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Free mode of bulk access resources", - NULL, - NULL, - 0, - -1, - 1, - 0 -); - -SPIDER_SYSVAR_OVERRIDE_VALUE_FUN(int, bulk_access_free) -#endif /* -1 :fallback to default @@ -2657,9 +2635,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(skip_parallel_search), MYSQL_SYSVAR(direct_order_limit), MYSQL_SYSVAR(read_only_mode), -#ifdef HA_CAN_BULK_ACCESS - MYSQL_SYSVAR(bulk_access_free), -#endif MYSQL_SYSVAR(udf_ds_use_real_table), MYSQL_SYSVAR(general_log), MYSQL_SYSVAR(index_hint_pushdown), diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index d7d35b17df5..c93d41022d5 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -337,11 +337,6 @@ int spider_param_read_only_mode( THD *thd, int read_only_mode ); -#ifdef HA_CAN_BULK_ACCESS -int spider_param_bulk_access_free( - int bulk_access_free -); -#endif int spider_param_udf_ds_use_real_table( THD *thd, int udf_ds_use_real_table diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 1503c61b1bb..dc30278e66c 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -1834,9 +1834,6 @@ static void spider_minus_1(SPIDER_SHARE *share, TABLE_SHARE *table_share) share->error_read_mode = -1; share->error_write_mode = -1; share->active_link_count = -1; -#ifdef HA_CAN_BULK_ACCESS - share->bulk_access_free = -1; -#endif #ifdef HA_CAN_FORCE_BULK_UPDATE share->force_bulk_update = -1; #endif @@ -2160,9 +2157,6 @@ int spider_parse_connect_info( 2147483647); SPIDER_PARAM_INT_WITH_MAX("aim", auto_increment_mode, 0, 3); SPIDER_PARAM_INT("alc", active_link_count, 1); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_PARAM_INT_WITH_MAX("baf", bulk_access_free, 0, 1); -#endif SPIDER_PARAM_INT("bfz", buffer_size, 0); #ifndef WITHOUT_SPIDER_BG_SEARCH SPIDER_PARAM_LONGLONG("bfr", bgs_first_read, 0); @@ -2419,10 +2413,6 @@ int spider_parse_connect_info( net_read_timeouts, 0, 2147483647); SPIDER_PARAM_INT_WITH_MAX( "error_write_mode", error_write_mode, 0, 1); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_PARAM_INT_WITH_MAX( - "bulk_access_free", bulk_access_free, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX( "query_cache_sync", query_cache_sync, 0, 3); error_num = parse.fail(true); @@ -4549,8 +4539,6 @@ SPIDER_SHARE *spider_get_share( sizeof(uchar) * share->link_bitmap_size, &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, -#ifdef HA_CAN_BULK_ACCESS -#endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, &spider->dbton_handler, @@ -5027,8 +5015,6 @@ SPIDER_SHARE *spider_get_share( sizeof(uchar) * share->link_bitmap_size, &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, -#ifdef HA_CAN_BULK_ACCESS -#endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, &spider->dbton_handler, @@ -7733,18 +7719,10 @@ bool spider_check_direct_order_limit( spider->use_index_merge ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider is_clone=%s", spider->is_clone ? "TRUE" : "FALSE")); -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider is_bulk_access_clone=%s", - spider->is_bulk_access_clone ? "TRUE" : "FALSE")); -#endif if ( spider->wide_handler->sql_command != SQLCOM_HA_READ && !spider->use_index_merge && -#ifdef HA_CAN_BULK_ACCESS - (!spider->is_clone || spider->is_bulk_access_clone) -#else !spider->is_clone -#endif ) { spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); bool first_check = TRUE; @@ -7946,12 +7924,6 @@ Field *spider_field_exchange( Field *field ) { DBUG_ENTER("spider_field_exchange"); -#ifdef HA_CAN_BULK_ACCESS - if (handler->is_bulk_access_clone) - { - handler = handler->pt_clone_source_handler; - } -#endif DBUG_PRINT("info",("spider in field=%p", field)); DBUG_PRINT("info",("spider in field->table=%p", field->table)); DBUG_PRINT("info",("spider table=%p", handler->get_table())); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 11dc7a81ad8..305d8fc7327 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -3097,11 +3097,6 @@ int spider_commit( if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - trx->bulk_access_conn_first = NULL; -#endif /* We do (almost) nothing if the following two conditions are both met: @@ -3195,11 +3190,6 @@ int spider_rollback( if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - trx->bulk_access_conn_first = NULL; -#endif /* In case the rollback happens due to failure of LOCK TABLE, we need to clear the list of tables to lock. */ @@ -3936,34 +3926,3 @@ int spider_trx_check_link_idx_failed( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -void spider_trx_add_bulk_access_conn( - SPIDER_TRX *trx, - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_trx_add_bulk_access_conn"); - DBUG_PRINT("info",("spider trx=%p", trx)); - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - DBUG_PRINT("info",("spider conn->bulk_access_sended=%u", - conn->bulk_access_sended)); - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - if (!conn->bulk_access_requests && !conn->bulk_access_sended) - { - if (!trx->bulk_access_conn_first) - { - trx->bulk_access_conn_first = conn; - } else { - trx->bulk_access_conn_last->bulk_access_next = conn; - } - trx->bulk_access_conn_last = conn; - conn->bulk_access_next = NULL; - } - conn->bulk_access_requests++; - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - DBUG_VOID_RETURN; -} -#endif diff --git a/storage/spider/spd_trx.h b/storage/spider/spd_trx.h index 3bf93aada1a..2055a49717e 100644 --- a/storage/spider/spd_trx.h +++ b/storage/spider/spd_trx.h @@ -266,9 +266,3 @@ int spider_trx_check_link_idx_failed( ha_spider *spider ); -#ifdef HA_CAN_BULK_ACCESS -void spider_trx_add_bulk_access_conn( - SPIDER_TRX *trx, - SPIDER_CONN *conn -); -#endif From 84067291b4fe177a40754418a315ede7bf9536e8 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 18 Jun 2024 19:14:42 +0800 Subject: [PATCH 46/54] MDEV-28360 Spider: remove #ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name --- storage/spider/spd_db_conn.cc | 45 --------------------------------- storage/spider/spd_db_mysql.cc | 5 ---- storage/spider/spd_db_oracle.cc | 5 ---- storage/spider/spd_include.h | 1 - 4 files changed, 56 deletions(-) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 4319616961b..a3113059143 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1614,13 +1614,8 @@ int spider_db_append_key_where_internal( if (sql_kind == SPIDER_SQL_KIND_HANDLER) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name const char *key_name = key_info->name.str; key_name_length = key_info->name.length; -#else - const char *key_name = key_info->name; - key_name_length = strlen(key_name); -#endif if (str->reserve(SPIDER_SQL_READ_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + key_name_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -8480,13 +8475,8 @@ int spider_db_open_item_ident( } if (str) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if (item_ident->field_name.str) field_name_length = item_ident->field_name.length; -#else - if (item_ident->field_name) - field_name_length = strlen(item_ident->field_name); -#endif else field_name_length = 0; if (share->access_charset->cset == system_charset_info->cset) @@ -8497,14 +8487,9 @@ int spider_db_open_item_ident( DBUG_RETURN(HA_ERR_OUT_OF_MEM); } str->q_append(alias, alias_length); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_escaped_name(str, item_ident->field_name.str, field_name_length))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_escaped_name(str, item_ident->field_name, field_name_length))) -#endif { DBUG_RETURN(error_num); } @@ -8512,15 +8497,9 @@ int spider_db_open_item_ident( if (str->reserve(alias_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_escaped_name_with_charset(str, item_ident->field_name.str, field_name_length, system_charset_info))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_escaped_name_with_charset(str, item_ident->field_name, - field_name_length, system_charset_info))) -#endif { DBUG_RETURN(error_num); } @@ -8630,7 +8609,6 @@ int spider_db_open_item_ref( DBUG_ENTER("spider_db_open_item_ref"); if (item_ref->ref) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ( (*(item_ref->ref))->type() != Item::CACHE_ITEM && item_ref->ref_type() != Item_ref::VIEW_REF && @@ -8638,34 +8616,16 @@ int spider_db_open_item_ref( item_ref->name.str && item_ref->alias_name_used ) -#else - if ( - (*(item_ref->ref))->type() != Item::CACHE_ITEM && - item_ref->ref_type() != Item_ref::VIEW_REF && - !item_ref->table_name && - item_ref->name && - item_ref->alias_name_used - ) -#endif { if (str) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name uint length = item_ref->name.length; -#else - uint length = strlen(item_ref->name); -#endif if (str->reserve(length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_name(str, item_ref->name.str, length))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_name(str, item_ref->name, length))) -#endif { DBUG_RETURN(error_num); } @@ -10320,13 +10280,8 @@ int spider_db_udf_copy_key_row( ) { int error_num; DBUG_ENTER("spider_db_udf_copy_key_row"); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_db_append_name_with_quote_str(str, (char *) field->field_name.str, dbton_id))) -#else - if ((error_num = spider_db_append_name_with_quote_str(str, - (char *) field->field_name, dbton_id))) -#endif DBUG_RETURN(error_num); if (str->reserve(joint_length + *length + SPIDER_SQL_AND_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 8c8ed349d32..f0d0a166ed3 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3669,13 +3669,8 @@ void spider_db_mbase::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name key_name = table->key_info[roop_count].name.str; key_name_length = table->key_info[roop_count].name.length; -#else - key_name = table->key_info[roop_count].name; - key_name_length = strlen(key_name); -#endif } DBUG_PRINT("info",("spider key_name=%s", key_name)); if ( diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index c5bf59b8df8..455b52177dd 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2431,13 +2431,8 @@ void spider_db_oracle::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name key_name = (char *) table->s->key_info[roop_count].name.str; key_name_length = table->s->key_info[roop_count].name.length; -#else - key_name = table->s->key_info[roop_count].name; - key_name_length = strlen(key_name); -#endif } memcpy(tmp_pos, key_name, key_name_length + 1); DBUG_PRINT("info",("spider key_name=%s", key_name)); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index d06d0d7be8b..473bdc2c416 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -109,7 +109,6 @@ #define SPIDER_read_record_read_record(A) read_record() #define SPIDER_has_Item_with_subquery -#define SPIDER_use_LEX_CSTRING_for_KEY_Field_name #define SPIDER_use_LEX_CSTRING_for_Field_blob_constructor #define SPIDER_use_LEX_CSTRING_for_database_tablename_alias #define SPIDER_THD_db_str(A) (A)->db.str From 9e1579788fcd7de5f79a7018869ba82977b2fe81 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 10 Sep 2024 11:52:22 +1000 Subject: [PATCH 47/54] MDEV-31788 Factor spider locking and unlocking code around sending queries --- storage/spider/ha_spider.cc | 360 +---- storage/spider/spd_conn.cc | 70 +- storage/spider/spd_conn.h | 10 + storage/spider/spd_db_conn.cc | 729 ++------- storage/spider/spd_db_mysql.cc | 1895 ++++-------------------- storage/spider/spd_group_by_handler.cc | 28 +- storage/spider/spd_table.cc | 20 +- 7 files changed, 528 insertions(+), 2584 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index e910ffcff56..2a49af4ee3b 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1381,18 +1381,6 @@ int ha_spider::index_end() DBUG_ENTER("ha_spider::index_end"); DBUG_PRINT("info",("spider this=%p", this)); active_index = MAX_KEY; -/* -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - info_limit = 9223372036854775807LL; -#endif - if ( - (error_num = drop_tmp_tables()) || - (error_num = check_and_end_bulk_update( - SPD_BU_START_BY_INDEX_OR_RND_INIT)) || - (error_num = spider_trx_check_link_idx_failed(this)) - ) - DBUG_RETURN(check_error_mode(error_num)); -*/ if ((error_num = drop_tmp_tables())) DBUG_RETURN(check_error_mode(error_num)); result_list.use_union = FALSE; @@ -1438,6 +1426,7 @@ int ha_spider::index_read_map_internal( start_key.key = key; start_key.keypart_map = keypart_map; start_key.flag = find_flag; + /* Query construction */ if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); @@ -1529,6 +1518,7 @@ int ha_spider::index_read_map_internal( } } + /* Query execution */ int roop_start, roop_end, lock_mode, link_ok; lock_mode = spider_conn_lock_mode(this); if (lock_mode) @@ -1596,26 +1586,16 @@ int ha_spider::index_read_map_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -1647,11 +1627,7 @@ int ha_spider::index_read_map_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -1676,13 +1652,9 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -1711,7 +1683,7 @@ int ha_spider::index_read_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -1956,26 +1928,16 @@ int ha_spider::index_read_last_map_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2007,11 +1969,7 @@ int ha_spider::index_read_last_map_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2036,13 +1994,9 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2071,7 +2025,7 @@ int ha_spider::index_read_last_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -2365,27 +2319,17 @@ int ha_spider::index_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2417,11 +2361,7 @@ int ha_spider::index_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2446,13 +2386,9 @@ int ha_spider::index_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2481,7 +2417,7 @@ int ha_spider::index_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -2722,27 +2658,17 @@ int ha_spider::index_last_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2774,11 +2700,7 @@ int ha_spider::index_last_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2803,13 +2725,9 @@ int ha_spider::index_last_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2838,7 +2756,7 @@ int ha_spider::index_last_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -3122,26 +3040,16 @@ int ha_spider::read_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3173,11 +3081,7 @@ int ha_spider::read_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3202,13 +3106,9 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -3237,7 +3137,7 @@ int ha_spider::read_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -3719,27 +3619,17 @@ int ha_spider::read_multi_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3772,11 +3662,7 @@ int ha_spider::read_multi_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3803,13 +3689,9 @@ int ha_spider::read_multi_range_first_internal( if (!error_num) { connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - error_num = spider_db_store_result(this, roop_count, table); + error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && error_num != HA_ERR_END_OF_FILE && @@ -3836,7 +3718,7 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -4474,28 +4356,18 @@ int ha_spider::read_multi_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4534,11 +4406,7 @@ int ha_spider::read_multi_range_first_internal( -1, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4572,11 +4440,7 @@ int ha_spider::read_multi_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4601,13 +4465,9 @@ int ha_spider::read_multi_range_first_internal( break; } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4636,7 +4496,7 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -5088,27 +4948,17 @@ int ha_spider::read_multi_range_next( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5141,11 +4991,7 @@ int ha_spider::read_multi_range_next( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5172,13 +5018,9 @@ int ha_spider::read_multi_range_next( if (!error_num) { connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - error_num = spider_db_store_result(this, roop_count, table); + error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && error_num != HA_ERR_END_OF_FILE && @@ -5205,7 +5047,7 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -5842,28 +5684,18 @@ int ha_spider::read_multi_range_next( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5902,11 +5734,7 @@ int ha_spider::read_multi_range_next( -1, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5940,11 +5768,7 @@ int ha_spider::read_multi_range_next( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5969,13 +5793,9 @@ int ha_spider::read_multi_range_next( break; } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -6004,7 +5824,7 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -6461,27 +6281,17 @@ int ha_spider::rnd_next_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -6513,11 +6323,7 @@ int ha_spider::rnd_next_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -6542,13 +6348,9 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -6577,7 +6379,7 @@ int ha_spider::rnd_next_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -7076,25 +6878,15 @@ int ha_spider::ft_read_internal( uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_SELECT_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -7126,11 +6918,7 @@ int ha_spider::ft_read_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -7155,13 +6943,9 @@ int ha_spider::ft_read_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -7190,7 +6974,7 @@ int ha_spider::ft_read_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -10933,25 +10717,15 @@ int ha_spider::drop_tmp_tables() uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_TMP_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((tmp_error_num = spider_db_set_names(this, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -10985,11 +10759,7 @@ int ha_spider::drop_tmp_tables() -1, &need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - tmp_error_num = spider_db_errorno(conn); + tmp_error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -11013,11 +10783,7 @@ int ha_spider::drop_tmp_tables() } error_num = tmp_error_num; } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } spider_clear_bit(result_list.tmp_table_created, roop_count); diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index cc3a6b52719..8cb55e8415f 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2568,7 +2568,6 @@ void *spider_bg_conn_action( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (spider->use_fields) { if ((error_num = dbton_handler->set_sql_for_exec(sql_type, @@ -2587,16 +2586,12 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } } - pthread_mutex_lock(&conn->mta_conn_mutex); + /* todo: is it ok if the following statement is not locked? */ sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (!result_list->bgs_error) { - conn->need_mon = &spider->need_mons[conn->link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); if (!(result_list->bgs_error = spider_db_set_names(spider, conn, conn->link_idx))) { @@ -2665,13 +2660,7 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } else { spider->connection_ids[conn->link_idx] = conn->connection_id; @@ -2746,24 +2735,14 @@ void *spider_bg_conn_action( { DBUG_PRINT("info",("spider bg exec sql start")); spider = (ha_spider*) conn->bg_target; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[conn->link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); *conn->bg_error_num = spider_db_query_with_set_names( conn->bg_sql_type, spider, conn, conn->link_idx ); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); conn->bg_exec_sql = FALSE; continue; } @@ -4134,3 +4113,42 @@ void spider_free_ipport_conn(void *info) } DBUG_VOID_RETURN; } + +void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon) +{ + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); + conn->need_mon = need_mon; + DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); + DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; +} + +int spider_unlock_after_query(SPIDER_CONN *conn, int ret) +{ + DBUG_ASSERT(conn->mta_conn_mutex_lock_already); + DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + pthread_mutex_unlock(&conn->mta_conn_mutex); + return ret; +} + +int spider_unlock_after_query_1(SPIDER_CONN *conn) +{ + DBUG_ASSERT(conn->mta_conn_mutex_lock_already); + DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + return spider_db_errorno(conn); +} + +int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table) +{ + DBUG_ASSERT(conn->mta_conn_mutex_lock_already); + DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); + conn->mta_conn_mutex_lock_already = FALSE; + conn->mta_conn_mutex_unlock_later = FALSE; + return spider_db_store_result(spider, link_idx, table); +} diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index 405832a1e7b..59802b00712 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -24,6 +24,8 @@ #define SPIDER_SIMPLE_RECORDS 3 #define SPIDER_SIMPLE_CHECKSUM_TABLE 4 +struct TABLE; + /* The SPIDER_CONN_LOOP_CHECK has been added to the loop_check queue to check for self-reference. @@ -454,3 +456,11 @@ SPIDER_CONN* spider_get_conn_from_idle_connection int *error_num ); void spider_free_ipport_conn(void *info); + +void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon); + +int spider_unlock_after_query(SPIDER_CONN *conn, int ret); + +int spider_unlock_after_query_1(SPIDER_CONN *conn); + +int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index a3113059143..8750e87237e 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -100,8 +100,6 @@ int spider_db_connect( } } - if (thd) - { conn->connect_timeout = spider_param_connect_timeout(thd, share->connect_timeouts[link_idx]); conn->net_read_timeout = spider_param_net_read_timeout(thd, @@ -113,16 +111,6 @@ int spider_db_connect( connect_retry_count = 0; else connect_retry_count = spider_param_connect_retry_count(thd); - } else { - conn->connect_timeout = spider_param_connect_timeout(NULL, - share->connect_timeouts[link_idx]); - conn->net_read_timeout = spider_param_net_read_timeout(NULL, - share->net_read_timeouts[link_idx]); - conn->net_write_timeout = spider_param_net_write_timeout(NULL, - share->net_write_timeouts[link_idx]); - connect_retry_interval = spider_param_connect_retry_interval(NULL); - connect_retry_count = spider_param_connect_retry_count(NULL); - } DBUG_PRINT("info",("spider connect_timeout=%u", conn->connect_timeout)); DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); @@ -923,19 +911,10 @@ int spider_db_query_for_bulk_update( SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_db_query_for_bulk_update"); - pthread_mutex_assert_owner(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[link_idx] && spider->need_mons[link_idx] @@ -969,11 +948,7 @@ int spider_db_query_for_bulk_update( -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -1018,11 +993,7 @@ int spider_db_query_for_bulk_update( } if (error_num > 0 && !conn->db_conn->is_dup_entry_error(error_num)) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[link_idx] && spider->need_mons[link_idx] @@ -1046,12 +1017,7 @@ int spider_db_query_for_bulk_update( } DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_unlock_after_query(conn, 0)); } size_t spider_db_real_escape_string( @@ -4689,16 +4655,16 @@ int spider_db_seek_next( link_idx = link_idx_holder->link_idx; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, link_idx))) { DBUG_PRINT("info",("spider error_num 6=%d", error_num)); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (fields->is_first_link_ok_chain(link_idx_chain)) { @@ -4711,18 +4677,10 @@ int spider_db_seek_next( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( spider->need_mons[link_idx] ) { @@ -4739,11 +4697,7 @@ int spider_db_seek_next( result_list->quick_mode, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( spider->need_mons[link_idx] ) { @@ -4753,14 +4707,9 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider->connection_ids[link_idx] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (fields->is_first_link_ok_chain(link_idx_chain)) { - if ((error_num = spider_db_store_result(spider, link_idx, - table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4775,7 +4724,7 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, link_idx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -4796,16 +4745,16 @@ int spider_db_seek_next( } spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_PRINT("info",("spider error_num 6=%d", error_num)); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (roop_count == link_ok) { @@ -4818,18 +4767,10 @@ int spider_db_seek_next( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -4862,11 +4803,7 @@ int spider_db_seek_next( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -4892,14 +4829,9 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, - table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4929,7 +4861,7 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -5066,15 +4998,15 @@ int spider_db_seek_last( } conn = spider->conns[roop_count]; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (roop_count == link_ok) { @@ -5087,18 +5019,10 @@ int spider_db_seek_last( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5131,11 +5055,7 @@ int spider_db_seek_last( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5160,13 +5080,9 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -5195,7 +5111,7 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -5283,25 +5199,15 @@ int spider_db_seek_last( } conn = spider->conns[roop_count]; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5334,11 +5240,7 @@ int spider_db_seek_last( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5363,13 +5265,9 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -5398,7 +5296,7 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } DBUG_RETURN(spider_db_fetch(buf, spider, table)); @@ -6044,7 +5942,6 @@ int spider_db_bulk_insert( sql_type = SPIDER_SQL_TYPE_INSERT_SQL; conn = spider->conns[roop_count2]; dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count2))) { @@ -6052,21 +5949,12 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count2]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count2]); if ((error_num = spider_db_set_names(spider, conn, roop_count2))) { if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count2] && spider->need_mons[roop_count2] @@ -6106,11 +5994,7 @@ int spider_db_bulk_insert( { conn->db_conn->set_dup_key_idx(spider, roop_count2); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6137,16 +6021,12 @@ int spider_db_bulk_insert( } DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (!insert_info && copy_info) { insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (first_insert_link_idx == -1) { first_insert_link_idx = roop_count2; @@ -6155,13 +6035,7 @@ int spider_db_bulk_insert( } conn = first_insert_conn; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[first_insert_link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[first_insert_link_idx]); if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); if (table->next_number_field && @@ -6181,12 +6055,7 @@ int spider_db_bulk_insert( else if ((error_num = dbton_handler-> show_last_insert_id(first_insert_link_idx, last_insert_id))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } table->next_number_field->set_notnull(); if ( @@ -6195,19 +6064,10 @@ int spider_db_bulk_insert( (error_num = table->next_number_field->store( last_insert_id, TRUE)) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); spider->store_last_insert_id = 0; } if ( @@ -6520,25 +6380,15 @@ int spider_db_update( conn = spider->conns[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; conn->ignore_dup_key = spider->wide_handler->ignore_dup_key; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_UPDATE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -6571,11 +6421,7 @@ int spider_db_update( -1, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6612,12 +6458,7 @@ int spider_db_update( if ((error_num = dbton_hdl->append_insert_for_recovery( SPIDER_SQL_TYPE_INSERT_SQL, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, spider->wide_handler->trx->thd, @@ -6628,11 +6469,7 @@ int spider_db_update( -1, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6660,11 +6497,7 @@ int spider_db_update( DBUG_RETURN(error_num); } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); result_list->update_sqls[roop_count].length(0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -6778,24 +6611,14 @@ int spider_db_direct_update( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_setup_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -6831,11 +6654,7 @@ int spider_db_direct_update( ) && (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6870,11 +6689,7 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); DBUG_RETURN(0); @@ -6976,24 +6791,14 @@ int spider_db_direct_update( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7030,11 +6835,7 @@ int spider_db_direct_update( (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->wide_handler->ignore_dup_key) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -7069,11 +6870,7 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); DBUG_RETURN(0); @@ -7128,32 +6925,18 @@ int spider_db_delete( ) { conn = spider->conns[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_query_with_set_names( SPIDER_SQL_TYPE_DELETE_SQL, spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); result_list->update_sqls[roop_count].length(0); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) @@ -7238,24 +7021,14 @@ int spider_db_direct_delete( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_setup_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7288,11 +7061,7 @@ int spider_db_direct_delete( -1, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7316,17 +7085,13 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } int error_num2 = 0; if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) @@ -7404,24 +7169,14 @@ int spider_db_direct_delete( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7454,11 +7209,7 @@ int spider_db_direct_delete( -1, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7482,17 +7233,13 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } int error_num2 = 0; if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) @@ -7527,18 +7274,12 @@ int spider_db_delete_all_rows( uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id]; conn = spider->conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); spider_conn_set_timeout_from_share(conn, roop_count, spider->wide_handler->trx->thd, share); @@ -7560,11 +7301,7 @@ int spider_db_delete_all_rows( /* retry */ if ((error_num = spider_db_ping(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7590,11 +7327,7 @@ int spider_db_delete_all_rows( } if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7627,11 +7360,7 @@ int spider_db_delete_all_rows( -1, &spider->need_mons[roop_count]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7656,11 +7385,7 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7685,11 +7410,7 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) DBUG_RETURN(error_num); @@ -9462,13 +9183,7 @@ int spider_db_udf_direct_sql( sql_command_backup = c_thd->lex->sql_command; c_thd->lex->sql_command = SQLCOM_INSERT; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ( !(error_num = spider_db_udf_direct_sql_set_names(direct_sql, trx, conn)) && !(error_num = spider_db_udf_direct_sql_select_db(direct_sql, conn)) @@ -9690,11 +9405,7 @@ int spider_db_udf_direct_sql( } while (status == 0); } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (need_trx_end && insert_start) { if (error_num) @@ -9853,20 +9564,10 @@ int spider_db_udf_ping_table( spider.conn_link_idx = &tmp_conn_link_idx; spider.db_request_phase = &db_request_phase; spider.db_request_id = &db_request_id; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_ping(&spider, conn, 0))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); if (error_num == ER_CON_COUNT_ERROR) @@ -9878,11 +9579,7 @@ int spider_db_udf_ping_table( share->server_names[0]); DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (!ping_only) { int init_sql_alloc_size = @@ -9925,20 +9622,10 @@ int spider_db_udf_ping_table( my_afree(sql_buf); DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_set_names(&spider, conn, 0))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); DBUG_PRINT("info",("spider error_num=%d", error_num)); @@ -9953,23 +9640,15 @@ int spider_db_udf_ping_table( -1, &need_mon) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num = spider_unlock_after_query_1(conn); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); DBUG_PRINT("info",("spider error_num=%d", error_num)); my_afree(sql_buf); DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; + spider_unlock_after_query(conn, 0); spider_db_discard_result(&spider, 0, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); } table_mon_list->last_mon_result = 0; @@ -10185,34 +9864,18 @@ int spider_db_udf_ping_table_mon_next( DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_ping(&spider, conn, 0))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); my_afree(sql_buf); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + DBUG_RETURN(spider_unlock_after_query(conn, ER_CONNECT_TO_FOREIGN_DATA_SOURCE)); } if ((error_num = spider_db_set_names(&spider, conn, 0))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } spider_conn_set_timeout_from_share(conn, 0, thd, share); if (spider_db_query( @@ -10222,12 +9885,8 @@ int spider_db_udf_ping_table_mon_next( -1, &need_mon) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; my_afree(sql_buf); - DBUG_RETURN(spider_db_errorno(conn)); + DBUG_RETURN(spider_unlock_after_query_1(conn)); } st_spider_db_request_key request_key; request_key.spider_thread_id = trx.spider_thread_id; @@ -10237,30 +9896,22 @@ int spider_db_udf_ping_table_mon_next( request_key.next = NULL; if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } - else if ((error_num = spider_db_errorno(conn))) + else if ((error_num = spider_unlock_after_query_1(conn))) { my_afree(sql_buf); DBUG_RETURN(error_num); } + spider_unlock_after_query(conn, 0); my_error(HA_ERR_OUT_OF_MEM, MYF(0)); my_afree(sql_buf); DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); my_afree(sql_buf); error_num = res->fetch_table_mon_status(mon_table_result->result_status); res->free_result(); @@ -10338,20 +9989,10 @@ int spider_db_udf_copy_tables( spider_conn_clear_queue_at_commit(tmp_conn); if (!tmp_conn->trx_start) { - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &tmp_spider->need_mons[0]; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &tmp_spider->need_mons[0]); if (spider_db_ping(tmp_spider, tmp_conn, 0)) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; @@ -10362,18 +10003,10 @@ int spider_db_udf_copy_tables( (error_num = spider_db_start_transaction(tmp_conn, tmp_spider->need_mons)) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_start_transaction; } - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } } else { @@ -10393,20 +10026,10 @@ int spider_db_udf_copy_tables( { tmp_spider = &spider[roop_count]; tmp_conn = tmp_spider->conns[0]; - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &tmp_spider->need_mons[0]; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &tmp_spider->need_mons[0]); if (spider_db_ping(tmp_spider, tmp_conn, 0)) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; @@ -10419,21 +10042,13 @@ int spider_db_udf_copy_tables( (error_num = spider_db_lock_tables(tmp_spider, 0)) ) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); tmp_conn->table_lock = 0; if (error_num == HA_ERR_OUT_OF_MEM) my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); goto error_lock_tables; } - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); tmp_conn->table_lock = 1; } } @@ -10441,23 +10056,13 @@ int spider_db_udf_copy_tables( tmp_conn = src_tbl_conn->conn; spider_conn_set_timeout_from_share(tmp_conn, 0, copy_tables->trx->thd, src_tbl_conn->share); - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &src_tbl_conn->need_mon; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &src_tbl_conn->need_mon); if (select_ct->exec_query( tmp_conn, -1, &src_tbl_conn->need_mon) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(tmp_conn); + error_num= spider_unlock_after_query_1(tmp_conn); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); @@ -10485,11 +10090,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; @@ -10503,11 +10104,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } } @@ -10532,11 +10129,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } if ( @@ -10550,12 +10143,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); - error_num = ER_OUT_OF_RESOURCES; + error_num= spider_unlock_after_query(tmp_conn, ER_OUT_OF_RESOURCES); goto error_db_query; } error_num = 0; @@ -10565,20 +10153,12 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; dst_tbl_conn = dst_tbl_conn->next) { @@ -10597,11 +10177,7 @@ int spider_db_udf_copy_tables( } if (error_num) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); @@ -10609,31 +10185,12 @@ int spider_db_udf_copy_tables( } error_num = HA_ERR_END_OF_FILE; end_of_file = TRUE; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } if (!error_num && roop_count) { -/* - dst_tbl_conn = copy_tables->table_conn[1]; - spider_db_copy_table *source_ct = dst_tbl_conn->copy_table; - for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; - dst_tbl_conn = dst_tbl_conn->next) - { - insert_ct = dst_tbl_conn->copy_table; - if (insert_ct->copy_insert_values(source_ct)) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); - error_num = ER_OUT_OF_RESOURCES; - goto error_db_query; - } - } -*/ #ifndef WITHOUT_SPIDER_BG_SEARCH if (copy_tables->bg_mode) { @@ -10654,13 +10211,7 @@ int spider_db_udf_copy_tables( { tmp_conn = dst_tbl_conn->conn; insert_ct = dst_tbl_conn->copy_table; - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &dst_tbl_conn->need_mon; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &dst_tbl_conn->need_mon); spider_conn_set_timeout_from_share(tmp_conn, 0, copy_tables->trx->thd, dst_tbl_conn->share); if (insert_ct->exec_query( @@ -10668,21 +10219,13 @@ int spider_db_udf_copy_tables( -1, &dst_tbl_conn->need_mon) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(tmp_conn); + error_num= spider_unlock_after_query_1(tmp_conn); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); goto error_db_query; } else { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -10818,20 +10361,14 @@ int spider_db_open_handler( SPIDER_CONN *conn, int link_idx ) { - int error_num; + int error_num= 0; SPIDER_SHARE *share = spider->share; uint *handler_id_ptr = &spider->m_handler_id[link_idx] ; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_open_handler"); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if (!spider->handler_opened(link_idx, conn->conn_kind)) *handler_id_ptr = conn->opened_handlers; if (!spider->handler_opened(link_idx, conn->conn_kind)) @@ -10867,20 +10404,9 @@ int spider_db_open_handler( } DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); error: - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } @@ -10890,31 +10416,17 @@ int spider_db_close_handler( int link_idx, uint tgt_conn_kind ) { - int error_num; + int error_num= 0; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_close_handler"); DBUG_PRINT("info",("spider conn=%p", conn)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if (spider->handler_opened(link_idx, tgt_conn_kind)) { dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); if ((error_num = dbton_hdl->append_close_handler_part( SPIDER_SQL_TYPE_HANDLER, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - + goto error; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -10933,20 +10445,9 @@ int spider_db_close_handler( conn->opened_handlers--; DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); error: - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index f0d0a166ed3..9ab15058253 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2489,37 +2489,24 @@ int spider_db_mbase::select_db( DBUG_RETURN(mysql_select_db(db_conn, dbname)); } +static int spider_db_query_with_lock(SPIDER_CONN *conn, const char *query, + uint len, int *need_mon) +{ + int error_num= 0; + spider_lock_before_query(conn, need_mon); + if (spider_db_query(conn, query, len, -1, need_mon)) + error_num= spider_db_errorno(conn); + return spider_unlock_after_query(conn, error_num); +} + int spider_db_mbase::consistent_snapshot( int *need_mon ) { DBUG_ENTER("spider_db_mbase::consistent_snapshot"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR, - SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR, + SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN, need_mon)); } bool spider_db_mbase::trx_start_in_bulk_sql() @@ -2554,77 +2541,30 @@ int spider_db_mbase::commit( ) { DBUG_ENTER("spider_db_mbase::commit"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_COMMIT_STR, - SPIDER_SQL_COMMIT_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, SPIDER_SQL_COMMIT_STR, + SPIDER_SQL_COMMIT_LEN, need_mon)); } int spider_db_mbase::rollback( int *need_mon ) { bool is_error; - int error_num; + int error_num= 0; DBUG_ENTER("spider_db_mbase::rollback"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ROLLBACK_STR, - SPIDER_SQL_ROLLBACK_LEN, - -1, - need_mon) - ) { - is_error = conn->thd->is_error(); - error_num = spider_db_errorno(conn); - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !is_error - ) + spider_lock_before_query(conn, need_mon); + if (spider_db_query(conn, SPIDER_SQL_ROLLBACK_STR, + SPIDER_SQL_ROLLBACK_LEN, -1, need_mon)) + { + is_error= conn->thd->is_error(); + error_num= spider_db_errorno(conn); + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && !is_error) + { conn->thd->clear_error(); - else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + error_num= 0; } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_db_mbase::xa_start( @@ -2657,32 +2597,8 @@ int spider_db_mbase::xa_end( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_END_STR, SPIDER_SQL_XA_END_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_prepare( @@ -2698,32 +2614,8 @@ int spider_db_mbase::xa_prepare( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_PREPARE_STR, SPIDER_SQL_XA_PREPARE_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_commit( @@ -2739,32 +2631,8 @@ int spider_db_mbase::xa_commit( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_COMMIT_STR, SPIDER_SQL_XA_COMMIT_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_rollback( @@ -2780,32 +2648,8 @@ int spider_db_mbase::xa_rollback( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_ROLLBACK_STR, SPIDER_SQL_XA_ROLLBACK_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } bool spider_db_mbase::set_trx_isolation_in_bulk_sql() @@ -2824,113 +2668,21 @@ int spider_db_mbase::set_trx_isolation( switch (trx_isolation) { case ISO_READ_UNCOMMITTED: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, - SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN, need_mon)); case ISO_READ_COMMITTED: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_READ_COMMITTED_STR, - SPIDER_SQL_ISO_READ_COMMITTED_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN, need_mon)); case ISO_REPEATABLE_READ: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_REPEATABLE_READ_STR, - SPIDER_SQL_ISO_REPEATABLE_READ_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_REPEATABLE_READ_STR, + SPIDER_SQL_ISO_REPEATABLE_READ_LEN, need_mon)); case ISO_SERIALIZABLE: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_SERIALIZABLE_STR, - SPIDER_SQL_ISO_SERIALIZABLE_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN, need_mon)); default: DBUG_RETURN(HA_ERR_UNSUPPORTED); } @@ -2951,60 +2703,12 @@ int spider_db_mbase::set_autocommit( DBUG_ENTER("spider_db_mbase::set_autocommit"); DBUG_PRINT("info",("spider this=%p", this)); if (autocommit) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_AUTOCOMMIT_ON_STR, - SPIDER_SQL_AUTOCOMMIT_ON_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_AUTOCOMMIT_OFF_STR, - SPIDER_SQL_AUTOCOMMIT_OFF_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN, need_mon)); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN, need_mon)); } bool spider_db_mbase::set_sql_log_off_in_bulk_sql() @@ -3021,60 +2725,12 @@ int spider_db_mbase::set_sql_log_off( DBUG_ENTER("spider_db_mbase::set_sql_log_off"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_log_off) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_SQL_LOG_ON_STR, - SPIDER_SQL_SQL_LOG_ON_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_SQL_LOG_OFF_STR, - SPIDER_SQL_SQL_LOG_OFF_LEN, - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_SQL_LOG_ON_STR, + SPIDER_SQL_SQL_LOG_ON_LEN, need_mon)); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_SQL_LOG_OFF_STR, + SPIDER_SQL_SQL_LOG_OFF_LEN, need_mon)); } bool spider_db_mbase::set_wait_timeout_in_bulk_sql() @@ -3102,32 +2758,8 @@ int spider_db_mbase::set_wait_timeout( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql_str.q_append(SPIDER_SQL_WAIT_TIMEOUT_STR, SPIDER_SQL_WAIT_TIMEOUT_LEN); sql_str.q_append(timeout_str, timeout_str_length); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } bool spider_db_mbase::set_sql_mode_in_bulk_sql() @@ -3165,32 +2797,8 @@ int spider_db_mbase::set_sql_mode( } } sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } bool spider_db_mbase::set_time_zone_in_bulk_sql() @@ -3217,32 +2825,8 @@ int spider_db_mbase::set_time_zone( sql_str.q_append(SPIDER_SQL_TIME_ZONE_STR, SPIDER_SQL_TIME_ZONE_LEN); sql_str.q_append(tz_str->ptr(), tz_str->length()); sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } int spider_db_mbase::exec_simple_sql_with_result( @@ -3254,17 +2838,10 @@ int spider_db_mbase::exec_simple_sql_with_result( int *need_mon, SPIDER_DB_RESULT **res ) { - int error_num; + int error_num= 0; DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result"); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, - share); + spider_lock_before_query(conn, need_mon); + spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, share); if ( (error_num = spider_db_set_names_internal(trx, share, conn, all_link_idx, need_mon)) || @@ -3278,87 +2855,39 @@ int spider_db_mbase::exec_simple_sql_with_result( (error_num = spider_db_errorno(conn)) ) ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping_internal(share, conn, - all_link_idx, need_mon))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names_internal(trx, share, conn, - all_link_idx, need_mon))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, - share); - if (spider_db_query( - conn, - sql, - sql_length, - -1, - need_mon) + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); - DBUG_RETURN(error_num); + if ((error_num = spider_db_ping_internal(share, conn, + all_link_idx, need_mon))) + goto unlock; + if ((error_num= spider_db_set_names_internal(trx, share, conn, + all_link_idx, need_mon))) + goto unlock; + spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, + share); + if (spider_db_query( + conn, + sql, + sql_length, + -1, + need_mon) + ) { + error_num= spider_db_errorno(conn); + goto unlock; + } + } else + goto unlock; } - } - if (!(*res = store_result(NULL, NULL, &error_num))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - if (error_num) + if (!(*res = store_result(NULL, NULL, &error_num))) { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); - DBUG_RETURN(error_num); + if (error_num || (error_num= spider_db_errorno(conn)) || + (error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE)) + goto unlock; } - else if ((error_num = spider_db_errorno(conn))) - { - DBUG_PRINT("info", ("spider error_num=%d 6", error_num)); - DBUG_RETURN(error_num); - } else { - DBUG_PRINT("info", ("spider error_num=%d 7", - ER_QUERY_ON_FOREIGN_DATA_SOURCE)); - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); - } - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_db_mbase::show_master_status( @@ -3411,10 +2940,6 @@ int spider_db_mbase::show_master_status( spider_store_binlog_pos_gtid(table, NULL, 0, conn->access_charset); } } -/* - res->free_result(); - delete res; -*/ if (error_num) { DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); @@ -3480,10 +3005,6 @@ int spider_db_mbase::select_binlog_gtid_pos( { spider_store_binlog_pos_gtid(table, gtid_pos, strlen(gtid_pos), conn->access_charset); } -/* - res->free_result(); - delete res; -*/ if (error_num) { DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); @@ -4016,70 +3537,15 @@ int spider_db_mysql_util::append_column_value( ptr = tmp_str.get_str(); } else if (field->type() == MYSQL_TYPE_GEOMETRY) { -/* - uint mlength = SIZEOF_STORED_DOUBLE, lcnt; - uchar *dest = (uchar *) buf; - const uchar *source; - for (lcnt = 0; lcnt < 4; lcnt++) - { - mlength = SIZEOF_STORED_DOUBLE; - source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; - while (mlength--) - *dest++ = *--source; - } - tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); -*/ #ifdef DBUG_TRACE double xmin, xmax, ymin, ymax; -/* - float8store(buf,xmin); - float8store(buf+8,xmax); - float8store(buf+16,ymin); - float8store(buf+24,ymax); - memcpy(&xmin,new_ptr,sizeof(xmin)); - memcpy(&xmax,new_ptr + 8,sizeof(xmax)); - memcpy(&ymin,new_ptr + 16,sizeof(ymin)); - memcpy(&ymax,new_ptr + 24,sizeof(ymax)); - float8get(xmin, buf); - float8get(xmax, buf + 8); - float8get(ymin, buf + 16); - float8get(ymax, buf + 24); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", - xmin, xmax, ymin, ymax)); -*/ float8get(xmin, new_ptr); float8get(xmax, new_ptr + 8); float8get(ymin, new_ptr + 16); float8get(ymax, new_ptr + 24); DBUG_PRINT("info", ("spider geo is %f %f %f %f", xmin, xmax, ymin, ymax)); -/* - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); -*/ #endif -/* - tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, - &my_charset_bin); -*/ tmp_str.length(0); tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, SPIDER_SQL_LINESTRING_HEAD_LEN); @@ -4108,27 +3574,6 @@ int spider_db_mysql_util::append_column_value( DBUG_PRINT("info", ("spider field->type() is %d", field->type())); DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); -/* - if ( - field->type() == MYSQL_TYPE_BIT || - (field->type() >= MYSQL_TYPE_TINY_BLOB && - field->type() <= MYSQL_TYPE_BLOB) - ) { - uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; - char *str_ptr; - DBUG_PRINT("info", ("spider HEX")); - if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); - str_ptr = (char *) str->ptr() + str->length(); - for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) - { - *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; - *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; - } - str->length(str->length() + ptr->length() * 2); - } else -*/ if (field->result_type() == STRING_RESULT) { DBUG_PRINT("info", ("spider STRING_RESULT")); @@ -7898,169 +7343,105 @@ int spider_mbase_share::discover_table_structure( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); SPIDER_CONN *conn; - int need_mon; + int need_mon_deref; + int *need_mon= &need_mon_deref; if (!(conn = spider_get_conn( spider_share, 0, spider_share->conn_keys[roop_count], trx, NULL, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num)) ) { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, need_mon); if (!conn->disable_reconnect) { ha_spider tmp_spider; SPIDER_WIDE_HANDLER wide_handler; - int need_mon = 0; - uint tmp_conn_link_idx = 0; - tmp_spider.wide_handler = &wide_handler; - wide_handler.trx = trx; - tmp_spider.share = spider_share; - tmp_spider.need_mons = &need_mon; - tmp_spider.conn_link_idx = &tmp_conn_link_idx; - if ((error_num = spider_db_ping(&tmp_spider, conn, 0))) + int need_mon= 0; + uint tmp_conn_link_idx= 0; + tmp_spider.wide_handler= &wide_handler; + wide_handler.trx= trx; + tmp_spider.share= spider_share; + tmp_spider.need_mons= &need_mon; + tmp_spider.conn_link_idx= &tmp_conn_link_idx; + if ((error_num= spider_db_ping(&tmp_spider, conn, 0))) { - DBUG_PRINT("info",("spider spider_db_ping error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } } spider_conn_set_timeout_from_share(conn, roop_count, trx->thd, - spider_share); - if ( - (error_num = spider_db_set_names_internal(trx, spider_share, conn, - roop_count, &need_mon)) || - ( - spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - &need_mon) && - (error_num = spider_db_errorno(conn)) - ) - ) { - DBUG_PRINT("info",("spider spider_get_trx error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_share); + if ((error_num= spider_db_set_names_internal(trx, spider_share, conn, + roop_count, need_mon)) || + (spider_db_query(conn, sql_str.ptr(), sql_str.length(), -1, + need_mon) && + (error_num= spider_db_errorno(conn)))) + { + spider_unlock_after_query(conn, 0); continue; } st_spider_db_request_key request_key; - request_key.spider_thread_id = trx->spider_thread_id; - request_key.query_id = trx->thd->query_id; - request_key.handler = NULL; - request_key.request_id = 1; - request_key.next = NULL; - spider_db_result *res; + request_key.spider_thread_id= trx->spider_thread_id; + request_key.query_id= trx->thd->query_id; request_key.handler= NULL; + request_key.request_id= 1; request_key.next= NULL; + spider_db_result * res; /* get column list */ - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - if (error_num || (error_num = spider_db_errorno(conn))) + if (!(res= conn->db_conn->store_result(NULL, &request_key, + &error_num))) { + if (error_num || (error_num= spider_db_errorno(conn))) { - DBUG_PRINT("info",("spider column store error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - /* no record */ - DBUG_PRINT("info",("spider column no record error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - if ((error_num = res->fetch_columns_for_discover_table_structure(str, - spider_share->access_charset))) - { - DBUG_PRINT("info",("spider column fetch error")); + if ((error_num= + res->fetch_columns_for_discover_table_structure( + str, spider_share->access_charset))) { + DBUG_PRINT("info", ("spider column fetch error")); res->free_result(); delete res; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - db_names_str[roop_count].ptr(), - table_names_str[roop_count].ptr()); - error_num = ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + db_names_str[roop_count].ptr(), + table_names_str[roop_count].ptr()); + error_num= ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; if (conn->db_conn->next_result()) { - DBUG_PRINT("info",("spider single result error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } /* get index list */ - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - if (error_num || (error_num = spider_db_errorno(conn))) + if (!(res= conn->db_conn->store_result(NULL, &request_key, + &error_num))) { + if (error_num || (error_num= spider_db_errorno(conn))) { - DBUG_PRINT("info",("spider index store error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - /* no record */ - DBUG_PRINT("info",("spider index no record error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - if ((error_num = res->fetch_index_for_discover_table_structure(str, - spider_share->access_charset))) - { - DBUG_PRINT("info",("spider index fetch error")); + if ((error_num= + res->fetch_index_for_discover_table_structure( + str, spider_share->access_charset))) { + DBUG_PRINT("info", ("spider index fetch error")); res->free_result(); delete res; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; - if (conn->db_conn->next_result()) - { - DBUG_PRINT("info",("spider dual result error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + if (conn->db_conn->next_result()) { + DBUG_PRINT("info", ("spider dual result error")); + spider_unlock_after_query(conn, 0); continue; } /* get table info */ @@ -8069,44 +7450,30 @@ int spider_mbase_share::discover_table_structure( if (error_num || (error_num = spider_db_errorno(conn))) { DBUG_PRINT("info",("spider table store error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } /* no record */ DBUG_PRINT("info",("spider table no record error")); - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } if ((error_num = res->fetch_table_for_discover_table_structure(str, - spider_share, spider_share->access_charset))) + spider_share, spider_share->access_charset))) { DBUG_PRINT("info",("spider table fetch error")); res->free_result(); delete res; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); if (!error_num) + { + spider_unlock_after_query(conn, 0); break; + } } DBUG_RETURN(error_num); } @@ -13401,20 +12768,12 @@ int spider_mbase_handler::show_table_status( SPIDER_CONN *conn = spider->conns[link_idx]; SPIDER_DB_RESULT *res; SPIDER_SHARE *share = spider->share; - uint pos = (2 * spider->conn_link_idx[link_idx]); + uint pos = 2 * spider->conn_link_idx[link_idx] + (sts_mode == 1 ? 0 : 1); ulonglong auto_increment_value = 0; DBUG_ENTER("spider_mbase_handler::show_table_status"); DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); - if (sts_mode == 1) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); conn->disable_connect_retry = TRUE; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -13424,8 +12783,8 @@ int spider_mbase_handler::show_table_status( ( spider_db_query( conn, - mysql_share->show_table_status[0 + pos].ptr(), - mysql_share->show_table_status[0 + pos].length(), + mysql_share->show_table_status[pos].ptr(), + mysql_share->show_table_status[pos].length(), -1, &spider->need_mons[link_idx]) && (error_num = spider_db_errorno(conn)) @@ -13438,51 +12797,29 @@ int spider_mbase_handler::show_table_status( /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); if (spider_db_query( conn, - mysql_share->show_table_status[0 + pos].ptr(), - mysql_share->show_table_status[0 + pos].length(), + mysql_share->show_table_status[pos].ptr(), + mysql_share->show_table_status[pos].length(), -1, &spider->need_mons[link_idx]) ) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); + goto unlock; } } else { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; st_spider_db_request_key request_key; request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; request_key.query_id = spider->wide_handler->trx->thd->query_id; @@ -13491,43 +12828,27 @@ int spider_mbase_handler::show_table_status( request_key.next = NULL; if (spider_param_dry_access()) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + goto unlock; } if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - if (error_num) - { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - else if ((error_num = spider_db_errorno(conn))) - DBUG_RETURN(error_num); - else { + if (error_num || (error_num = spider_db_errorno(conn))) + goto unlock; + else if (sts_mode == 1) { my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), mysql_share->table_names_str[spider->conn_link_idx[ link_idx]].ptr()); - DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); + error_num= ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + goto unlock; + } + else /* sts_mode != 1 */ + { + error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE; + goto unlock; } } - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_status( sts_mode, share->stat @@ -13556,168 +12877,29 @@ int spider_mbase_handler::show_table_status( default: break; } - DBUG_RETURN(error_num); + goto unlock; } - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - conn->disable_connect_retry = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if ( - (error_num = spider_db_set_names(spider, conn, link_idx)) || - ( - spider_db_query( - conn, - mysql_share->show_table_status[1 + pos].ptr(), - mysql_share->show_table_status[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) && - (error_num = spider_db_errorno(conn)) - ) - ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - mysql_share->show_table_status[1 + pos].ptr(), - mysql_share->show_table_status[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) - ) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = 1; - request_key.next = NULL; - if (spider_param_dry_access()) + if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL))) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + goto unlock; } - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + if (share->static_records_for_status != -1) { - conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - if (error_num || (error_num = spider_db_errorno(conn))) - DBUG_RETURN(error_num); - else - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + share->stat.records = (ha_rows) share->static_records_for_status; } + if (share->static_mean_rec_length != -1) + { + share->stat.mean_rec_length = (ulong) share->static_mean_rec_length; + } + if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value) + { + share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value; + DBUG_PRINT("info",("spider auto_increment_value=%llu", + share->lgtm_tblhnd_share->auto_increment_value)); + } +unlock: conn->disable_connect_retry = FALSE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - error_num = res->fetch_table_status( - sts_mode, - share->stat - ); - auto_increment_value = share->stat.auto_increment_value; - res->free_result(); - delete res; - if (error_num) - { - switch (error_num) - { - case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: - my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: - my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, - ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - default: - break; - } - DBUG_RETURN(error_num); - } - } - if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL))) - { - DBUG_RETURN(error_num); - } - if (share->static_records_for_status != -1) - { - share->stat.records = (ha_rows) share->static_records_for_status; - } - if (share->static_mean_rec_length != -1) - { - share->stat.mean_rec_length = (ulong) share->static_mean_rec_length; - } - if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value) - { - share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value; - DBUG_PRINT("info",("spider auto_increment_value=%llu", - share->lgtm_tblhnd_share->auto_increment_value)); - } - DBUG_RETURN(0); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::crd_mode_exchange( @@ -13739,18 +12921,10 @@ int spider_mbase_handler::show_index( SPIDER_DB_RESULT *res; int roop_count; longlong *tmp_cardinality; - uint pos = (2 * spider->conn_link_idx[link_idx]); + uint pos = 2 * spider->conn_link_idx[link_idx] + (crd_mode == 1 ? 0 : 1); DBUG_ENTER("spider_mbase_handler::show_index"); DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); - if (crd_mode == 1) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -13759,8 +12933,8 @@ int spider_mbase_handler::show_index( ( spider_db_query( conn, - mysql_share->show_index[0 + pos].ptr(), - mysql_share->show_index[0 + pos].length(), + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), -1, &spider->need_mons[link_idx]) && (error_num = spider_db_errorno(conn)) @@ -13772,48 +12946,27 @@ int spider_mbase_handler::show_index( ) { /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); if (spider_db_query( conn, - mysql_share->show_index[0 + pos].ptr(), - mysql_share->show_index[0 + pos].length(), + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); + error_num= spider_db_errorno(conn); + goto unlock; } } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; st_spider_db_request_key request_key; request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; request_key.query_id = spider->wide_handler->trx->thd->query_id; @@ -13824,20 +12977,10 @@ int spider_mbase_handler::show_index( { if (error_num || (error_num = spider_db_errorno(conn))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } /* no record is ok */ } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); if (res) { error_num = res->fetch_table_cardinality( @@ -13885,154 +13028,10 @@ int spider_mbase_handler::show_index( default: break; } - DBUG_RETURN(error_num); + goto unlock; } - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if ( - (error_num = spider_db_set_names(spider, conn, link_idx)) || - ( - spider_db_query( - conn, - mysql_share->show_index[1 + pos].ptr(), - mysql_share->show_index[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) && - (error_num = spider_db_errorno(conn)) - ) - ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - mysql_share->show_index[1 + pos].ptr(), - mysql_share->show_index[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = 1; - request_key.next = NULL; - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - if (error_num || (error_num = spider_db_errorno(conn))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - /* no record is ok */ - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - if (res) - { - error_num = res->fetch_table_cardinality( - crd_mode, - table, - share->cardinality, - share->cardinality_upd, - share->bitmap_size - ); - } - for (roop_count = 0, tmp_cardinality = share->cardinality; - roop_count < (int) table->s->fields; - roop_count++, tmp_cardinality++) - { - if (!spider_bit_is_set(share->cardinality_upd, roop_count)) - { - DBUG_PRINT("info", - ("spider uninitialized column cardinality id=%d", roop_count)); - *tmp_cardinality = -1; - } - } - if (res) - { - res->free_result(); - delete res; - } - if (error_num) - { - switch (error_num) - { - case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: - my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: - my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, - ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - default: - break; - } - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::simple_action( @@ -14084,14 +13083,8 @@ int spider_mbase_handler::simple_action( default: DBUG_ASSERT(0); DBUG_RETURN(0); - } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + } + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14113,25 +13106,9 @@ int spider_mbase_handler::simple_action( ) { /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14142,23 +13119,14 @@ int spider_mbase_handler::simple_action( -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); - DBUG_RETURN(spider_db_errorno(conn)); + error_num= spider_db_errorno(conn); + goto unlock; } } else { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; st_spider_db_request_key request_key; request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; request_key.query_id = spider->wide_handler->trx->thd->query_id; @@ -14167,31 +13135,15 @@ int spider_mbase_handler::simple_action( request_key.next = NULL; if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) - { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; else if ((error_num = spider_db_errorno(conn))) - { - DBUG_PRINT("info", ("spider error_num=%d 6", error_num)); - DBUG_RETURN(error_num); - } else { - DBUG_PRINT("info", ("spider error_num=%d 7", - ER_QUERY_ON_FOREIGN_DATA_SOURCE)); - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + goto unlock; + else { + error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE; + goto unlock; } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); switch (simple_action) { case SPIDER_SIMPLE_RECORDS: @@ -14208,12 +13160,8 @@ int spider_mbase_handler::simple_action( } res->free_result(); delete res; - if (error_num) - { - DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); - DBUG_RETURN(error_num); - } - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::show_records( @@ -14268,13 +13216,7 @@ ha_rows spider_mbase_handler::explain_select( DBUG_RETURN(HA_POS_ERROR); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -14299,23 +13241,15 @@ ha_rows spider_mbase_handler::explain_select( { if (spider->check_error_mode(error_num)) my_errno = error_num; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { if (spider->check_error_mode(error_num)) my_errno = error_num; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -14330,22 +13264,14 @@ ha_rows spider_mbase_handler::explain_select( error_num = spider_db_errorno(conn); if (spider->check_error_mode(error_num)) my_errno = error_num; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } else { if (spider->check_error_mode(error_num)) my_errno = error_num; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } st_spider_db_request_key request_key; @@ -14360,27 +13286,13 @@ ha_rows spider_mbase_handler::explain_select( { if (spider->check_error_mode(error_num)) my_errno = error_num; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } else { - my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 2, rows @@ -14390,8 +13302,10 @@ ha_rows spider_mbase_handler::explain_select( if (error_num) { my_errno = error_num; - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; } +unlock: + spider_unlock_after_query(conn, 0); DBUG_RETURN(rows); } @@ -14409,22 +13323,9 @@ int spider_mbase_handler::lock_tables( } if (str->length()) { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -14434,18 +13335,9 @@ int spider_mbase_handler::lock_tables( str->length(), -1, &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + ) + DBUG_RETURN(spider_unlock_after_query_1(conn)); + spider_unlock_after_query(conn, 0); } if (!conn->table_locked) { @@ -14477,31 +13369,9 @@ int spider_mbase_handler::unlock_tables( spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - DBUG_RETURN(spider_db_errorno(conn)); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(spider_db_query_with_lock( + conn, str->ptr(), str->length(), + &spider->need_mons[link_idx])); } } DBUG_RETURN(0); @@ -14521,22 +13391,9 @@ int spider_mbase_handler::disable_keys( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14546,20 +13403,10 @@ int spider_mbase_handler::disable_keys( str->length(), -1, &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; + ) error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::enable_keys( @@ -14576,22 +13423,9 @@ int spider_mbase_handler::enable_keys( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14601,20 +13435,10 @@ int spider_mbase_handler::enable_keys( str->length(), -1, &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; + ) error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::check_table( @@ -14632,22 +13456,9 @@ int spider_mbase_handler::check_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14658,19 +13469,10 @@ int spider_mbase_handler::check_table( -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::repair_table( @@ -14688,22 +13490,9 @@ int spider_mbase_handler::repair_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14714,19 +13503,10 @@ int spider_mbase_handler::repair_table( -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::analyze_table( @@ -14743,45 +13523,18 @@ int spider_mbase_handler::analyze_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + spider_lock_before_query(conn, &spider->need_mons[link_idx]); + error_num = spider_db_set_names(spider, conn, link_idx); + if (!error_num) + { + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, + share); + if (spider_db_query(conn, str->ptr(), str->length(), -1, + &spider->need_mons[link_idx])) + error_num = spider_db_errorno(conn); + } + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::optimize_table( @@ -14798,22 +13551,9 @@ int spider_mbase_handler::optimize_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14824,19 +13564,10 @@ int spider_mbase_handler::optimize_table( -1, &spider->need_mons[link_idx]) ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::flush_tables( @@ -14857,73 +13588,23 @@ int spider_mbase_handler::flush_tables( spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, str->ptr(), str->length(), &spider->need_mons[link_idx])); } int spider_mbase_handler::flush_logs( SPIDER_CONN *conn, int link_idx ) { - int error_num; SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_mbase_handler::flush_logs"); DBUG_PRINT("info",("spider this=%p", this)); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_FLUSH_LOGS_STR, - SPIDER_SQL_FLUSH_LOGS_LEN, - -1, - &spider->need_mons[link_idx]) - ) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_FLUSH_LOGS_STR, + SPIDER_SQL_FLUSH_LOGS_LEN, &spider->need_mons[link_idx])); } int spider_mbase_handler::insert_opened_handler( diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index fa9f041c83b..481291ec6f0 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1191,25 +1191,15 @@ static int spider_send_query( } } else { #endif - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_SELECT_SQL, link_idx, link_idx_chain))) DBUG_RETURN(error_num); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); if ((error_num = spider->check_error_mode_eof(error_num)) == @@ -1227,11 +1217,7 @@ static int spider_send_query( spider->result_list.quick_mode, &spider->need_mons[link_idx])) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); if ((error_num = spider->check_error_mode_eof(error_num)) == @@ -1243,13 +1229,9 @@ static int spider_send_query( DBUG_RETURN(error_num); } spider->connection_ids[link_idx] = conn->connection_id; - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; if (fields->is_first_link_ok_chain(link_idx_chain)) { - if ((error_num = spider_db_store_result(spider, link_idx, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) { if (error_num != HA_ERR_END_OF_FILE && spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); @@ -1266,7 +1248,7 @@ static int spider_send_query( } else { spider_db_discard_result(spider, link_idx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index dc30278e66c..d41a957d436 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -5725,20 +5725,10 @@ int spider_open_all_tables( } conn->error_mode &= spider_param_error_read_mode(thd, 0); conn->error_mode &= spider_param_error_write_mode(thd, 0); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &mon_val; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &mon_val); if ((error_num = spider_db_before_query(conn, &mon_val))) { - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); spider_sys_index_end(table_tables); spider_close_sys_table(thd, table_tables, &open_tables_backup, TRUE); @@ -5747,11 +5737,7 @@ int spider_open_all_tables( free_root(&mem_root, MYF(0)); DBUG_RETURN(error_num); } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2) { From 0ba97e4dc6209bfc109b33522719270543f0658d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 11:29:57 +0800 Subject: [PATCH 48/54] MDEV-31788 Factor out calls to spider_ping_table_mon_from_table in ha_spider.cc --- storage/spider/ha_spider.cc | 1365 ++++------------------------------- 1 file changed, 140 insertions(+), 1225 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 2a49af4ee3b..140a5873034 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1387,6 +1387,58 @@ int ha_spider::index_end() DBUG_RETURN(0); } +static int spider_maybe_ping(ha_spider *spider, int link_idx, int error_num) +{ + if ( + spider->share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->wide_handler->trx, + spider->wide_handler->trx->thd, + spider->share, + link_idx, + (uint32) spider->share->monitoring_sid[link_idx], + spider->share->table_name, + spider->share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + spider->share->monitoring_kind[link_idx], + spider->share->monitoring_limit[link_idx], + spider->share->monitoring_flag[link_idx], + TRUE + ); + } + return spider->check_error_mode_eof(error_num); +} + +static int spider_maybe_ping_1(ha_spider *spider, + int link_idx, int error_num) +{ + if ( + spider->share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->wide_handler->trx, + spider->wide_handler->trx->thd, + spider->share, + link_idx, + (uint32) spider->share->monitoring_sid[link_idx], + spider->share->table_name, + spider->share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + spider->share->monitoring_kind[link_idx], + spider->share->monitoring_limit[link_idx], + spider->share->monitoring_flag[link_idx], + TRUE + ); + } + return error_num; +} int ha_spider::index_read_map_internal( uchar *buf, @@ -1552,26 +1604,9 @@ int ha_spider::index_read_map_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1596,28 +1631,7 @@ int ha_spider::index_read_map_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -1628,28 +1642,7 @@ int ha_spider::index_read_map_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -1657,26 +1650,9 @@ int ha_spider::index_read_map_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1894,26 +1870,9 @@ int ha_spider::index_read_last_map_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1938,28 +1897,7 @@ int ha_spider::index_read_last_map_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -1970,28 +1908,7 @@ int ha_spider::index_read_last_map_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -1999,26 +1916,9 @@ int ha_spider::index_read_last_map_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2285,26 +2185,9 @@ int ha_spider::index_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2330,28 +2213,7 @@ int ha_spider::index_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -2362,28 +2224,7 @@ int ha_spider::index_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -2391,26 +2232,9 @@ int ha_spider::index_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2624,26 +2448,9 @@ int ha_spider::index_last_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2669,28 +2476,7 @@ int ha_spider::index_last_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -2701,28 +2487,7 @@ int ha_spider::index_last_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -2730,26 +2495,9 @@ int ha_spider::index_last_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3006,26 +2754,9 @@ int ha_spider::read_range_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3050,28 +2781,7 @@ int ha_spider::read_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -3082,28 +2792,7 @@ int ha_spider::read_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -3111,26 +2800,9 @@ int ha_spider::read_range_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3587,26 +3259,9 @@ int ha_spider::read_multi_range_first_internal( TRUE, FALSE, (roop_count != link_ok)); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } else { #endif @@ -3630,27 +3285,7 @@ int ha_spider::read_multi_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } if (!error_num) { @@ -3663,27 +3298,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } if (!error_num) @@ -3694,26 +3309,9 @@ int ha_spider::read_multi_range_first_internal( error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } result_link_idx = link_ok; } else { @@ -4322,26 +3920,9 @@ int ha_spider::read_multi_range_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -4368,27 +3949,7 @@ int ha_spider::read_multi_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } if ( @@ -4407,27 +3968,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } spider_db_discard_multiple_result(this, roop_count, conn); @@ -4441,27 +3982,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } connection_ids[roop_count] = conn->connection_id; @@ -4470,26 +3991,9 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -4916,26 +4420,9 @@ int ha_spider::read_multi_range_next( TRUE, FALSE, (roop_count != link_ok)); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } else { #endif @@ -4959,27 +4446,7 @@ int ha_spider::read_multi_range_next( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } if (!error_num) { @@ -4992,27 +4459,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } if (!error_num) @@ -5023,26 +4470,9 @@ int ha_spider::read_multi_range_next( error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } result_link_idx = link_ok; } else { @@ -5650,26 +5080,9 @@ int ha_spider::read_multi_range_next( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -5696,27 +5109,7 @@ int ha_spider::read_multi_range_next( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } if ( @@ -5735,27 +5128,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } spider_db_discard_multiple_result(this, roop_count, conn); @@ -5769,27 +5142,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } connection_ids[roop_count] = conn->connection_id; @@ -5798,26 +5151,9 @@ int ha_spider::read_multi_range_next( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); } break; } @@ -6247,26 +5583,9 @@ int ha_spider::rnd_next_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6292,28 +5611,7 @@ int ha_spider::rnd_next_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -6324,28 +5622,7 @@ int ha_spider::rnd_next_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -6353,26 +5630,9 @@ int ha_spider::rnd_next_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6850,26 +6110,9 @@ int ha_spider::ft_read_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6887,28 +6130,7 @@ int ha_spider::ft_read_internal( if ((error_num = spider_db_set_names(this, conn, roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -6919,28 +6141,7 @@ int ha_spider::ft_read_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -6948,26 +6149,9 @@ int ha_spider::ft_read_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -7201,27 +6385,7 @@ int ha_spider::info( flag | (share->sts_init ? 0 : HA_STATUS_AUTO))) ) { pthread_mutex_unlock(&share->sts_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->sts_init) { if ( @@ -7488,27 +6652,7 @@ ha_rows ha_spider::records_in_range( share->crd_init ? 2 : 1))) { pthread_mutex_unlock(&share->crd_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->crd_init) { if ( @@ -7796,27 +6940,7 @@ int ha_spider::check_crd() share->crd_init ? 2 : 1))) { pthread_mutex_unlock(&share->crd_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->crd_init) { if ( @@ -10688,7 +9812,7 @@ int ha_spider::check_ha_range_eof() int ha_spider::drop_tmp_tables() { - int error_num = 0, tmp_error_num, need_mon; + int error_num = 0, need_mon; DBUG_ENTER("ha_spider::drop_tmp_tables"); DBUG_PRINT("info",("spider this=%p", this)); if (result_list.tmp_tables_created) @@ -10723,33 +9847,13 @@ int ha_spider::drop_tmp_tables() DBUG_RETURN(error_num); } spider_lock_before_query(conn, &need_mon); - if ((tmp_error_num = spider_db_set_names(this, conn, roop_count))) + /* todo: double check the logic here w.r.t. tmp_error_num vs error_num */ + if ((error_num = spider_db_set_names(this, conn, roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - tmp_error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - error_num = tmp_error_num; + error_num= spider_maybe_ping_1(this, roop_count, error_num); } - if (!tmp_error_num) + if (!error_num) { spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -10759,29 +9863,8 @@ int ha_spider::drop_tmp_tables() -1, &need_mons[roop_count]) ) { - tmp_error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - tmp_error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - error_num = tmp_error_num; + error_num= spider_unlock_after_query_1(conn); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } else { spider_unlock_after_query(conn, 0); } @@ -10835,37 +9918,16 @@ int ha_spider::close_opened_handler( int link_idx, bool release_conn ) { - int error_num = 0, error_num2; + int error_num = 0; DBUG_ENTER("ha_spider::close_opened_handler"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_bit_is_set(m_handler_opened, link_idx)) { - if ((error_num2 = spider_db_close_handler(this, + if ((error_num = spider_db_close_handler(this, conns[link_idx], link_idx, SPIDER_CONN_KIND_MYSQL)) ) { - if ( - share->monitoring_kind[link_idx] && - need_mons[link_idx] - ) { - error_num2 = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - link_idx, - (uint32) share->monitoring_sid[link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[link_idx], - NULL, - 0, - share->monitoring_kind[link_idx], - share->monitoring_limit[link_idx], - share->monitoring_flag[link_idx], - TRUE - ); - } - error_num = error_num2; + error_num= spider_maybe_ping_1(this, link_idx, error_num); } spider_clear_bit(m_handler_opened, link_idx); if (release_conn && !conns[link_idx]->join_trx) @@ -10914,28 +9976,7 @@ int ha_spider::index_handler_init() conns[roop_count] , roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); + DBUG_RETURN(spider_maybe_ping_1(this, roop_count, error_num)); } set_handler_opened(roop_count); } @@ -11000,28 +10041,7 @@ int ha_spider::rnd_handler_init() conns[roop_count] , roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); + DBUG_RETURN(spider_maybe_ping_1(this, roop_count, error_num)); } set_handler_opened(roop_count); spider_db_handler *dbton_hdl= @@ -13185,28 +12205,7 @@ int ha_spider::lock_tables() conns[roop_count], roop_count))) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } reset_first_link_idx(); } @@ -13216,29 +12215,8 @@ int ha_spider::lock_tables() conns[roop_count]->db_conn->have_lock_table_list() && (error_num = spider_db_lock_tables(this, roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } conns[roop_count]->table_lock = 0; - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } if (conns[roop_count]->table_lock == 2) conns[roop_count]->table_lock = 1; @@ -13252,28 +12230,7 @@ int ha_spider::lock_tables() conns[roop_count]->disable_reconnect = FALSE; if ((error_num = spider_db_unlock_tables(this, roop_count))) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } } } @@ -13323,28 +12280,7 @@ int ha_spider::dml_init() conns[roop_count], roop_count))) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } reset_first_link_idx(); if ( @@ -13361,28 +12297,7 @@ int ha_spider::dml_init() if ((error_num = spider_check_and_set_trx_isolation( conns[roop_count], &need_mons[roop_count]))) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } } conns[roop_count]->semi_trx_isolation = -1; From cc0faa1e3ea140135097bfc298d5a8b9d833dd9e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 12:05:09 +0800 Subject: [PATCH 49/54] MDEV-31788 Factor functions to reduce duplication around spider_check_and_init_casual_read in ha_spider.cc factored out static functions: - spider_prep_loop - spider_start_bg - spider_send_queries --- storage/spider/ha_spider.cc | 798 ++++++++---------------------------- 1 file changed, 160 insertions(+), 638 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 140a5873034..1eb0dc6e53f 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1440,15 +1440,117 @@ static int spider_maybe_ping_1(ha_spider *spider, return error_num; } +static void spider_prep_loop(ha_spider *spider, int *roop_start, int *roop_end, int *link_ok) +{ + int lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + *link_ok = spider_conn_link_idx_next(spider->share->link_statuses, + spider->conn_link_idx, -1, spider->share->link_count, + SPIDER_LINK_STATUS_OK); + *roop_start = spider_conn_link_idx_next(spider->share->link_statuses, + spider->conn_link_idx, -1, spider->share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + *roop_end = spider->share->link_count; + } else { + *link_ok = spider->search_link_idx; + *roop_start = spider->search_link_idx; + *roop_end = spider->search_link_idx + 1; + } +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* Returns true if the caller should return *error_num */ +static bool spider_start_bg(ha_spider* spider, int roop_count, int roop_start, int link_ok, int *error_num) +{ + if ((*error_num = spider_check_and_init_casual_read( + spider->wide_handler->trx->thd, spider, + roop_count))) + return true; + if ((*error_num = spider_bg_conn_search(spider, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + *error_num != HA_ERR_END_OF_FILE + ) { + *error_num= spider_maybe_ping(spider, roop_count, *error_num); + return true; + } + *error_num= spider->check_error_mode_eof(*error_num); + return true; + } + return false; +} +#endif + +/* Updates error_num. Returning true if the caller should return. */ +static bool spider_send_query(ha_spider *spider, TABLE *table, int link_idx, int link_ok, int *error_num) +{ + ulong sql_type; + SPIDER_CONN *conn = spider->conns[link_idx]; + if (spider->sql_kind[link_idx] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((*error_num = dbton_hdl->set_sql_for_exec(sql_type, link_idx))) + { + return true; + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + spider_lock_before_query(conn, &spider->need_mons[link_idx]); + if ((*error_num = spider_db_set_names(spider, conn, + link_idx))) + { + spider_unlock_after_query(conn, 0); + *error_num= spider_maybe_ping(spider, link_idx, *error_num); + return true; + } + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + spider->result_list.quick_mode, + &spider->need_mons[link_idx]) + ) { + *error_num= spider_unlock_after_query_1(conn); + *error_num= (spider_maybe_ping(spider, link_idx, *error_num)); + return true; + } + spider->connection_ids[link_idx] = conn->connection_id; + if (link_idx == link_ok) + { + if ((*error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) + { + if ( + *error_num != HA_ERR_END_OF_FILE + ) { + *error_num= spider_maybe_ping(spider, link_idx, *error_num); + return true; + } + *error_num= spider->check_error_mode_eof(*error_num); + return true; + } + spider->result_link_idx = link_ok; + } else { + spider_db_discard_result(spider, link_idx, conn); + spider_unlock_after_query(conn, 0); + } + return false; +} + int ha_spider::index_read_map_internal( uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag ) { - int error_num, roop_count; + int error_num; key_range start_key; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_read_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -1570,24 +1672,8 @@ int ha_spider::index_read_map_internal( } } - /* Query execution */ - int roop_start, roop_end, lock_mode, link_ok; - lock_mode = spider_conn_lock_mode(this); - if (lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -1596,71 +1682,12 @@ int ha_spider::index_read_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -1726,7 +1753,6 @@ int ha_spider::index_read_last_map_internal( ) { int error_num; key_range start_key; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_read_last_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -1837,23 +1863,8 @@ int ha_spider::index_read_last_map_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -1862,71 +1873,12 @@ int ha_spider::index_read_last_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2043,7 +1995,6 @@ int ha_spider::index_first_internal( uchar *buf ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2152,97 +2103,22 @@ int ha_spider::index_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2306,7 +2182,6 @@ int ha_spider::index_last_internal( uchar *buf ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_last_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2415,97 +2290,22 @@ int ha_spider::index_last_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2606,7 +2406,6 @@ int ha_spider::read_range_first_internal( bool sorted ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::read_range_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2721,23 +2520,8 @@ int ha_spider::read_range_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -2746,71 +2530,12 @@ int ha_spider::read_range_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3226,23 +2951,8 @@ int ha_spider::read_multi_range_first_internal( } } - int roop_start, roop_end, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -3886,24 +3596,8 @@ int ha_spider::read_multi_range_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -4387,23 +4081,8 @@ int ha_spider::read_multi_range_next( } } - int roop_start, roop_end, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -5047,23 +4726,8 @@ int ha_spider::read_multi_range_next( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -5550,97 +5214,22 @@ int ha_spider::rnd_next_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - SPIDER_CONN *conn = conns[roop_count]; - ulong sql_type; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6077,89 +5666,22 @@ int ha_spider::ft_read_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - uint dbton_id = share->sql_dbton_ids[roop_count]; - spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; - SPIDER_CONN *conn = conns[roop_count]; - if ((error_num = dbton_hdl->set_sql_for_exec( - SPIDER_SQL_TYPE_SELECT_SQL, roop_count))) - { - DBUG_RETURN(error_num); - } - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - SPIDER_SQL_TYPE_SELECT_SQL, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif From 2496779d6939f6ef6257cf56689ae2d2b85729fe Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 23 Jul 2024 13:30:17 +1000 Subject: [PATCH 50/54] MDEV-34617 galera.galera_ist_mariabackup_verify_ca fails on FreeBSD Was failing because innodb-log-file-buffering is a Linux/Windows only variable. This was introduced in MDEV-33787 to enforce O_DIRECT on Linux. --- .../suite/galera/t/galera_ist_mariabackup_verify_ca.cnf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/t/galera_ist_mariabackup_verify_ca.cnf b/mysql-test/suite/galera/t/galera_ist_mariabackup_verify_ca.cnf index ffd2306bfb3..d1d3b4eb9cd 100644 --- a/mysql-test/suite/galera/t/galera_ist_mariabackup_verify_ca.cnf +++ b/mysql-test/suite/galera/t/galera_ist_mariabackup_verify_ca.cnf @@ -10,11 +10,11 @@ ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' -innodb-log-file-buffering +loose-innodb-log-file-buffering [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' -innodb-log-file-buffering +loose-innodb-log-file-buffering [sst] ssl-mode=VERIFY_CA From 02b30044aa36eb0d99752da3026d14fa21da1e44 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 11 Sep 2024 13:37:40 +1000 Subject: [PATCH 51/54] MDEV-34650 main.having_cond_pushdown test failure - crash server (s390x) The 10.5->10.6 merge commit 3bc98a4ec4e casts the arg to an int16 pointer in set_extraction_flag_processor(). This matched the previous commit c76eabfb5e3 where set_extraction_flag was changed to have int16 arg instead of int. The commit a5e4c34991e for MDEV-29363 added a call to set_extraction_flag_processor on IMMUTABLE_FL (MARKER_IMMUTABLE in 10.6). The subsequent 10.5->10.6 merge f071b7620b2 did not cast the flag to int16 when merging this change. The result is big-endian processors cleared the immutable flag rather than set the flag, resulting in MDEV-29363 being unfixed on big-endian processors. --- sql/item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 41fec9096f8..20289c317a3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1295,7 +1295,7 @@ Item *Item::multiple_equality_transformer(THD *thd, uchar *arg) This flag will be removed at the end of the pushdown optimization by remove_immutable_flag_processor processor. */ - int new_flag= MARKER_IMMUTABLE; + int16 new_flag= MARKER_IMMUTABLE; this->walk(&Item::set_extraction_flag_processor, false, (void*)&new_flag); } From c6eadc40877f4b5d2d164a87db5b8b372926ea8d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 11 Sep 2024 14:07:32 +0300 Subject: [PATCH 52/54] Fix main.order_by_join_limit on x86-debian-12: Mask the cost numbers. --- .../include/optimizer_trace_no_costs.inc | 11 ++++++++++ mysql-test/main/order_by_limit_join.result | 20 +++++++++---------- mysql-test/main/order_by_limit_join.test | 6 ++++++ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 mysql-test/include/optimizer_trace_no_costs.inc diff --git a/mysql-test/include/optimizer_trace_no_costs.inc b/mysql-test/include/optimizer_trace_no_costs.inc new file mode 100644 index 00000000000..540ce06e685 --- /dev/null +++ b/mysql-test/include/optimizer_trace_no_costs.inc @@ -0,0 +1,11 @@ +# Mask the cost value from any field that looks like +# "xxx_cost" : double_number +# Print the +# "xxx_cost" : "REPLACED" +# instead +--replace_regex /(_cost": )[0-9.e-]+/\1"REPLACED"/ +#--replace_regex /(_cost": )[0-9.e-]+/"REPLACED"/ +#--replace_regex /[0-9]+/BBB/ + +#--replace_regex /("r_engine_stats":) {[^}]*}/\1 REPLACED/ + diff --git a/mysql-test/main/order_by_limit_join.result b/mysql-test/main/order_by_limit_join.result index 3f48aa3f65f..2b9fb6b97da 100644 --- a/mysql-test/main/order_by_limit_join.result +++ b/mysql-test/main/order_by_limit_join.result @@ -108,9 +108,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 97.28224614, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 972.8224614, "use_shortcut_cost": true } @@ -160,9 +160,9 @@ JS "test_if_skip_sort_order_early": [], "can_skip_filesort": false, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 2097.281246, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 20972.81246, "use_shortcut_cost": true } @@ -244,9 +244,9 @@ JS } ], "can_skip_filesort": false, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 24059.12698, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 240591.2698, "use_shortcut_cost": false } @@ -363,9 +363,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 47079.71684, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 98.29697856, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 982.9697856, "use_shortcut_cost": true } @@ -448,9 +448,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 97.28224614, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 972.8224614, "use_shortcut_cost": true } diff --git a/mysql-test/main/order_by_limit_join.test b/mysql-test/main/order_by_limit_join.test index da05cdc30c3..3b60581871c 100644 --- a/mysql-test/main/order_by_limit_join.test +++ b/mysql-test/main/order_by_limit_join.test @@ -68,6 +68,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -95,6 +96,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -121,6 +123,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -140,6 +143,7 @@ limit 10; set @trace=(select trace from information_schema.optimizer_trace); --echo # This will show nothing as limit shortcut code figures that --echo # it's not possible to use t1 to construct shortcuts: +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -169,6 +173,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -197,6 +202,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; From 3ae4ecbfc5744625cba57a52d6ecc8d9af1f63b2 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 10 Sep 2024 15:52:13 +0300 Subject: [PATCH 53/54] MDEV-34867 engine S3 cause 500 error for huawei buckets Add support for removing the Content-Type header to the S3 engine. This is required for compatibility with some S3 providers. This also adds a provider option to the S3 engine which will turn on relevant compatibility options for specific providers. This was required for getting MariaDB S3 engine to work with "Huawei Cloud S3". To get Huawei S3 storage to work on has set one of the following S3 options: s3_provider=Huawei s3_ssl_no_verify=1 Author: Andrew Hutchings --- mysql-test/suite/s3/basic.result | 3 +++ mysql-test/suite/s3/my.cnf | 2 ++ mysql-test/suite/s3/slave.cnf | 2 ++ mysql-test/suite/s3/suite.pm | 13 +++++++++++++ storage/maria/aria_s3_copy.cc | 32 ++++++++++++++++++++++++++++++++ storage/maria/ha_s3.cc | 23 ++++++++++++++++++++++- storage/maria/libmarias3 | 2 +- storage/maria/s3_func.c | 23 +++++++++++++++++++++++ storage/maria/s3_func.h | 5 +++++ 9 files changed, 103 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/s3/basic.result b/mysql-test/suite/s3/basic.result index 790806ee43c..47c35d8cfbe 100644 --- a/mysql-test/suite/s3/basic.result +++ b/mysql-test/suite/s3/basic.result @@ -130,16 +130,19 @@ s3_block_size X s3_bucket X s3_debug X s3_host_name X +s3_no_content_type X s3_pagecache_age_threshold X s3_pagecache_buffer_size X s3_pagecache_division_limit X s3_pagecache_file_hash_size X s3_port X s3_protocol_version X +s3_provider X s3_region X s3_replicate_alter_as_create_select X s3_secret_key X s3_slave_ignore_updates X +s3_ssl_no_verify X s3_use_http X show variables like "s3_slave%"; Variable_name Value diff --git a/mysql-test/suite/s3/my.cnf b/mysql-test/suite/s3/my.cnf index f851aa18d6d..4f4049cf89b 100644 --- a/mysql-test/suite/s3/my.cnf +++ b/mysql-test/suite/s3/my.cnf @@ -12,6 +12,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY s3-region=@ENV.S3_REGION s3-port=@ENV.S3_PORT s3-use-http=@ENV.S3_USE_HTTP +s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY +s3-provider=@ENV.S3_PROVIDER #s3-host-name=s3.amazonaws.com #s3-protocol-version=Amazon diff --git a/mysql-test/suite/s3/slave.cnf b/mysql-test/suite/s3/slave.cnf index 4f4d3d39ac7..729a48c49eb 100644 --- a/mysql-test/suite/s3/slave.cnf +++ b/mysql-test/suite/s3/slave.cnf @@ -10,6 +10,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY s3-region=@ENV.S3_REGION s3-port=@ENV.S3_PORT s3-use-http=@ENV.S3_USE_HTTP +s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY +s3-provider=@ENV.S3_PROVIDER # You can change the following when running the tests against # your own S3 setup diff --git a/mysql-test/suite/s3/suite.pm b/mysql-test/suite/s3/suite.pm index cdefbc5e323..383bf4f7798 100644 --- a/mysql-test/suite/s3/suite.pm +++ b/mysql-test/suite/s3/suite.pm @@ -20,6 +20,8 @@ if(connect(SOCK, $paddr)) $ENV{'S3_REGION'} = ""; $ENV{'S3_PROTOCOL_VERSION'} = "Auto"; $ENV{'S3_USE_HTTP'} = "ON"; + $ENV{'S3_SSL_NO_VERIFY'} = "OFF"; + $ENV{'S3_PROVIDER'} = "Default"; } else { @@ -62,6 +64,17 @@ else { $ENV{'S3_USE_HTTP'} = "OFF"; } + + if (!$ENV{'S3_SSL_NO_VERIFY'}) + { + $ENV{'S3_SSL_NO_VERIFY'} = "OFF"; + } + + if (!$ENV{'S3_PROVIDER'}) + { + $ENV{'S3_PROVIDER'} = "Default"; + } + } bless { }; diff --git a/storage/maria/aria_s3_copy.cc b/storage/maria/aria_s3_copy.cc index b8a0f5b7921..1b0063c21f8 100644 --- a/storage/maria/aria_s3_copy.cc +++ b/storage/maria/aria_s3_copy.cc @@ -41,7 +41,10 @@ static const char *opt_database; static const char *opt_s3_bucket="MariaDB"; static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug; static my_bool opt_s3_use_http; +static my_bool opt_s3_ssl_no_verify; +static my_bool opt_s3_no_content_type; static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1; +static ulong opt_provider= 0; static ulong opt_block_size; static ulong opt_s3_port; static char **default_argv=0; @@ -73,6 +76,13 @@ static struct my_option my_long_options[] = {"s3_use_http", 'P', "If true, force use of HTTP protocol", (char**) &opt_s3_use_http, (char**) &opt_s3_use_http, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_ssl_no_verify", 's', "If true, verification of the S3 endpoint SSL " + "certificate is disabled", + (char**) &opt_s3_ssl_no_verify, (char**) &opt_s3_ssl_no_verify, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_no_content_type", 'n', "If true, disables the Content-Type header", + (char**) &opt_s3_no_content_type, (char**) &opt_s3_no_content_type, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'c', "Use compression", &opt_compression, &opt_compression, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or " @@ -92,6 +102,10 @@ static struct my_option my_long_options[] = "Note: \"Legacy\", \"Original\" and \"Amazon\" are deprecated.", &opt_protocol_version, &opt_protocol_version, &s3_protocol_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_provider", 'R', "Enable S3 provider specific compatibility tweaks " + "\"Default\", \"Amazon\", or \"Huawei\".", + &opt_provider, &opt_provider, &s3_provider_typelib, + GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force copy even if target exists", &opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Write more information", &opt_verbose, &opt_verbose, @@ -220,6 +234,19 @@ int main(int argc, char** argv) ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size); + /* Provider specific overrides */ + switch (opt_provider) + { + case 0: /* Default */ + break; + case 1: /* Amazon */ + opt_protocol_version = 5; + break; + case 2: /* Huawei */ + opt_s3_no_content_type = 1; + break; + } + if (opt_protocol_version > 2) { uint8_t protocol_version; @@ -245,6 +272,11 @@ int main(int argc, char** argv) if (opt_s3_use_http) ms3_set_option(global_s3_client, MS3_OPT_USE_HTTP, NULL); + if (opt_s3_ssl_no_verify) + ms3_set_option(global_s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL); + + if (opt_s3_no_content_type) + ms3_set_option(global_s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL); for (; *argv ; argv++) { diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index 276703cfaea..e911bdbe242 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -78,7 +78,7 @@ #define DEFAULT_AWS_HOST_NAME "s3.amazonaws.com" static PAGECACHE s3_pagecache; -static ulong s3_block_size, s3_protocol_version; +static ulong s3_block_size, s3_protocol_version, s3_provider; static ulong s3_pagecache_division_limit, s3_pagecache_age_threshold; static ulong s3_pagecache_file_hash_size; static ulonglong s3_pagecache_buffer_size; @@ -86,6 +86,8 @@ static char *s3_bucket, *s3_access_key=0, *s3_secret_key=0, *s3_region; static char *s3_host_name; static int s3_port; static my_bool s3_use_http; +static my_bool s3_ssl_no_verify; +static my_bool s3_no_content_type; static char *s3_tmp_access_key=0, *s3_tmp_secret_key=0; static my_bool s3_debug= 0, s3_slave_ignore_updates= 0; static my_bool s3_replicate_alter_as_create_select= 0; @@ -222,6 +224,10 @@ static MYSQL_SYSVAR_BOOL(use_http, s3_use_http, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "If true, force use of HTTP protocol", NULL /*check*/, NULL /*update*/, 0 /*default*/); +static MYSQL_SYSVAR_BOOL(ssl_no_verify, s3_ssl_no_verify, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "If true, SSL certificate verifiction for the S3 endpoint is disabled", + NULL, NULL, 0); static MYSQL_SYSVAR_STR(access_key, s3_tmp_access_key, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC, "AWS access key", @@ -234,6 +240,15 @@ static MYSQL_SYSVAR_STR(region, s3_region, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "AWS region", 0, 0, ""); +static MYSQL_SYSVAR_BOOL(no_content_type, s3_no_content_type, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "If true, disables the Content-Type header, required for some providers", + NULL, NULL, 0); +static MYSQL_SYSVAR_ENUM(provider, s3_provider, + PLUGIN_VAR_RQCMDARG, + "Enable S3 provider specific compatibility tweaks " + "\"Default\", \"Amazon\", or \"Huawei\". ", + NULL, NULL, 0, &s3_provider_typelib); ha_create_table_option s3_table_option_list[]= { @@ -319,6 +334,9 @@ static my_bool s3_info_init(S3_INFO *info) lex_string_set(&info->host_name, s3_host_name); info->port= s3_port; info->use_http= s3_use_http; + info->ssl_no_verify= s3_ssl_no_verify; + info->no_content_type = s3_no_content_type; + info->provider= s3_provider; lex_string_set(&info->access_key, s3_access_key); lex_string_set(&info->secret_key, s3_secret_key); lex_string_set(&info->region, s3_region); @@ -1120,12 +1138,15 @@ static struct st_mysql_sys_var* system_variables[]= { MYSQL_SYSVAR(host_name), MYSQL_SYSVAR(port), MYSQL_SYSVAR(use_http), + MYSQL_SYSVAR(ssl_no_verify), MYSQL_SYSVAR(bucket), MYSQL_SYSVAR(access_key), MYSQL_SYSVAR(secret_key), MYSQL_SYSVAR(region), MYSQL_SYSVAR(slave_ignore_updates), MYSQL_SYSVAR(replicate_alter_as_create_select), + MYSQL_SYSVAR(no_content_type), + MYSQL_SYSVAR(provider), NULL }; diff --git a/storage/maria/libmarias3 b/storage/maria/libmarias3 index a81724ab07b..5e6aa32f96e 160000 --- a/storage/maria/libmarias3 +++ b/storage/maria/libmarias3 @@ -1 +1 @@ -Subproject commit a81724ab07bd28e16bf431419c24b6362d5894fc +Subproject commit 5e6aa32f96ebdbcaf32b90d6182685156f8198b5 diff --git a/storage/maria/s3_func.c b/storage/maria/s3_func.c index d85dc8a0b40..b8918c48d4b 100644 --- a/storage/maria/s3_func.c +++ b/storage/maria/s3_func.c @@ -43,6 +43,9 @@ static const char *protocol_types[]= {"Auto", "Original", "Amazon", "Legacy", "P TYPELIB s3_protocol_typelib= {array_elements(protocol_types)-1,"", protocol_types, NULL}; +static const char *providers[]= {"Default", "Amazon", "Huawei", NullS}; +TYPELIB s3_provider_typelib = {array_elements(providers)-1,"",providers, NULL}; + /****************************************************************************** Allocations handler for libmarias3 To be removed when we do the init allocation in mysqld.cc @@ -154,6 +157,20 @@ ms3_st *s3_open_connection(S3_INFO *s3) errno, ms3_error(errno)); my_errno= HA_ERR_NO_SUCH_TABLE; } + + /* Provider specific overrides */ + switch (s3->provider) + { + case 0: /* Default */ + break; + case 1: /* Amazon */ + s3->protocol_version = 5; + break; + case 2: /* Huawei */ + s3->no_content_type = 1; + break; + } + if (s3->protocol_version > 2) { uint8_t protocol_version; @@ -177,6 +194,12 @@ ms3_st *s3_open_connection(S3_INFO *s3) if (s3->use_http) ms3_set_option(s3_client, MS3_OPT_USE_HTTP, NULL); + if (s3->ssl_no_verify) + ms3_set_option(s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL); + + if (s3->no_content_type) + ms3_set_option(s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL); + return s3_client; } diff --git a/storage/maria/s3_func.h b/storage/maria/s3_func.h index f73a95dea24..9c0831b158d 100644 --- a/storage/maria/s3_func.h +++ b/storage/maria/s3_func.h @@ -38,6 +38,7 @@ extern struct s3_func { } s3f; extern TYPELIB s3_protocol_typelib; +extern TYPELIB s3_provider_typelib; /* Store information about a s3 connection */ @@ -47,6 +48,8 @@ struct s3_info LEX_CSTRING access_key, secret_key, region, bucket, host_name; int port; // 0 means 'Use default' my_bool use_http; + my_bool ssl_no_verify; + my_bool no_content_type; /* Will be set by caller or by ma_open() */ LEX_CSTRING database, table; @@ -63,6 +66,8 @@ struct s3_info /* Protocol for the list bucket API call. 1 for Amazon, 2 for some others */ uint8_t protocol_version; + + uint8_t provider; }; From fafcd24e023c059b4f93453bf00d7429b76de4ce Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 10 Sep 2024 19:57:51 +0300 Subject: [PATCH 54/54] Fixed compiler warning from strncpy in mysql_plugin.c --- client/mysql_plugin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 27ec0bc55e9..d025de60c62 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -738,8 +738,8 @@ static int check_options(int argc, char **argv, char *operation) { int i= 0; /* loop counter */ int num_found= 0; /* number of options found (shortcut loop) */ - char config_file[FN_REFLEN]; /* configuration file name */ - char plugin_name[FN_REFLEN]; /* plugin name */ + char config_file[FN_REFLEN+1]; /* configuration file name */ + char plugin_name[FN_REFLEN+1]; /* plugin name */ /* Form prefix strings for the options. */ const char *basedir_prefix = "--basedir="; @@ -787,8 +787,8 @@ static int check_options(int argc, char **argv, char *operation) /* read the plugin config file and check for match against argument */ else { - if (safe_strcpy_truncated(plugin_name, sizeof plugin_name, argv[i]) || - safe_strcpy_truncated(config_file, sizeof config_file, argv[i]) || + if (safe_strcpy_truncated(plugin_name, sizeof(plugin_name)-1, argv[i]) || + safe_strcpy_truncated(config_file, sizeof(config_file)-1, argv[i]) || safe_strcat(config_file, sizeof(config_file), ".ini")) { fprintf(stderr, "ERROR: argument is too long.\n");