Merge branch '10.4' into bb-10.4-mdev7486

This commit is contained in:
Galina Shalygina 2019-02-19 11:00:39 +03:00
commit 7fe1ca7ed6
91 changed files with 4340 additions and 1147 deletions

View File

@ -431,6 +431,7 @@ INCLUDE(cmake/tags.cmake)
INCLUDE(for_clients)
ADD_SUBDIRECTORY(scripts)
ADD_SUBDIRECTORY(support-files)
ADD_SUBDIRECTORY(aws_sdk)
IF(NOT CMAKE_CROSSCOMPILING)
SET(EXPORTED comp_err comp_sql factorial)

74
aws_sdk/CMakeLists.txt Normal file
View File

@ -0,0 +1,74 @@
OPTION(AWS_SDK_EXTERNAL_PROJECT "Allow to download and build AWS C++ SDK" OFF)
INCLUDE(aws_sdk)
INCLUDE(ExternalProject)
GET_PROPERTY(SDK_LIBS GLOBAL PROPERTY AWS_SDK_LIBS)
LIST(LENGTH SDK_LIBS SDK_LIBS_COUNT)
IF(SDK_LIBS_COUNT EQUAL 0)
RETURN()
ENDIF()
CHECK_AWS_SDK(RETVAL REASON)
IF(NOT RETVAL)
MESSAGE(FATAL_ERROR
"AWS C++ will not be built (${REASON}), but dependency on following components is found ${SDK_LIBS}.
Use CHECK_AWS_SDK() function before trying to build with SDK components")
ENDIF()
SET(byproducts)
FOREACH(lib ${SDK_LIBS} core)
SET(lib aws-cpp-sdk-${lib})
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
SET (loc "${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
IF(CMAKE_VERSION VERSION_GREATER "3.1")
SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${loc})
ENDIF()
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
ENDFOREACH()
# To be compatible with older cmake, we use older version of the SDK
IF(CMAKE_VERSION LESS "3.0")
SET(GIT_TAG "1.0.8")
ELSE()
SET(GIT_TAG "1.2.11")
ENDIF()
IF(MSVC_CRT_TYPE MATCHES "/MD")
SET(FORCE_SHARED_CRT ON)
ELSE()
SET(FORCE_SHARED_CRT OFF)
ENDIF()
LIST(REMOVE_DUPLICATES SDK_LIBS)
STRING( REPLACE ";" "!" SDK_LIBS_STR "${SDK_LIBS}")
#MESSAGE("SDK_LIBS_STR=${SDK_LIBS_STR}")
ExternalProject_Add(
aws_sdk_cpp
GIT_REPOSITORY "https://github.com/awslabs/aws-sdk-cpp.git"
GIT_TAG ${GIT_TAG}
UPDATE_COMMAND ""
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-cpp"
LIST_SEPARATOR !
${byproducts}
CMAKE_ARGS
-DBUILD_ONLY=${SDK_LIBS_STR}
-DBUILD_SHARED_LIBS=OFF
-DFORCE_SHARED_CRT=${FORCE_SHARED_CRT}
-DENABLE_TESTING=OFF
"-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL} ${PIC_FLAG}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
${EXTRA_SDK_CMAKE_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp
-DCMAKE_INSTALL_LIBDIR=lib
TEST_COMMAND ""
)
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)

91
cmake/aws_sdk.cmake Normal file
View File

@ -0,0 +1,91 @@
MACRO (SKIP_AWS_SDK MSG)
SET(${RETVAL} OFF PARENT_SCOPE)
SET(${REASON} ${MSG} PARENT_SCOPE)
RETURN()
ENDMACRO()
FUNCTION (CHECK_AWS_SDK RETVAL REASON)
# AWS_SDK_EXTERNAL_PROJECT must be ON
IF(NOT AWS_SDK_EXTERNAL_PROJECT)
SKIP_AWS_SDK("AWS_SDK_EXTERNAL_PROJECT is not ON")
ENDIF()
# Check compiler support
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
IF (GCC_VERSION VERSION_LESS 4.8)
SKIP_AWS_SDK("GCC VERSION too old (${GCC_VERSION}, required is 4.8 or later")
ENDIF()
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
IF ((CMAKE_CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) OR
(CLANG_VERSION_STRING AND CLANG_VERSION_STRING VERSION_LESS 3.3))
SKIP_AWS_SDK("Clang version too old, required is 3.3 or later")
ENDIF()
ELSEIF(MSVC)
IF (MSVC_VERSION LESS 1800)
SKIP_AWS_SDK("MSVC version too old, required is VS2015 or later")
ENDIF()
ELSE()
SKIP_AWS_SDK("Unsupported compiler")
ENDIF()
# Check OS support
IF (NOT(WIN32 OR APPLE OR (CMAKE_SYSTEM_NAME MATCHES "Linux")))
SKIP_AWS_SDK("OS unsupported by AWS SDK")
ENDIF()
# Build from source, using ExternalProject_Add
# AWS C++ SDK requires cmake 2.8.12
IF(CMAKE_VERSION VERSION_LESS "2.8.12")
SKIP_AWS_SDK("CMake is too old")
ENDIF()
IF(UNIX)
# Check librairies required for building SDK
FIND_PACKAGE(CURL)
IF(NOT CURL_FOUND)
SKIP_AWS_SDK("AWS C++ SDK requires libcurl development package")
ENDIF()
FIND_PATH(UUID_INCLUDE_DIR uuid/uuid.h)
IF(NOT UUID_INCLUDE_DIR)
SKIP_AWS_SDK("AWS C++ SDK requires uuid development package")
ENDIF()
IF(NOT APPLE)
FIND_LIBRARY(UUID_LIBRARIES uuid)
IF(NOT UUID_LIBRARIES)
SKIP_AWS_SDK("AWS C++ SDK requires uuid development package")
ENDIF()
FIND_PACKAGE(OpenSSL)
IF(NOT OPENSSL_FOUND)
SKIP_AWS_SDK("AWS C++ SDK requires openssl development package")
ENDIF()
ENDIF()
ENDIF()
SET(${RETVAL} ON PARENT_SCOPE)
ENDFUNCTION()
# USE_AWS_SDK_LIBS(target sdk_component1 ... sdk_component_N)
# Example usage
# USE_AWS_SDK_LIBS(aws_key_management kms s3)
FUNCTION(USE_AWS_SDK_LIBS)
SET(SDK_COMPONENTS ${ARGN})
LIST(GET SDK_COMPONENTS 0 target)
IF(NOT TARGET ${target})
MESSAGE(FATAL_ERROR "${target} is not a valid target")
ENDIF()
LIST(REMOVE_AT SDK_COMPONENTS 0)
FOREACH(comp ${SDK_COMPONENTS})
SET_PROPERTY(GLOBAL PROPERTY AWS_SDK_LIBS ${comp} APPEND)
TARGET_LINK_LIBRARIES(${target} aws-cpp-sdk-${comp})
ENDFOREACH()
TARGET_LINK_LIBRARIES(${target} aws-cpp-sdk-core)
TARGET_INCLUDE_DIRECTORIES(${target} PRIVATE ${PROJECT_BINARY_DIR}/aws_sdk/aws_sdk_cpp/include)
# Link OS libraries that AWS SDK depends on
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} bcrypt winhttp wininet userenv version)
ELSE()
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)
TARGET_LINK_LIBRARIES(${target} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES})
ENDIF()
ENDFUNCTION()

View File

@ -15735,7 +15735,7 @@ explain extended select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 33.33 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where
1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where
1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary; Using filesort
@ -15752,7 +15752,7 @@ EXPLAIN
"table_name": "t2",
"access_type": "ALL",
"rows": 90,
"filtered": 33.333,
"filtered": 63.281,
"attached_condition": "t2.b < 40 and t2.a is not null"
},
"table": {
@ -16231,7 +16231,7 @@ explain extended select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 33.33 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 90 63.28 Using where
1 PRIMARY t3 ref idx_a idx_a 5 test.t2.a 1 100.00 Using where
1 PRIMARY <derived2> ref key0 key0 128 test.t3.c 10 100.00
2 DERIVED t4 ALL idx_c NULL NULL NULL 160 100.00 Using temporary
@ -16248,7 +16248,7 @@ EXPLAIN
"table_name": "t2",
"access_type": "ALL",
"rows": 90,
"filtered": 33.333,
"filtered": 63.281,
"attached_condition": "t2.b < 40 and t2.a is not null"
},
"table": {

View File

@ -1716,7 +1716,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 0.39 Using where; Using index
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 0.38 Using where; Using index
Warnings:
Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where `test`.`t1`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b'
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
@ -1733,7 +1733,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 0.28 Using where; Using index
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 0.30 Using where; Using index
Warnings:
Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where `test`.`t2`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b'
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
@ -2078,19 +2078,19 @@ id select_type table type possible_keys key key_len ref rows Extra
explain extended select a1,a2,min(b),max(b) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 100.00 Using where; Using index
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 99.22 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
explain extended select a1,a2,b,min(c),max(c) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 40.10 Using where; Using temporary; Using filesort
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 40.10 Using where; Using temporary; Using filesort
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
@ -2098,7 +2098,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 100.00 Using where; Using index
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 77 99.22 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;

View File

@ -1280,7 +1280,7 @@ pk v pk v
SHOW STATUS LIKE 'Handler_read_%';
Variable_name Value
Handler_read_first 0
Handler_read_key 11
Handler_read_key 14
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0

View File

@ -1803,7 +1803,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 10
Handler_read_key 13
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -1818,7 +1818,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 6
Handler_read_key 7
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -2552,7 +2552,7 @@ test.t3 analyze status OK
explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1
# t3.filtered must less than 100%, too:
@ -2560,7 +2560,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1
drop table t1,t2,t3;

View File

@ -1814,7 +1814,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 10
Handler_read_key 13
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -1829,7 +1829,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 6
Handler_read_key 7
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -2563,7 +2563,7 @@ test.t3 analyze status OK
explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.99 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 1.96 Using where; Using join buffer (flat, BNLH join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1
# t3.filtered must less than 100%, too:
@ -2571,7 +2571,7 @@ explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 1.96 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1
drop table t1,t2,t3;

View File

@ -1463,8 +1463,8 @@ gtid-ignore-duplicates FALSE
gtid-pos-auto-engines
gtid-strict-mode FALSE
help TRUE
histogram-size 0
histogram-type SINGLE_PREC_HB
histogram-size 254
histogram-type DOUBLE_PREC_HB
host-cache-size 279
idle-readonly-transaction-timeout 0
idle-transaction-timeout 0

File diff suppressed because it is too large Load Diff

View File

@ -323,6 +323,7 @@ set optimizer_trace='enabled=off';
--echo # MDEV-18528: Optimizer trace support for multi-table UPDATE and DELETE
--echo #
set optimizer_trace=1;
create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t0 (a int, b int);
@ -333,3 +334,43 @@ insert into t1 select * from t0;
explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3;
select * from information_schema.optimizer_trace;
drop table ten,t0,t1;
set optimizer_trace='enabled=off';
--echo #
--echo # Merged to Materialized for derived tables
--echo #
set optimizer_trace=1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
explain select * from (select rand() from t1)q;
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
drop table t1;
set optimizer_trace='enabled=off';
--echo #
--echo # Semi-join nest
--echo #
set optimizer_trace=1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
create table t2(a int);
insert into t2 values (1),(2),(3),(1),(2),(3),(1),(2),(3);
set @save_optimizer_switch= @@optimizer_switch;
explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_inner_2);
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
--echo # with Firstmatch, mostly for tracing fix_semijoin_strategies_for_picked_join_order
set optimizer_switch='materialization=off';
explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_inner_1.a from t2 t_inner_2, t1 t_inner_1) and
t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4);
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
set optimizer_switch='materialization=on';
explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_inner_1.a from t2 t_inner_2, t1 t_inner_1) and
t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4);
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2;
set optimizer_trace='enabled=off';

View File

@ -24,7 +24,7 @@ explain select * from t1 where a=1 or b=1 {
"select_id": 1,
"steps": [
{
"expanded_query": "select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c`,`t1`.`filler` AS `filler` from `t1` where `t1`.`a` = 1 or `t1`.`b` = 1"
"expanded_query": "select t1.a AS a,t1.b AS b,t1.c AS c,t1.filler AS filler from t1 where t1.a = 1 or t1.b = 1"
}
]
}
@ -194,15 +194,11 @@ explain select * from t1 where a=1 or b=1 {
},
{
"selectivity_for_indexes": [],
"selectivity_for_columns": []
"selectivity_for_columns": [],
"cond_selectivity": 0.002
}
]
},
{
"execution_plan_for_potential_materialization": {
"steps": []
}
},
{
"considered_execution_plans": [
{

View File

@ -32,7 +32,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"select_id": 1,
"steps": [
{
"expanded_query": "select `t1`.`pk1` AS `pk1`,`t1`.`pk2` AS `pk2`,`t1`.`key1` AS `key1`,`t1`.`key2` AS `key2` from `t1` where `t1`.`pk1` <> 0 and `t1`.`key1` = 1"
"expanded_query": "select t1.pk1 AS pk1,t1.pk2 AS pk2,t1.key1 AS key1,t1.key2 AS key2 from t1 where t1.pk1 <> 0 and t1.key1 = 1"
}
]
}
@ -183,15 +183,11 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"selectivity_from_index": 0.001
}
],
"selectivity_for_columns": []
"selectivity_for_columns": [],
"cond_selectivity": 0.001
}
]
},
{
"execution_plan_for_potential_materialization": {
"steps": []
}
},
{
"considered_execution_plans": [
{

View File

@ -55,7 +55,7 @@ select * from db1.t1 {
"select_id": 1,
"steps": [
{
"expanded_query": "select `db1`.`t1`.`a` AS `a` from `t1`"
"expanded_query": "select db1.t1.a AS a from t1"
}
]
}
@ -85,11 +85,6 @@ select * from db1.t1 {
}
]
},
{
"execution_plan_for_potential_materialization": {
"steps": []
}
},
{
"considered_execution_plans": [
{
@ -157,7 +152,7 @@ select * from db1.v1 {
"view": {
"table": "v1",
"select_id": 2,
"merged": true
"algorithm": "merged"
}
},
{
@ -165,13 +160,13 @@ select * from db1.v1 {
"select_id": 2,
"steps": [
{
"expanded_query": "/* select#2 */ select `db1`.`t1`.`a` AS `a` from `t1`"
"expanded_query": "/* select#2 */ select db1.t1.a AS a from t1"
}
]
}
},
{
"expanded_query": "/* select#1 */ select `db1`.`t1`.`a` AS `a` from `v1`"
"expanded_query": "/* select#1 */ select db1.t1.a AS a from v1"
}
]
}
@ -201,11 +196,6 @@ select * from db1.v1 {
}
]
},
{
"execution_plan_for_potential_materialization": {
"steps": []
}
},
{
"considered_execution_plans": [
{

View File

@ -3347,9 +3347,9 @@ filler2 char(255),
key(a)
);
insert into t4 select a,a,a, a,a from t3;
set @tmp_h=@@histogram_size, @tmp_u=@@use_stat_tables,
set @tmp_h=@@histogram_size, @tmp_ht=@@histogram_type, @tmp_u=@@use_stat_tables,
@tmp_o=@@optimizer_use_condition_selectivity;
set histogram_size=100;
set histogram_size=100, histogram_type='single_prec_hb';
set use_stat_tables=preferably;
set optimizer_use_condition_selectivity=4;
analyze table t4 persistent for columns(b) indexes ();
@ -3363,6 +3363,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t4 index NULL a 5 NULL 1188 100.00 Using where
Warnings:
Note 1003 select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c`,`test`.`t4`.`filler1` AS `filler1`,`test`.`t4`.`filler2` AS `filler2` from `test`.`t4` where `test`.`t4`.`b` < 5000 order by `test`.`t4`.`a` limit 600
set histogram_size=@tmp_h, use_stat_tables=@tmp_u,
set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u,
optimizer_use_condition_selectivity=@tmp_o;
drop table t1,t2,t3,t4;

View File

@ -2209,9 +2209,9 @@ create table t4 (
);
insert into t4 select a,a,a, a,a from t3;
set @tmp_h=@@histogram_size, @tmp_u=@@use_stat_tables,
set @tmp_h=@@histogram_size, @tmp_ht=@@histogram_type, @tmp_u=@@use_stat_tables,
@tmp_o=@@optimizer_use_condition_selectivity;
set histogram_size=100;
set histogram_size=100, histogram_type='single_prec_hb';
set use_stat_tables=preferably;
set optimizer_use_condition_selectivity=4;
analyze table t4 persistent for columns(b) indexes ();
@ -2220,7 +2220,7 @@ analyze table t4 persistent for columns(b) indexes ();
explain extended
select * from t4 where b < 5000 order by a limit 600;
set histogram_size=@tmp_h, use_stat_tables=@tmp_u,
set histogram_size=@tmp_h, histogram_type=@tmp_ht, use_stat_tables=@tmp_u,
optimizer_use_condition_selectivity=@tmp_o;
drop table t1,t2,t3,t4;

View File

@ -2737,7 +2737,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1,p2 ALL NULL NULL NULL NULL 400 Using where
explain extended select * from t2 where b=5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 19.80 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 19.61 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` = 5
explain partitions select * from t2 where b=5;
@ -2745,7 +2745,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1000 Using where
explain extended select * from t2 partition(p0) where b=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 19.80 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 19.61 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` PARTITION (`p0`) where `test`.`t2`.`b` = 1
set @@use_stat_tables= @save_use_stat_tables;

View File

@ -350,7 +350,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
VARIABLE_NAME VARIABLE_VALUE
HANDLER_COMMIT 1
HANDLER_READ_FIRST 1
HANDLER_READ_KEY 6
HANDLER_READ_KEY 8
HANDLER_TMP_WRITE 24
# Should be 1 commit
# 4 locks (1 ha_partition + 1 ha_innobase) x 2 (lock/unlock)

View File

@ -10,6 +10,8 @@ set use_stat_tables='preferably';
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_histogram_size=@@histogram_size;
set @save_histogram_type=@@histogram_type;
set histogram_size=0;
set histogram_type='single_prec_hb';
set optimizer_use_condition_selectivity=3;
create table t1 (a int);
insert into t1 values
@ -1369,14 +1371,14 @@ test.t2 analyze status Table is already up to date
explain extended
select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10
explain extended
select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10

View File

@ -14,6 +14,8 @@ set use_stat_tables='preferably';
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_histogram_size=@@histogram_size;
set @save_histogram_type=@@histogram_type;
set histogram_size=0;
set histogram_type='single_prec_hb';
# check that statistics on nulls is used

View File

@ -13,6 +13,8 @@ set use_stat_tables='preferably';
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_histogram_size=@@histogram_size;
set @save_histogram_type=@@histogram_type;
set histogram_size=0;
set histogram_type='single_prec_hb';
set optimizer_use_condition_selectivity=3;
create table t1 (a int);
insert into t1 values
@ -1379,14 +1381,14 @@ test.t2 analyze status OK
explain extended
select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10
explain extended
select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1.96 Using where
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 10

View File

@ -6,6 +6,8 @@ select @@session.use_stat_tables;
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
set @tmp_stt_hs=@@histogram_size, @tmp_stt_ht=@@histogram_type;
set histogram_size=0, histogram_type='single_prec_hb';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
@ -680,4 +682,5 @@ select * from t1 where a=1 and b=3;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set histogram_size=@tmp_stt_hs, histogram_type=@tmp_stt_ht;
set use_stat_tables=@save_use_stat_tables;

View File

@ -6,6 +6,8 @@ select @@session.use_stat_tables;
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
set @tmp_stt_hs=@@histogram_size, @tmp_stt_ht=@@histogram_type;
set histogram_size=0, histogram_type='single_prec_hb';
--disable_warnings
DROP DATABASE IF EXISTS dbt3_s001;
@ -443,4 +445,5 @@ select * from mysql.column_stats;
analyze
select * from t1 where a=1 and b=3;
drop table t1;
set histogram_size=@tmp_stt_hs, histogram_type=@tmp_stt_ht;
set use_stat_tables=@save_use_stat_tables;

View File

@ -14,6 +14,8 @@ select @@session.use_stat_tables;
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
set @tmp_stt_hs=@@histogram_size, @tmp_stt_ht=@@histogram_type;
set histogram_size=0, histogram_type='single_prec_hb';
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
@ -712,6 +714,7 @@ select * from t1 where a=1 and b=3;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set histogram_size=@tmp_stt_hs, histogram_type=@tmp_stt_ht;
set use_stat_tables=@save_use_stat_tables;
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=

View File

@ -1,5 +1,7 @@
drop table if exists t1,t2;
set @save_use_stat_tables=@@use_stat_tables;
set @save_hist_size=@@histogram_size, @save_hist_type=@@histogram_type;
set histogram_size=0, histogram_type='single_prec_hb';
DELETE FROM mysql.table_stats;
DELETE FROM mysql.column_stats;
DELETE FROM mysql.index_stats;
@ -246,7 +248,7 @@ test t1 e 0.01 0.112 0.2250 6.2000 8 DOUBLE_PREC_HB 000005056464E1E1
test t1 f 1 5 0.2000 6.4000 8 DOUBLE_PREC_HB FF3FFF7FFFBFFFBF
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=default;
set histogram_type='single_prec_hb';
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -1504,8 +1506,8 @@ hist_size 254
hist_type DOUBLE_PREC_HB
hex(histogram) 1F00A1002B023002350238023F02430249024E02520258025D02630268026E02720276027B02800285028C02920297029D02A102A802AC02B402BC02C402CC02D302DA02E302EA02F102F802010305030C03120319031F03290333033D0343034F03590363036D037803840390039A03A603B303C303D103E003F203020412042404330440045304600472047F049104A204B804C804DE04F2040A0526053F0558056F058E05B305D905F4051306380667068406AB06DA06020731075C079407C507F8072E085E08A508DF0824096909CC092E0A760AD50A400BA90B150CAD0C310D240E130F0E103B11B9126B14F0166B192F1CB71FFF240630483FC567
decode_histogram(hist_type,histogram) 0.00047,0.00198,0.00601,0.00008,0.00008,0.00005,0.00011,0.00006,0.00009,0.00008,0.00006,0.00009,0.00008,0.00009,0.00008,0.00009,0.00006,0.00006,0.00008,0.00008,0.00008,0.00011,0.00009,0.00008,0.00009,0.00006,0.00011,0.00006,0.00012,0.00012,0.00012,0.00012,0.00011,0.00011,0.00014,0.00011,0.00011,0.00011,0.00014,0.00006,0.00011,0.00009,0.00011,0.00009,0.00015,0.00015,0.00015,0.00009,0.00018,0.00015,0.00015,0.00015,0.00017,0.00018,0.00018,0.00015,0.00018,0.00020,0.00024,0.00021,0.00023,0.00027,0.00024,0.00024,0.00027,0.00023,0.00020,0.00029,0.00020,0.00027,0.00020,0.00027,0.00026,0.00034,0.00024,0.00034,0.00031,0.00037,0.00043,0.00038,0.00038,0.00035,0.00047,0.00056,0.00058,0.00041,0.00047,0.00056,0.00072,0.00044,0.00060,0.00072,0.00061,0.00072,0.00066,0.00085,0.00075,0.00078,0.00082,0.00073,0.00108,0.00089,0.00105,0.00105,0.00151,0.00150,0.00110,0.00145,0.00163,0.00160,0.00165,0.00232,0.00201,0.00371,0.00365,0.00383,0.00459,0.00583,0.00662,0.00984,0.00969,0.01080,0.01379,0.02063,0.04308,0.05960,0.15816,0.59464
set histogram_type=default;
set histogram_size=default;
set histogram_type='single_prec_hb';
set histogram_size=0;
use test;
DROP DATABASE world;
SELECT UPPER(db_name), UPPER(table_name), cardinality
@ -1600,8 +1602,8 @@ hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t1 a 1 5 0.0000 1.0000 10 DOUBLE_PREC_HB 0000FF3FFF7FFFBFFFFF
set histogram_size=default;
set histogram_type=default;
set histogram_size=0;
set histogram_type='single_prec_hb';
drop table t1;
#
# Bug mdev-4369: histogram for a column with many distinct values
@ -1641,7 +1643,7 @@ hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
test t2 id 1 1024 0.0000 8.0000 63 SINGLE_PREC_HB 03070B0F13171B1F23272B2F33373B3F43474B4F53575B5F63676B6F73777B7F83878B8F93979B9FA3A7ABAFB3B7BBBFC3C7CBCFD3D7DBDFE3E7EBEFF3F7FB
set histogram_size=default;
set histogram_size=0;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
#
@ -1757,3 +1759,4 @@ DROP TABLE t1;
#
# End of 10.2 tests
#
set histogram_size=@save_hist_size, histogram_type=@save_hist_type;

View File

@ -5,7 +5,8 @@ drop table if exists t1,t2;
--enable_warnings
set @save_use_stat_tables=@@use_stat_tables;
set @save_hist_size=@@histogram_size, @save_hist_type=@@histogram_type;
set histogram_size=0, histogram_type='single_prec_hb';
DELETE FROM mysql.table_stats;
--sorted_result
DELETE FROM mysql.column_stats;
@ -196,7 +197,7 @@ SELECT db_name, table_name, column_name,
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=default;
set histogram_type='single_prec_hb';
ANALYZE TABLE t1;
@ -657,8 +658,8 @@ FLUSH TABLES;
--query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='COUNTRYLANGUAGE' and UPPER(column_name) = 'PERCENTAGE';
--query_vertical select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION';
set histogram_type=default;
set histogram_size=default;
set histogram_type='single_prec_hb';
set histogram_size=0;
use test;
DROP DATABASE world;
@ -732,8 +733,8 @@ select db_name, table_name, column_name,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
set histogram_size=default;
set histogram_type=default;
set histogram_size=0;
set histogram_type='single_prec_hb';
drop table t1;
@ -776,7 +777,7 @@ select db_name, table_name, column_name,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
set histogram_size=default;
set histogram_size=0;
drop table t1, t2;
@ -898,3 +899,5 @@ DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #
set histogram_size=@save_hist_size, histogram_type=@save_hist_type;

View File

@ -62,7 +62,7 @@ explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1`))))
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
@ -73,7 +73,7 @@ explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1`))))
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
@ -84,7 +84,7 @@ explain extended
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`))))
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
@ -95,7 +95,7 @@ explain extended
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`min(b2)`))))
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
@ -322,7 +322,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
4 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#3 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery4>`.`b1` and `test`.`t3`.`c2` = `<subquery4>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery3>`.`c1` and `test`.`t1`.`a2` = `<subquery3>`.`c2`))))
select * from t1
@ -452,8 +452,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery5>`.`b1` and `test`.`t3`.`c2` = `<subquery5>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery4>`.`c1` and `test`.`t1`.`a2` = `<subquery4>`.`c2`))))
@ -475,8 +475,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
5 MATERIALIZED t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#5 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery5>`.`b1` and `test`.`t3`.`c2` = `<subquery5>`.`b2`)))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery4>`.`c1` and `test`.`t3`.`c2` = `<subquery4>`.`c2`))))
@ -497,8 +497,8 @@ select * from t3
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))
@ -712,7 +712,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(/* select#2 */ select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(/* select#3 */ select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where `test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1` from `test`.`t3` where `test`.`t3`.`c2` > '0' ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where `test`.`t2`.`b1` = `<subquery4>`.`c1`)))) and <cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1` and <cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))) and <cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))
drop table t1_16, t2_16, t3_16;

View File

@ -60,9 +60,9 @@ set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off';
explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0'
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
@ -72,9 +72,9 @@ a1 a2
explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0'
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
@ -84,9 +84,9 @@ a1 a2
explain extended
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`b1` > '0'
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
@ -98,7 +98,7 @@ select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' gr
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 test.t1.a1,test.t1.a2 1 100.00
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Using temporary
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (/* select#2 */ select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`b1` > '0' group by `test`.`t2`.`b1`) join `test`.`t1` where `<subquery2>`.`b1` = `test`.`t1`.`a1` and `<subquery2>`.`min(b2)` = `test`.`t1`.`a2`
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
@ -331,12 +331,12 @@ where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
(a1, a2) in (select c1, c2 from t3
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 98.44
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 16 func,func 1 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 98.44 Using where
3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 98.44 Using where
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t2`.`b1` > '0' and `test`.`t3`.`c2` > '0'
select * from t1
@ -373,12 +373,12 @@ b2 in (select c2 from t3 where c2 LIKE '%03')) and
(a1, a2) in (select c1, c2 from t3
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 16 func,func 1 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func,func 1 100.00
5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
5 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where
5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 99.22 Using where
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
@ -399,10 +399,10 @@ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
(a1, a2) in (select c1, c2 from t3 t3c
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 16 func,func 1 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 100.00 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 99.22 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
5 MATERIALIZED t3c ALL NULL NULL NULL NULL 4 99.22 Using where
5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3c.c1,test.t3c.c2 1 100.00 Using index
4 MATERIALIZED t3b ALL NULL NULL NULL NULL 4 100.00 Using where
3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where
@ -432,12 +432,12 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL # # # 3 100.00 #
1 PRIMARY t1 ALL NULL # # # 3 99.22 #
1 PRIMARY <subquery5> eq_ref distinct_key # # # 1 100.00 #
1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
5 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
5 MATERIALIZED t3 ALL NULL # # # 4 99.22 #
5 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 #
2 MATERIALIZED t2 ALL NULL # # # 5 100.00 #
2 MATERIALIZED t2 ALL NULL # # # 5 99.22 #
4 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
3 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 50.00 #
@ -468,12 +468,12 @@ where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where
(a1, a2) in (select c1, c2 from t3
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 16 func,func 1 100.00
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where
4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'
@ -493,11 +493,11 @@ a1 = c1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 PRIMARY <subquery4> ALL distinct_key NULL NULL NULL 4 100.00 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 100.00 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join)
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where
4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t3`.`c2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'
@ -518,8 +518,8 @@ select * from t3
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(/* select#2 */ select `test`.`t1`.`a1` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1` union /* select#3 */ select `test`.`t2`.`b1` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))
@ -734,7 +734,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary; Using join buffer (flat, BNL join)
1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where `test`.`t2`.`b1` = `test`.`t3`.`c1` and `test`.`t2_16`.`b1` = `test`.`t1_16`.`a1` and `test`.`t2_16`.`b2` = `test`.`t1_16`.`a2` and `test`.`t2`.`b2` = substr(`test`.`t1_16`.`a2`,1,6) and `test`.`t3`.`c2` > '0' and concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8)

Binary file not shown.

View File

@ -11,17 +11,17 @@ while ($seqno <= $sr_max)
--let $sr_fragment_file = $MYSQLTEST_VARDIR/tmp/sr_fragment.log
--exec rm -rf $sr_fragment_file
--disable_query_log
--eval SELECT frag FROM mysql.wsrep_streaming_log WHERE seqno = $seqno INTO DUMPFILE '$sr_fragment_file'
--eval SELECT frag INTO DUMPFILE '$sr_fragment_file' FROM mysql.wsrep_streaming_log WHERE seqno = $seqno
--enable_query_log
--let $sr_binlog_file = $MYSQLTEST_VARDIR/tmp/sr_binlog.log
--exec rm -rf $sr_binlog_file
--exec cp std_data/binlog-header.log $sr_binlog_file
--exec cp std_data/binlog-header.binlog $sr_binlog_file
--exec cat $sr_fragment_file >> $sr_binlog_file
--replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=<TIMESTAMP>/ /#[0-9]+ +[0-9]+:[0-9]+:[0-9]+/<ISO TIMESTAMP>/ /pseudo_thread_id=[0-9]+/pseudo_thread_id=<PSEUDO_THREAD_ID>/ /thread_id=[0-9]+/thread_id=<QUERY_THREAD_ID>/ /table id [0-9]+/table id <TABLE_ID>/ /mapped to number [0-9]+/mapped to number <TABLE_ID>/ /auto_increment_increment=[0-9]+/auto_increment_increment=<AUTO_INCREMENT_INCREMENT>/ /auto_increment_offset=[0-9]+/auto_increment_offset=<AUTO_INCREMENT_OFFSET>/ /exec_time=[0-9]+/exec_time=<EXEC_TIME>/
--exec $MYSQL_BINLOG --skip-gtids $sr_binlog_file --base64-output=decode-rows --start-position=120 | grep -v 'SET @' 2>&1
--exec $MYSQL_BINLOG $sr_binlog_file --base64-output=decode-rows --start-position=256 --skip-annotate-row-events | grep -v 'SET @' 2>&1
--inc $seqno
}

View File

@ -0,0 +1,38 @@
connection node_2;
connection node_1;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
wsrep_last_committed_id_match
1
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connection node_1a;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection node_1;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
connection node_1a;
INSERT INTO t1 VALUES (1);
connection node_1;
wsrep_last_committed_id_match
1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
INSERT INTO t1 VALUES (1);
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1'
1
wsrep_last_committed_id_match
1
COMMIT;
wsrep_last_committed_id_advanced
1
wsrep_last_committed_id_advanced
1
SET AUTOCOMMIT=ON;
DROP TABLE t1;

View File

@ -0,0 +1,43 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
SELECT WSREP_SYNC_WAIT_UPTO_GTID(NULL);
ERROR HY000: Incorrect arguments to wsrep_sync_wait_upto_gtid
SELECT WSREP_SYNC_WAIT_UPTO_GTID('a');
ERROR HY000: Incorrect arguments to wsrep_sync_wait_upto_gtid
SELECT WSREP_SYNC_WAIT_UPTO_GTID(2);
ERROR HY000: Incorrect arguments to wsrep_sync_wait_upto_gtid
WSREP_SYNC_WAIT_UPTO
1
WSREP_SYNC_WAIT_UPTO
1
WSREP_SYNC_WAIT_UPTO
1
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection node_2;
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb";
connection node_1;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
connection node_2;
SET SESSION wsrep_sync_wait = 0;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_2a;
SET SESSION wsrep_sync_wait = 0;
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
connection node_2;
WSREP_SYNC_WAIT_UPTO
1
gtid_current = gtid_first
1
SET GLOBAL DEBUG_DBUG = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
WSREP_SYNC_WAIT_UPTO
1
seqno_current = seqno_second
1
SET DEBUG_SYNC = "RESET";
connection node_1;
DROP TABLE t1;

View File

@ -0,0 +1,68 @@
#
# Tests functions WSREP_LAST_WRITTEN_GTID and WSREP_LAST_SEEN_GTID
#
--source include/galera_cluster.inc
# Returns -1 if no transactions have been run
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
--disable_query_log
--let $seqno = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--let $state = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_uuid'`
--eval SELECT WSREP_LAST_SEEN_GTID() = '$state:$seqno' AS wsrep_last_committed_id_match;
--enable_query_log
# WSREP_LAST_WRITTEN_GTID() should not be influenced by transactions committed
# on other connections
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1a
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection node_1
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
# WSREP_LAST_SEEN_GTID() should be influenced by transactions committed
# on other connections
--connection node_1a
INSERT INTO t1 VALUES (1);
--disable_query_log
--let $wsrep_last_committed_id_conn_1a = `SELECT WSREP_LAST_SEEN_GTID()`
--enable_query_log
--connection node_1
--disable_query_log
--eval SELECT WSREP_LAST_SEEN_GTID() = '$wsrep_last_committed_id_conn_1a' AS wsrep_last_committed_id_match;
--enable_query_log
# Should not advance while a transaction is in progress
SET AUTOCOMMIT=OFF;
START TRANSACTION;
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
--disable_query_log
--let $wsrep_last_committed_id_before = `SELECT WSREP_LAST_SEEN_GTID()`
--enable_query_log
INSERT INTO t1 VALUES (1);
SELECT WSREP_LAST_WRITTEN_GTID() = '00000000-0000-0000-0000-000000000000:-1';
--disable_query_log
--eval SELECT WSREP_LAST_SEEN_GTID() = '$wsrep_last_committed_id_before' AS wsrep_last_committed_id_match;
--enable_query_log
# Should only advance after the transaction has been committed
COMMIT;
--disable_query_log
--let $seqno = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--let $state = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_uuid'`
--eval SELECT WSREP_LAST_WRITTEN_GTID() = '$state:$seqno' AS wsrep_last_committed_id_advanced;
--eval SELECT WSREP_LAST_SEEN_GTID() = '$state:$seqno' AS wsrep_last_committed_id_advanced;
--enable_query_log
SET AUTOCOMMIT=ON;
DROP TABLE t1;

View File

@ -0,0 +1 @@
--wsrep-sync-wait=0 --wsrep-causal-reads=OFF

View File

@ -0,0 +1,115 @@
#
# Tests the wsrep_sync_wait_upto variable.
#
--source include/galera_cluster.inc
--source include/have_debug_sync.inc
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
# Test with invalid values
--error ER_WRONG_ARGUMENTS
SELECT WSREP_SYNC_WAIT_UPTO_GTID(NULL);
--error ER_WRONG_ARGUMENTS
SELECT WSREP_SYNC_WAIT_UPTO_GTID('a');
--error ER_WRONG_ARGUMENTS
SELECT WSREP_SYNC_WAIT_UPTO_GTID(2);
# If set to low value, expect no waiting
--disable_query_log
--let $seqno = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--let $state = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_uuid'`
--enable_query_log
--disable_query_log
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('00000000-0000-0000-0000-000000000000:-1') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
--disable_query_log
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$state:0') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
# If set to current last_committed value
--disable_query_log
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$state:$seqno') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
# If set to very high value, will wait
--disable_query_log
--error ER_LOCK_WAIT_TIMEOUT
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$state:9223372036854775807', 1) AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
# If applier is blocked, will wait
--connection node_2
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb";
--connection node_1
# Perform two inserts and record the IDs of each
INSERT INTO t1 VALUES (2);
--let $gtid_first = `SELECT WSREP_LAST_WRITTEN_GTID()`
INSERT INTO t1 VALUES (3);
--let $gtid_second = `SELECT WSREP_LAST_WRITTEN_GTID()`
--connection node_2
SET SESSION wsrep_sync_wait = 0;
--disable_query_log
--error ER_LOCK_WAIT_TIMEOUT
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$gtid_first', 1) AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
--disable_query_log
--send_eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$gtid_first') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
# Unblock applier
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connection node_2a
SET SESSION wsrep_sync_wait = 0;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE 'SELECT WSREP_SYNC_WAIT%';
--source include/wait_condition.inc
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
--connection node_2
--reap
# Confirm that we were allowed to proceed when the applier reached $seqno_first
--let $gtid_current = `SELECT WSREP_LAST_SEEN_GTID()`
--disable_query_log
--eval SELECT '$gtid_current' = '$gtid_first' AS `gtid_current = gtid_first`
--enable_query_log
SET GLOBAL DEBUG_DBUG = "";
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
# Move forward some more, to $seqno_second;
--disable_query_log
--eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$gtid_second') AS WSREP_SYNC_WAIT_UPTO;
--enable_query_log
--let $gtid_current = `SELECT WSREP_LAST_SEEN_GTID()`
--disable_query_log
--eval SELECT '$gtid_current' = '$gtid_second' AS `seqno_current = seqno_second`
--enable_query_log
SET DEBUG_SYNC = "RESET";
--connection node_1
DROP TABLE t1;

View File

@ -0,0 +1,36 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INT PRIMARY KEY);
SET SESSION wsrep_trx_fragment_unit='ROWS';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (1), (2);
SET SESSION wsrep_trx_fragment_unit='BYTES';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (3), (4);
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (5), (6);
SET SESSION wsrep_trx_fragment_unit=default;
SET SESSION wsrep_trx_fragment_size=default;
SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 518;
Log_name Pos Event_type Server_id End_log_pos Info
mysqld-bin.000002 518 Gtid 1 560 BEGIN GTID 0-1-2
mysqld-bin.000002 560 Annotate_rows 1 613 INSERT INTO t1 VALUES (1), (2)
mysqld-bin.000002 613 Table_map 1 658 table_id: # (test.t1)
mysqld-bin.000002 658 Write_rows_v1 1 696 table_id: # flags: STMT_END_F
mysqld-bin.000002 696 Table_map 1 741 table_id: # (test.t1)
mysqld-bin.000002 741 Write_rows_v1 1 779 table_id: # flags: STMT_END_F
mysqld-bin.000002 779 Xid 1 810 COMMIT /* xid=# */
mysqld-bin.000002 810 Gtid 1 852 BEGIN GTID 0-1-3
mysqld-bin.000002 852 Annotate_rows 1 905 INSERT INTO t1 VALUES (3), (4)
mysqld-bin.000002 905 Table_map 1 950 table_id: # (test.t1)
mysqld-bin.000002 950 Write_rows_v1 1 988 table_id: # flags: STMT_END_F
mysqld-bin.000002 988 Table_map 1 1033 table_id: # (test.t1)
mysqld-bin.000002 1033 Write_rows_v1 1 1071 table_id: # flags: STMT_END_F
mysqld-bin.000002 1071 Xid 1 1102 COMMIT /* xid=# */
mysqld-bin.000002 1102 Gtid 1 1144 BEGIN GTID 0-1-4
mysqld-bin.000002 1144 Annotate_rows 1 1197 INSERT INTO t1 VALUES (5), (6)
mysqld-bin.000002 1197 Table_map 1 1242 table_id: # (test.t1)
mysqld-bin.000002 1242 Write_rows_v1 1 1285 table_id: # flags: STMT_END_F
mysqld-bin.000002 1285 Xid 1 1316 COMMIT /* xid=# */
DROP TABLE t1;

View File

@ -0,0 +1,28 @@
connection node_2;
connection node_1;
SET SESSION wsrep_trx_fragment_size=1;
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
connection node_2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
connection node_1;
DROP TABLE t1;
connection node_2;
SHOW CREATE TABLE t1;
ERROR 42S02: Table 'test.t1' doesn't exist
CREATE DATABASE mdev_18587;
connection node_2;
SHOW DATABASES LIKE 'mdev_18587';
Database (mdev_18587)
mdev_18587
connection node_1;
DROP DATABASE mdev_18587;
connection node_2;
SHOW DATABASES LIKE 'mdev_18587';
Database (mdev_18587)
connection node_1;
SET SESSION wsrep_trx_fragment_size=DEFAULT;

View File

@ -1,3 +1,5 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
@ -9,16 +11,12 @@ START TRANSACTION;
Start of Simple Insert
INSERT INTO t1 VALUES (4);
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 73 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
BEGIN
/*!*/;
# at 193
<ISO TIMESTAMP> server id 1 end_log_pos 114 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 234
<ISO TIMESTAMP> server id 1 end_log_pos 150 Write_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 300
<ISO TIMESTAMP> server id 1 end_log_pos 85 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 341
<ISO TIMESTAMP> server id 1 end_log_pos 119 CRC32 0x00000004 Write_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
@ -29,34 +27,34 @@ ROLLBACK;
Start of Multi-row Update
UPDATE t1 SET f1 = f1 + 10;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 73 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
BEGIN
/*!*/;
# at 193
<ISO TIMESTAMP> server id 1 end_log_pos 114 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 234
<ISO TIMESTAMP> server id 1 end_log_pos 156 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 301
<ISO TIMESTAMP> server id 1 end_log_pos 86 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 342
<ISO TIMESTAMP> server id 1 end_log_pos 126 CRC32 0x0000000b Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 197 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 239 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 301
<ISO TIMESTAMP> server id 1 end_log_pos 212 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 342
<ISO TIMESTAMP> server id 1 end_log_pos 252 CRC32 0x0000000c Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 280 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 322 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 301
<ISO TIMESTAMP> server id 1 end_log_pos 338 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 342
<ISO TIMESTAMP> server id 1 end_log_pos 378 CRC32 0x0000000d Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
@ -67,73 +65,79 @@ ROLLBACK;
Start of Multi-table Update
UPDATE t1, t2 SET t1.f1 = t1.f1 + 100, t2.f1 = t2.f1 + 100;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 82 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
BEGIN
/*!*/;
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 123 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 243
<ISO TIMESTAMP> server id 1 end_log_pos 164 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 284
<ISO TIMESTAMP> server id 1 end_log_pos 206 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 118 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 159 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 199 CRC32 0x00000065 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 247 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 288 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 330 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 317 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 358 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 398 CRC32 0x00000066 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 371 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 412 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 454 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 516 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 557 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 597 CRC32 0x00000067 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 495 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 536 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 578 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 715 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 756 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 796 CRC32 0x00000065 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 619 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 660 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 702 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 914 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 955 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 995 CRC32 0x00000066 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 743 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 784 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 202
<ISO TIMESTAMP> server id 1 end_log_pos 826 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 333
<ISO TIMESTAMP> server id 1 end_log_pos 1113 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 374
<ISO TIMESTAMP> server id 1 end_log_pos 1154 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number <TABLE_ID>
# at 415
<ISO TIMESTAMP> server id 1 end_log_pos 1194 CRC32 0x00000067 Update_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
@ -147,47 +151,23 @@ SAVEPOINT X;
INSERT INTO t1 VALUES (2000);
ROLLBACK TO SAVEPOINT X;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 73 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
BEGIN
/*!*/;
# at 193
<ISO TIMESTAMP> server id 1 end_log_pos 114 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 234
<ISO TIMESTAMP> server id 1 end_log_pos 150 Write_rows: table id <TABLE_ID> flags: STMT_END_F
# at 256
# at 303
<ISO TIMESTAMP> server id 1 end_log_pos 88 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 344
<ISO TIMESTAMP> server id 1 end_log_pos 122 CRC32 0x000003e8 Write_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 231 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
SAVEPOINT `X`
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 272 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 161
<ISO TIMESTAMP> server id 1 end_log_pos 308 Write_rows: table id <TABLE_ID> flags: STMT_END_F
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DELIMITER /*!*/;
# at 120
<ISO TIMESTAMP> server id 1 end_log_pos 391 Query thread_id=<QUERY_THREAD_ID> exec_time=<EXEC_TIME> error_code=0
SET TIMESTAMP=<TIMESTAMP>/*!*/;
/*!\C latin1 *//*!*/;
ROLLBACK TO `X`
/*!*/;
# at 256
# at 303
<ISO TIMESTAMP> server id 1 end_log_pos 210 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number <TABLE_ID>
# at 344
<ISO TIMESTAMP> server id 1 end_log_pos 244 CRC32 0x000007d0 Write_rows: table id <TABLE_ID> flags: STMT_END_F
# Number of rows: 1
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;

View File

@ -29,7 +29,6 @@ mysqld-bin.000001 <Pos> Gtid 1 <End_log_pos> BEGIN GTID 0-1-2
mysqld-bin.000001 <Pos> Annotate_rows 1 <End_log_pos> INSERT INTO t1 VALUES (1),(2)
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
mysqld-bin.000001 <Pos> Write_rows_v1 1 <End_log_pos> table_id: ### flags: STMT_END_F
mysqld-bin.000001 <Pos> Annotate_rows 1 <End_log_pos> INSERT INTO t1 VALUES (1),(2)
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
mysqld-bin.000001 <Pos> Write_rows_v1 1 <End_log_pos> table_id: ### flags: STMT_END_F
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */
@ -52,7 +51,6 @@ mysqld-bin.000001 <Pos> Gtid 1 <End_log_pos> BEGIN GTID 0-1-2
mysqld-bin.000001 <Pos> Annotate_rows 1 <End_log_pos> INSERT INTO t1 VALUES (1),(2)
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
mysqld-bin.000001 <Pos> Write_rows_v1 1 <End_log_pos> table_id: ### flags: STMT_END_F
mysqld-bin.000001 <Pos> Annotate_rows 1 <End_log_pos> INSERT INTO t1 VALUES (1),(2)
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
mysqld-bin.000001 <Pos> Write_rows_v1 1 <End_log_pos> table_id: ### flags: STMT_END_F
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */

View File

@ -0,0 +1,5 @@
!include ../galera_2nodes.cnf
[mysqld.1]
log-bin
log-slave-updates

View File

@ -0,0 +1,42 @@
#
# MDEV-18686 Verify that the Annotate_rows_log_event is written only
# once per statement into binlog.
#
--source include/galera_cluster.inc
CREATE TABLE t1 (f1 INT PRIMARY KEY);
#
# Unit ROW
#
SET SESSION wsrep_trx_fragment_unit='ROWS';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (1), (2);
#
# Unit BYTE
#
SET SESSION wsrep_trx_fragment_unit='BYTES';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (3), (4);
#
# Unit STATEMENT
#
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
SET SESSION wsrep_trx_fragment_size=1;
INSERT INTO t1 VALUES (5), (6);
#
# Reset to default settings
#
SET SESSION wsrep_trx_fragment_unit=default;
SET SESSION wsrep_trx_fragment_size=default;
--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/
SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 518;
DROP TABLE t1;

View File

@ -0,0 +1,33 @@
#
# Verify that CREATE/DROP DDLs work when streaming replication is on.
#
--source include/galera_cluster.inc
SET SESSION wsrep_trx_fragment_size=1;
#
# CREATE/DROP TABLE succeeds and the change is propagated to node_2.
#
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
--connection node_2
SHOW CREATE TABLE t1;
--connection node_1
DROP TABLE t1;
--connection node_2
--error ER_NO_SUCH_TABLE
SHOW CREATE TABLE t1;
#
# CREATE/DROP DATABASE succeeds and the change is propagated to node_2.
#
CREATE DATABASE mdev_18587;
--connection node_2
SHOW DATABASES LIKE 'mdev_18587';
--connection node_1
DROP DATABASE mdev_18587;
--connection node_2
SHOW DATABASES LIKE 'mdev_18587';
--connection node_1
SET SESSION wsrep_trx_fragment_size=DEFAULT;

View File

@ -699,7 +699,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -754,7 +754,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -810,7 +810,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -874,7 +874,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)

View File

@ -1325,7 +1325,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -1381,7 +1381,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY,v_idx,v_idx2 PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -1439,7 +1439,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY,v_idx2 PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
@ -1506,7 +1506,7 @@ WHERE t4.c1 < 'o'
)
AND t1.i1 <= t3.i2_key;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)

View File

@ -741,8 +741,8 @@ CREATE TABLE t1 (f TINYINT, g SMALLINT UNSIGNED) ENGINE=InnoDB ROW_FORMAT=REDUND
INSERT INTO t1 VALUES(127,6502),(-128,33101);
ALTER TABLE t1 MODIFY f SMALLINT DEFAULT 12345,
MODIFY g BIGINT UNSIGNED DEFAULT 1234567;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
SELECT * FROM t1;
f g
127 6502
@ -779,10 +779,90 @@ DELETE FROM t1 LIMIT 3;
ALTER TABLE t1 MODIFY f BIT(15);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f BIT(8);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT HEX(f) FROM t1;
HEX(f)
80
DROP TABLE t1;
CREATE TABLE t1 (b BIT NOT NULL) ENGINE=InnoDB ROW_FORMAT=REDUNDANT DEFAULT CHARSET utf16;
INSERT INTO t1 SET b=b'1';
ALTER TABLE t1 CHANGE b c BIT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(10) NOT NULL DEFAULT 'scary') ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
INSERT INTO t1() VALUES();
ALTER TABLE t1 ADD f TINYINT NOT NULL DEFAULT -42;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f MEDIUMINT NOT NULL DEFAULT 64802,
MODIFY c VARCHAR(20) NOT NULL DEFAULT 'gory',
ADD d DATETIME;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
INSERT INTO t1() VALUES();
INSERT INTO t1 (c,f,d) VALUES ('fury', -8388608, now());
SELECT * FROM t1;
c f d
scary -42 NULL
gory 64802 NULL
fury -8388608 1970-01-01 03:00:42
DROP TABLE t1;
CREATE TABLE t1 (t TINYINT PRIMARY KEY, m MEDIUMINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
SELECT table_id INTO @table_id1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
INSERT INTO t1 VALUES (-42, -123456);
ALTER TABLE t1 CHANGE t s SMALLINT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
ALTER TABLE t1 CHANGE m i INT, ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
ALTER TABLE t1 CHANGE m i INT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id3 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
SELECT @table_id1 = @table_id2, @table_id2 = @table_id3;
@table_id1 = @table_id2 @table_id2 = @table_id3
0 0
INSERT IGNORE INTO t1 VALUES (0, -123456);
Warnings:
Warning 1062 Duplicate entry '-123456' for key 'm'
REPLACE INTO t1 VALUES(-42, 123456);
INSERT IGNORE INTO t1 VALUES(32768, 2147483648);
Warnings:
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 'i' at row 1
SELECT * FROM t1;
s i
-42 123456
32767 2147483647
DROP TABLE t1;
CREATE TABLE t1 (a SERIAL, b INT, c TINYINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
INSERT INTO t1 (c) VALUES(1),(2),(3);
ALTER TABLE t1 MODIFY c BIGINT;
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
UPDATE t1 SET b=1 WHERE c=2;
UPDATE t1 SET c=4 WHERE a=3;
UPDATE t1 SET b=2 WHERE c>3;
UPDATE t1 SET c=c+1;
ERROR 23000: Duplicate entry '2' for key 'c'
SELECT * FROM t1;
a b c
1 NULL 1
2 1 2
3 2 4
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
@ -1508,10 +1588,90 @@ DELETE FROM t1 LIMIT 3;
ALTER TABLE t1 MODIFY f BIT(15);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f BIT(8);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT HEX(f) FROM t1;
HEX(f)
80
DROP TABLE t1;
CREATE TABLE t1 (b BIT NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPACT DEFAULT CHARSET utf16;
INSERT INTO t1 SET b=b'1';
ALTER TABLE t1 CHANGE b c BIT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(10) NOT NULL DEFAULT 'scary') ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1() VALUES();
ALTER TABLE t1 ADD f TINYINT NOT NULL DEFAULT -42;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f MEDIUMINT NOT NULL DEFAULT 64802,
MODIFY c VARCHAR(20) NOT NULL DEFAULT 'gory',
ADD d DATETIME;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
INSERT INTO t1() VALUES();
INSERT INTO t1 (c,f,d) VALUES ('fury', -8388608, now());
SELECT * FROM t1;
c f d
scary -42 NULL
gory 64802 NULL
fury -8388608 1970-01-01 03:00:42
DROP TABLE t1;
CREATE TABLE t1 (t TINYINT PRIMARY KEY, m MEDIUMINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=COMPACT;
SELECT table_id INTO @table_id1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
INSERT INTO t1 VALUES (-42, -123456);
ALTER TABLE t1 CHANGE t s SMALLINT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
ALTER TABLE t1 CHANGE m i INT, ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
ALTER TABLE t1 CHANGE m i INT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id3 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
SELECT @table_id1 = @table_id2, @table_id2 = @table_id3;
@table_id1 = @table_id2 @table_id2 = @table_id3
0 0
INSERT IGNORE INTO t1 VALUES (0, -123456);
Warnings:
Warning 1062 Duplicate entry '-123456' for key 'm'
REPLACE INTO t1 VALUES(-42, 123456);
INSERT IGNORE INTO t1 VALUES(32768, 2147483648);
Warnings:
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 'i' at row 1
SELECT * FROM t1;
s i
-42 123456
32767 2147483647
DROP TABLE t1;
CREATE TABLE t1 (a SERIAL, b INT, c TINYINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 (c) VALUES(1),(2),(3);
ALTER TABLE t1 MODIFY c BIGINT;
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
UPDATE t1 SET b=1 WHERE c=2;
UPDATE t1 SET c=4 WHERE a=3;
UPDATE t1 SET b=2 WHERE c>3;
UPDATE t1 SET c=c+1;
ERROR 23000: Duplicate entry '2' for key 'c'
SELECT * FROM t1;
a b c
1 NULL 1
2 1 2
3 2 4
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
@ -2237,14 +2397,94 @@ DELETE FROM t1 LIMIT 3;
ALTER TABLE t1 MODIFY f BIT(15);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f BIT(8);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT HEX(f) FROM t1;
HEX(f)
80
DROP TABLE t1;
CREATE TABLE t1 (b BIT NOT NULL) ENGINE=InnoDB ROW_FORMAT=DYNAMIC DEFAULT CHARSET utf16;
INSERT INTO t1 SET b=b'1';
ALTER TABLE t1 CHANGE b c BIT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(10) NOT NULL DEFAULT 'scary') ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1() VALUES();
ALTER TABLE t1 ADD f TINYINT NOT NULL DEFAULT -42;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t1 MODIFY f MEDIUMINT NOT NULL DEFAULT 64802,
MODIFY c VARCHAR(20) NOT NULL DEFAULT 'gory',
ADD d DATETIME;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
INSERT INTO t1() VALUES();
INSERT INTO t1 (c,f,d) VALUES ('fury', -8388608, now());
SELECT * FROM t1;
c f d
scary -42 NULL
gory 64802 NULL
fury -8388608 1970-01-01 03:00:42
DROP TABLE t1;
CREATE TABLE t1 (t TINYINT PRIMARY KEY, m MEDIUMINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
SELECT table_id INTO @table_id1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
INSERT INTO t1 VALUES (-42, -123456);
ALTER TABLE t1 CHANGE t s SMALLINT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
ALTER TABLE t1 CHANGE m i INT, ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
ALTER TABLE t1 CHANGE m i INT;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT table_id INTO @table_id3 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
affected rows: 1
SELECT @table_id1 = @table_id2, @table_id2 = @table_id3;
@table_id1 = @table_id2 @table_id2 = @table_id3
0 0
INSERT IGNORE INTO t1 VALUES (0, -123456);
Warnings:
Warning 1062 Duplicate entry '-123456' for key 'm'
REPLACE INTO t1 VALUES(-42, 123456);
INSERT IGNORE INTO t1 VALUES(32768, 2147483648);
Warnings:
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 'i' at row 1
SELECT * FROM t1;
s i
-42 123456
32767 2147483647
DROP TABLE t1;
CREATE TABLE t1 (a SERIAL, b INT, c TINYINT UNIQUE) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1 (c) VALUES(1),(2),(3);
ALTER TABLE t1 MODIFY c BIGINT;
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
UPDATE t1 SET b=1 WHERE c=2;
UPDATE t1 SET c=4 WHERE a=3;
UPDATE t1 SET b=2 WHERE c>3;
UPDATE t1 SET c=c+1;
ERROR 23000: Duplicate entry '2' for key 'c'
SELECT * FROM t1;
a b c
1 NULL 1
2 1 2
3 2 4
DROP TABLE t1;
disconnect analyze;
SELECT variable_value-@old_instant instants
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
171
174
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;

View File

@ -1,23 +1,5 @@
--- instant_alter_charset.result
+++ instant_alter_charset,redundant.result
@@ -143,7 +143,7 @@
drop index ab,
add unique key ab(a,c),
algorithm=instant;
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
drop table key_part_change;
create table key_part_change_and_rename (
a char(100) charset ascii,
@@ -156,7 +156,7 @@
drop index ab,
add unique key ab(a,b),
algorithm=instant;
-ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
drop table key_part_change_and_rename;
create table enum_and_set (
a enum('one', 'two') charset utf8mb3,
@@ -254,7 +254,6 @@
alter table boundary_255
modify b varchar(200) charset utf8mb3,

View File

@ -668,10 +668,66 @@ ALTER TABLE t1 MODIFY f BIT(15);
DELETE FROM t1 LIMIT 3;
--enable_info
ALTER TABLE t1 MODIFY f BIT(15);
ALTER TABLE t1 MODIFY f BIT(8);
--disable_info
SELECT HEX(f) FROM t1;
DROP TABLE t1;
eval CREATE TABLE t1 (b BIT NOT NULL) $engine DEFAULT CHARSET utf16;
INSERT INTO t1 SET b=b'1';
--enable_info
ALTER TABLE t1 CHANGE b c BIT NOT NULL;
--disable_info
SELECT HEX(c) FROM t1;
DROP TABLE t1;
eval CREATE TABLE t1 (c VARCHAR(10) NOT NULL DEFAULT 'scary') $engine;
INSERT INTO t1() VALUES();
--enable_info
ALTER TABLE t1 ADD f TINYINT NOT NULL DEFAULT -42;
ALTER TABLE t1 MODIFY f MEDIUMINT NOT NULL DEFAULT 64802,
MODIFY c VARCHAR(20) NOT NULL DEFAULT 'gory',
ADD d DATETIME;
--disable_info
INSERT INTO t1() VALUES();
INSERT INTO t1 (c,f,d) VALUES ('fury', -8388608, now());
SELECT * FROM t1;
DROP TABLE t1;
eval CREATE TABLE t1 (t TINYINT PRIMARY KEY, m MEDIUMINT UNIQUE) $engine;
SELECT table_id INTO @table_id1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
INSERT INTO t1 VALUES (-42, -123456);
--enable_info
ALTER TABLE t1 CHANGE t s SMALLINT;
SELECT table_id INTO @table_id2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 CHANGE m i INT, ALGORITHM=INSTANT;
ALTER TABLE t1 CHANGE m i INT;
SELECT table_id INTO @table_id3 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t1';
--disable_info
SELECT @table_id1 = @table_id2, @table_id2 = @table_id3;
INSERT IGNORE INTO t1 VALUES (0, -123456);
REPLACE INTO t1 VALUES(-42, 123456);
INSERT IGNORE INTO t1 VALUES(32768, 2147483648);
SELECT * FROM t1;
DROP TABLE t1;
eval CREATE TABLE t1 (a SERIAL, b INT, c TINYINT UNIQUE) $engine;
INSERT INTO t1 (c) VALUES(1),(2),(3);
--enable_info
ALTER TABLE t1 MODIFY c BIGINT;
--disable_info
UPDATE t1 SET b=1 WHERE c=2;
UPDATE t1 SET c=4 WHERE a=3;
UPDATE t1 SET b=2 WHERE c>3;
--error ER_DUP_ENTRY
UPDATE t1 SET c=c+1;
SELECT * FROM t1;
DROP TABLE t1;
dec $format;
}
disconnect analyze;

View File

@ -1,8 +1,10 @@
--source include/have_innodb.inc
--source include/innodb_row_format.inc
--source include/maybe_debug.inc
-- echo #
-- echo # MDEV-15563: Instant ROW_FORMAT=REDUNDANT column type change&extension
-- echo # (reverted in MDEV-18627)
-- echo #
# Use character-set-server in test db
@ -10,8 +12,6 @@ create or replace database test;
use test;
set default_storage_engine=innodb;
set @save_format= @@GLOBAL.innodb_default_row_format;
SET GLOBAL innodb_default_row_format=redundant;
set @bigval= repeat('0123456789', 30);
delimiter ~~;
@ -45,7 +45,9 @@ set @save_debug= @@SESSION.debug_dbug;
set debug_dbug= '+d,ib_instant_error';
--enable_query_log
}
alter table t modify a char(200), algorithm=instant;
--enable_info
alter table t modify a char(200);
--disable_info
select count(a) from t where a = @bigval;
select a, length(a) from t where a = 'z';
@ -53,7 +55,9 @@ check table t extended;
call check_table('t');
--echo # CHAR enlargement
alter table t modify a char(220), algorithm=instant;
--enable_info
alter table t modify a char(220);
--disable_info
select count(a) from t where a = @bigval;
select a, length(a) from t where a = 'z';
@ -61,10 +65,10 @@ check table t extended;
call check_table('t');
--echo # Convert from VARCHAR to a bigger CHAR
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t modify a varchar(200), algorithm=instant;
alter table t modify a varchar(200), algorithm=copy;
alter table t modify a char(255), algorithm=instant;
--enable_info
alter table t modify a varchar(200);
alter table t modify a char(255);
--disable_info
select count(a) from t where a = @bigval;
select a, length(a) from t where a = 'z';
@ -74,14 +78,17 @@ call check_table('t');
--echo # BINARY/VARBINARY test
create or replace table t (a varbinary(300));
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t modify a binary(255), algorithm=instant;
alter table t modify a binary(255), algorithm=copy;
insert into t values(NULL);
--enable_info
alter table t modify a binary(255);
--disable_info
create or replace table t (a varbinary(200));
insert into t values (@bigval);
insert into t values ('z');
alter table t modify a binary(200), algorithm=instant;
--enable_info
alter table t modify a binary(200);
--disable_info
select count(a) from t where a = @bigval;
select length(a) from t where left(a, 1) = 'z';
@ -89,16 +96,18 @@ check table t extended;
call check_table('t');
--echo # BINARY enlargement
alter table t modify a binary(220), algorithm=instant;
--enable_info
alter table t modify a binary(220);
--disable_info
check table t extended;
call check_table('t');
--echo # Convert from VARBINARY to a bigger BINARY
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t modify a varbinary(220), algorithm=instant;
alter table t modify a varbinary(220), algorithm=copy;
alter table t modify a binary(255), algorithm=instant;
--enable_info
alter table t modify a varbinary(220);
alter table t modify a binary(255);
--disable_info
select count(a) from t where a = @bigval;
select a, length(a) from t where a = 'z';
@ -110,25 +119,33 @@ call check_table('t');
--echo # Integer conversions
create or replace table t (x tinyint);
insert into t values (127);
alter table t modify x smallint, algorithm=instant;
--enable_info
alter table t modify x smallint;
--disable_info
select * from t;
check table t extended;
call check_table('t');
update t set x= 32767;
alter table t modify x mediumint, algorithm=instant;
--enable_info
alter table t modify x mediumint;
--disable_info
select * from t;
check table t extended;
call check_table('t');
update t set x= 8388607;
alter table t modify x int, algorithm=instant;
--enable_info
alter table t modify x int;
--disable_info
select * from t;
check table t extended;
call check_table('t');
update t set x= 2147483647;
alter table t modify x bigint, algorithm=instant;
--enable_info
alter table t modify x bigint;
--disable_info
select * from t;
check table t extended;
call check_table('t');
@ -163,13 +180,19 @@ call check_table('t2');
create or replace table t1 (x mediumint);
insert into t1 values (1);
insert into t1 values (1);
alter table t1 add column y int first, modify x int, algorithm instant;
--enable_info
alter table t1 add column y int first, modify x int;
--error ER_DUP_ENTRY
alter table t1 add column z int first, add primary key (x);
--disable_info
--echo # Check assertion in wrong instant operation
create or replace table t1 (a varchar(26) not null) default character set utf8mb4;
alter table t1 modify a varchar(25) not null;
insert into t1 values ('abcdef'), (repeat('x',26));
--enable_info
alter ignore table t1 modify a varchar(25) not null;
--disable_info
select * from t1;
--echo # Check row_mysql_store_col_in_innobase_format()
create or replace table t1(x int primary key, a varchar(20));
@ -181,30 +204,46 @@ update t1 set a= 'foo' where x = 2;
--echo #
create or replace table t1 (x int, y int);
insert into t1 (x, y) values (11, 22);
alter table t1 modify x bigint, algorithm instant;
alter table t1 add primary key (x), algorithm inplace;
--enable_info
alter table t1 modify x bigint;
alter table t1 add primary key (x);
--disable_info
select * from t1;
check table t1;
create or replace table t1 (a varchar(10), y int);
insert into t1 (a, y) values ("0123456789", 33);
alter table t1 modify a char(15), algorithm instant;
alter table t1 add primary key (a), algorithm inplace;
--enable_info
alter table t1 modify a char(15);
alter table t1 add primary key (a);
--disable_info
select * from t1;
check table t1;
create or replace table t1 (x int primary key, y int);
insert into t1 (x, y) values (44, 55);
alter table t1 modify x bigint, algorithm inplace;
--enable_info
alter table t1 modify x bigint;
--disable_info
select * from t1;
check table t1;
create or replace table t1 (x int primary key, y int);
insert into t1 values (66, 77);
alter table t1 add column z int, algorithm instant;
alter table t1 drop column y, algorithm instant;
--enable_info
alter table t1 add column z int;
alter table t1 drop column y;
--disable_info
select * from t1;
check table t1;
create or replace table t1 (x integer, a varchar(20));
alter table t1 add index idx3 (a);
--enable_info
insert into t1 (x, a) values (73, 'a');
alter table t1 add index idx3 (a);
alter table t1 modify a char(20);
--disable_info
select * from t1;
check table t1;
create or replace database test charset latin1;
SET GLOBAL innodb_default_row_format=@save_format;

View File

@ -1,20 +1,20 @@
SET @start_global_value = @@global.histogram_size;
SELECT @start_global_value;
@start_global_value
0
254
SET @start_session_value = @@session.histogram_size;
SELECT @start_session_value;
@start_session_value
0
254
'#--------------------FN_DYNVARS_053_01-------------------------#'
SET @@global.histogram_size = DEFAULT;
SELECT @@global.histogram_size;
@@global.histogram_size
0
254
SET @@session.histogram_size = DEFAULT;
SELECT @@session.histogram_size;
@@session.histogram_size
0
254
'#--------------------FN_DYNVARS_053_03-------------------------#'
SET @@global.histogram_size = 1;
SELECT @@global.histogram_size;
@ -129,8 +129,8 @@ SELECT @@local.histogram_size = @@session.histogram_size;
SET @@global.histogram_size = @start_global_value;
SELECT @@global.histogram_size;
@@global.histogram_size
0
254
SET @@session.histogram_size = @start_session_value;
SELECT @@session.histogram_size;
@@session.histogram_size
0
254

View File

@ -1,16 +1,16 @@
SET @start_global_value = @@global.histogram_type;
SELECT @start_global_value;
@start_global_value
SINGLE_PREC_HB
DOUBLE_PREC_HB
SET @start_session_value = @@session.histogram_type;
SELECT @start_session_value;
@start_session_value
SINGLE_PREC_HB
DOUBLE_PREC_HB
SET @@global.histogram_type = 1;
SET @@global.histogram_type = DEFAULT;
SELECT @@global.histogram_type;
@@global.histogram_type
SINGLE_PREC_HB
DOUBLE_PREC_HB
SET @@global.histogram_type = 0;
SELECT @@global.histogram_type;
@@global.histogram_type
@ -71,9 +71,9 @@ HISTOGRAM_TYPE DOUBLE_PREC_HB
SET @@global.histogram_type = @start_global_value;
SELECT @@global.histogram_type;
@@global.histogram_type
SINGLE_PREC_HB
DOUBLE_PREC_HB
SET @@session.histogram_type = @start_session_value;
SELECT @@session.histogram_type;
@@session.histogram_type
SINGLE_PREC_HB
DOUBLE_PREC_HB
set sql_mode='';

View File

@ -1287,10 +1287,10 @@ ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HISTOGRAM_SIZE
SESSION_VALUE 0
GLOBAL_VALUE 0
SESSION_VALUE 254
GLOBAL_VALUE 254
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
DEFAULT_VALUE 254
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Number of bytes used for a histogram. If set to 0, no histograms are created by ANALYZE.
@ -1301,10 +1301,10 @@ ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME HISTOGRAM_TYPE
SESSION_VALUE SINGLE_PREC_HB
GLOBAL_VALUE SINGLE_PREC_HB
SESSION_VALUE DOUBLE_PREC_HB
GLOBAL_VALUE DOUBLE_PREC_HB
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE SINGLE_PREC_HB
DEFAULT_VALUE DOUBLE_PREC_HB
VARIABLE_SCOPE SESSION
VARIABLE_TYPE ENUM
VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced.

View File

@ -1427,10 +1427,10 @@ ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME HISTOGRAM_SIZE
SESSION_VALUE 0
GLOBAL_VALUE 0
SESSION_VALUE 254
GLOBAL_VALUE 254
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
DEFAULT_VALUE 254
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Number of bytes used for a histogram. If set to 0, no histograms are created by ANALYZE.
@ -1441,10 +1441,10 @@ ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME HISTOGRAM_TYPE
SESSION_VALUE SINGLE_PREC_HB
GLOBAL_VALUE SINGLE_PREC_HB
SESSION_VALUE DOUBLE_PREC_HB
GLOBAL_VALUE DOUBLE_PREC_HB
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE SINGLE_PREC_HB
DEFAULT_VALUE DOUBLE_PREC_HB
VARIABLE_SCOPE SESSION
VARIABLE_TYPE ENUM
VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible values are: SINGLE_PREC_HB - single precision height-balanced, DOUBLE_PREC_HB - double precision height-balanced.

View File

@ -1,176 +1,14 @@
# We build parts of AWS C++ SDK as CMake external project
# The restrictions of the SDK (https://github.com/awslabs/aws-sdk-cpp/blob/master/README.md)
# are
# - OS : Windows,Linux or OSX
# - C++11 compiler : VS2013+, gcc 4.8+, clang 3.3+
# - libcurl development package needs to be present on Unixes
#
# If we build SDK outselves, we'll need require GIT to be present on the build machine
# Give message why the building this plugin is skipped (only if -DVERBOSE is defined)
# or if plugin is explicitly requested to build. Then bail out.
MACRO(SKIP_AWS_PLUGIN msg)
MESSAGE_ONCE(SKIP_AWS_PLUGIN "Skip aws_key_management - ${msg}")
INCLUDE(aws_sdk)
CHECK_AWS_SDK(HAVE_AWS_SDK REASON)
IF(NOT HAVE_AWS_SDK)
MESSAGE_ONCE(AWS_KEY_MANAGEMENT_NO_AWS_SDK "Can't build aws_key_management - AWS SDK not available (${REASON})")
RETURN()
ENDMACRO()
SET(CMAKE_CXX_STANDARD 11)
# This plugin needs recent C++ compilers (AWS C++ SDK header files are using C++11 features)
SET(CXX11_FLAGS)
SET(OLD_COMPILER_MSG "AWS SDK requires c++11 -capable compiler (minimal supported versions are g++ 4.8, clang 3.3, VS2103)")
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
IF (GCC_VERSION VERSION_LESS 4.8)
SKIP_AWS_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
SET(CXX11_FLAGS "-std=c++11")
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
IF ((CMAKE_CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) OR
(CLANG_VERSION_STRING AND CLANG_VERSION_STRING VERSION_LESS 3.3))
SKIP_AWS_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
SET(CXX11_FLAGS "-stdlib=libc++")
ELSEIF(MSVC)
IF (MSVC_VERSION LESS 1800)
SKIP_AWS_PLUGIN("${OLD_COMPILER_MSG}")
ENDIF()
ELSE()
SKIP_AWS_PLUGIN("Compiler not supported by AWS C++ SDK")
ENDIF()
IF (NOT(WIN32 OR APPLE OR (CMAKE_SYSTEM_NAME MATCHES "Linux")))
SKIP_AWS_PLUGIN("OS unsupported by AWS SDK")
ENDIF()
FIND_LIBRARY(AWS_CPP_SDK_CORE NAMES aws-cpp-sdk-core PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
FIND_LIBRARY(AWS_CPP_SDK_KMS NAMES aws-cpp-sdk-kms PATH_SUFFIXES "${SDK_INSTALL_BINARY_PREFIX}")
FIND_PATH(AWS_CPP_SDK_INCLUDE_DIR NAMES aws/kms/KMSClient.h)
IF(AWS_CPP_SDK_CORE AND AWS_CPP_SDK_KMS AND AWS_CPP_SDK_INCLUDE_DIR)
# AWS C++ SDK installed
INCLUDE_DIRECTORIES(${AWS_CPP_SDK_INCLUDE_DIR})
SET(AWS_SDK_LIBS ${AWS_CPP_SDK_CORE} ${AWS_CPP_SDK_KMS})
ELSE()
OPTION(AWS_SDK_EXTERNAL_PROJECT "Allow download and build AWS C++ SDK" OFF)
IF(NOT AWS_SDK_EXTERNAL_PROJECT)
SKIP_AWS_PLUGIN("AWS_SDK_EXTERNAL_PROJECT is not set")
ENDIF()
# Build from source, using ExternalProject_Add
# AWS C++ SDK requires cmake 2.8.12
IF(CMAKE_VERSION VERSION_LESS "2.8.12")
SKIP_AWS_PLUGIN("CMake is too old")
ENDIF()
FIND_PACKAGE(Git)
IF(NOT GIT_FOUND)
SKIP_AWS_PLUGIN("no GIT")
ENDIF()
INCLUDE(ExternalProject)
IF(UNIX)
FIND_PACKAGE(CURL)
IF(NOT CURL_FOUND)
SKIP_AWS_PLUGIN("AWS C++ SDK requires libcurl development package")
ENDIF()
SET(PIC_FLAG -fPIC)
FIND_PATH(UUID_INCLUDE_DIR uuid/uuid.h)
IF(NOT UUID_INCLUDE_DIR)
SKIP_AWS_PLUGIN("AWS C++ SDK requires uuid development package")
ENDIF()
IF(NOT APPLE)
FIND_LIBRARY(UUID_LIBRARIES uuid)
IF(NOT UUID_LIBRARIES)
SKIP_AWS_PLUGIN("AWS C++ SDK requires uuid development package")
ENDIF()
FIND_PACKAGE(OpenSSL)
IF(NOT OPENSSL_FOUND)
SKIP_AWS_PLUGIN("AWS C++ SDK requires openssl development package")
ENDIF()
ENDIF()
ENDIF()
IF(MSVC)
SET(EXTRA_SDK_CMAKE_FLAGS -DCMAKE_CXX_FLAGS_DEBUGOPT="" -DCMAKE_EXE_LINKER_FLAGS_DEBUGOPT="" "-DCMAKE_CXX_FLAGS=/wd4530 /wd4577 /WX-")
ENDIF()
IF(CMAKE_CXX_COMPILER)
SET(EXTRA_SDK_CMAKE_FLAGS ${EXTRA_SDK_CMAKE_FLAGS} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
ENDIF()
SET(byproducts )
# We do not need to build the whole SDK , just 2 of its libs
set(AWS_SDK_LIBS aws-cpp-sdk-core aws-cpp-sdk-kms)
FOREACH(lib ${AWS_SDK_LIBS})
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
ADD_DEPENDENCIES(${lib} aws_sdk_cpp)
SET(loc "${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
IF(CMAKE_VERSION VERSION_GREATER "3.1")
SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${loc})
ENDIF()
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${loc})
ENDFOREACH()
# To be compatible with older cmake, we use older version of the SDK
IF(CMAKE_VERSION LESS "3.0")
SET(GIT_TAG "1.0.8")
ELSE()
SET(GIT_TAG "1.2.11")
ENDIF()
IF(MSVC_CRT_TYPE MATCHES "/MD")
SET(FORCE_SHARED_CRT ON)
ELSE()
SET(FORCE_SHARED_CRT OFF)
ENDIF()
SET(AWS_SDK_PATCH_COMMAND )
ExternalProject_Add(
aws_sdk_cpp
GIT_REPOSITORY "https://github.com/awslabs/aws-sdk-cpp.git"
GIT_TAG ${GIT_TAG}
UPDATE_COMMAND ""
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/aws-sdk-cpp"
${byproducts}
CMAKE_ARGS
-DBUILD_ONLY=kms
-DBUILD_SHARED_LIBS=OFF
-DFORCE_SHARED_CRT=${FORCE_SHARED_CRT}
-DENABLE_TESTING=OFF
"-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} ${PIC_FLAG}"
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL} ${PIC_FLAG}"
${EXTRA_SDK_CMAKE_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp
-DCMAKE_INSTALL_LIBDIR=lib
TEST_COMMAND ""
)
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# Need whole-archive , otherwise static libraries are not linked
SET(AWS_SDK_LIBS -Wl,--whole-archive ${AWS_SDK_LIBS} -Wl,--no-whole-archive)
ENDIF()
SET_TARGET_PROPERTIES(aws_sdk_cpp PROPERTIES EXCLUDE_FROM_ALL TRUE)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/aws_sdk_cpp/include)
ENDIF()
ADD_DEFINITIONS(${SSL_DEFINES}) # Need to know whether openssl should be initialized
IF(CMAKE_VERSION GREATER "3.0")
SET(CMAKE_CXX_STANDARD 11)
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}")
ENDIF()
IF(WIN32)
SET(AWS_CPP_SDK_DEPENDENCIES bcrypt winhttp wininet userenv version)
ELSE()
SET(AWS_CPP_SDK_DEPENDENCIES ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES})
ENDIF()
MYSQL_ADD_PLUGIN(aws_key_management aws_key_management_plugin.cc
LINK_LIBRARIES ${AWS_SDK_LIBS} ${AWS_CPP_SDK_DEPENDENCIES}
COMPONENT aws-key-management)
MYSQL_ADD_PLUGIN(aws_key_management
aws_key_management_plugin.cc
COMPONENT aws-key-management)
IF(TARGET aws_key_management)
USE_AWS_SDK_LIBS(aws_key_management kms)
ENDIF()

View File

@ -7084,9 +7084,6 @@ uint Field_str::is_equal(Create_field *new_field)
return new_field->charset == field_charset
? IS_EQUAL_YES : IS_EQUAL_PACK_LENGTH;
if (table->file->ha_table_flags() & HA_EXTENDED_TYPES_CONVERSION)
return IS_EQUAL_PACK_LENGTH_EXT;
return IS_EQUAL_NO;
}
@ -7947,11 +7944,6 @@ uint Field_varstring::is_equal(Create_field *new_field)
(table->file->ha_table_flags() & HA_EXTENDED_TYPES_CONVERSION))
return IS_EQUAL_PACK_LENGTH; // VARCHAR, longer length
}
else if (new_type_handler == &type_handler_string) // converting to CHAR
{
if (table->file->ha_table_flags() & HA_EXTENDED_TYPES_CONVERSION)
return IS_EQUAL_PACK_LENGTH_EXT;
}
return IS_EQUAL_NO;
}
@ -9568,22 +9560,6 @@ uint Field_num::is_equal(Create_field *new_field)
format for integers, we can only return IS_EQUAL_YES for the TINYINT
conversion. */
if (table->file->ha_table_flags() & HA_EXTENDED_TYPES_CONVERSION)
{
/* For now, prohibit instant conversion between BIT and integers.
Note: pack_length(), which is compared below, is measured in
bytes, and for BIT the last byte may be partially occupied. We
must not allow instant conversion to BIT such that the last byte
is partially occupied.
We could allow converting TINYINT UNSIGNED to BIT(8) or wider. */
if (th != new_th &&
(th == &type_handler_bit || new_th == &type_handler_bit))
return IS_EQUAL_NO;
if (th->result_type() == new_th->result_type() &&
new_field->pack_length >= pack_length())
return IS_EQUAL_PACK_LENGTH_EXT;
}
return IS_EQUAL_NO;
}

View File

@ -6256,7 +6256,9 @@ static int write_locked_table_maps(THD *thd)
MYSQL_LOCK *locks[2];
locks[0]= thd->extra_lock;
locks[1]= thd->lock;
my_bool with_annotate= thd->variables.binlog_annotate_row_events &&
my_bool with_annotate= IF_WSREP(!wsrep_fragments_certified_for_stmt(thd),
true) &&
thd->variables.binlog_annotate_row_events &&
thd->query() && thd->query_length();
for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i )

View File

@ -751,14 +751,6 @@ typedef ulonglong alter_table_operations;
*/
#define ALTER_COLUMN_INDEX_LENGTH (1ULL << 60)
/**
Change the column length or type such that no rebuild is needed.
Only set if ALTER_COLUMN_EQUAL_PACK_LENGTH does not apply, and
if HA_EXTENDED_TYPES_CONVERSION holds.
@see IS_EQUAL_PACK_LENGTH_EXT
*/
#define ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT (1ULL << 61)
/*
Flags set in partition_flags when altering partitions
*/

View File

@ -219,15 +219,15 @@ void Json_writer::add_str(const String &str)
add_str(str.ptr(), str.length());
}
Json_writer_object::Json_writer_object(THD *thd) :
Json_writer_object::Json_writer_object(THD *thd) :
Json_writer_struct(thd)
{
if (my_writer)
my_writer->start_object();
}
Json_writer_object::Json_writer_object(THD* thd, const char *str)
: Json_writer_struct(thd)
Json_writer_object::Json_writer_object(THD* thd, const char *str) :
Json_writer_struct(thd)
{
if (my_writer)
my_writer->add_member(str).start_object();
@ -247,8 +247,8 @@ Json_writer_array::Json_writer_array(THD *thd) :
my_writer->start_array();
}
Json_writer_array::Json_writer_array(THD *thd, const char *str)
:Json_writer_struct(thd)
Json_writer_array::Json_writer_array(THD *thd, const char *str) :
Json_writer_struct(thd)
{
if (my_writer)
my_writer->add_member(str).start_array();
@ -263,6 +263,16 @@ Json_writer_array::~Json_writer_array()
}
}
Json_writer_temp_disable::Json_writer_temp_disable(THD *thd_arg)
{
thd= thd_arg;
thd->opt_trace.disable_tracing_if_required();
}
Json_writer_temp_disable::~Json_writer_temp_disable()
{
thd->opt_trace.enable_tracing_if_required();
}
bool Single_line_formatting_helper::on_add_member(const char *name)
{
DBUG_ASSERT(state== INACTIVE || state == DISABLED);

View File

@ -215,12 +215,11 @@ public:
*/
void set_size_limit(size_t mem_size) { output.set_size_limit(mem_size); }
// psergey: return how many bytes would be required to store everything
size_t get_truncated_bytes() { return output.get_truncated_bytes(); }
Json_writer() :
indent_level(0), document_start(true), element_started(false),
first_child(true), allowed_mem_size(0)
first_child(true)
{
fmt_helper.init(this);
}
@ -235,12 +234,6 @@ private:
bool element_started;
bool first_child;
/*
True when we are using the optimizer trace
FALSE otherwise
*/
size_t allowed_mem_size;
Single_line_formatting_helper fmt_helper;
void append_indent();
@ -566,6 +559,17 @@ public:
~Json_writer_array();
};
/*
RAII-based class to disable writing into the JSON document
*/
class Json_writer_temp_disable
{
public:
Json_writer_temp_disable(THD *thd_arg);
~Json_writer_temp_disable();
THD *thd;
};
/*
RAII-based helper class to detect incorrect use of Json_writer.

View File

@ -675,7 +675,7 @@ int SEL_IMERGE::or_sel_tree_with_checks(RANGE_OPT_PARAM *param,
{
bool was_ored= FALSE;
*is_last_check_pass= is_first_check_pass;
SEL_TREE** or_tree = trees;
SEL_TREE** or_tree= trees;
for (uint i= 0; i < n_trees; i++, or_tree++)
{
SEL_TREE *result= 0;
@ -872,7 +872,7 @@ SEL_IMERGE::SEL_IMERGE(SEL_IMERGE *arg, uint cnt,
trees_next= trees + (cnt ? cnt : arg->trees_next-arg->trees);
trees_end= trees + elements;
for (SEL_TREE **tree = trees, **arg_tree= arg->trees; tree < trees_next;
for (SEL_TREE **tree= trees, **arg_tree= arg->trees; tree < trees_next;
tree++, arg_tree++)
{
if (!(*tree= new SEL_TREE(*arg_tree, TRUE, param)))
@ -2211,7 +2211,7 @@ public:
@param trace_object The optimizer trace object the info is appended to
*/
virtual void trace_basic_info(const PARAM *param,
Json_writer_object *trace_object) const = 0;
Json_writer_object *trace_object) const= 0;
};
@ -2261,10 +2261,10 @@ void TRP_RANGE::trace_basic_info(const PARAM *param,
Json_writer_object *trace_object) const
{
DBUG_ASSERT(param->using_real_indexes);
const uint keynr_in_table = param->real_keynr[key_idx];
const uint keynr_in_table= param->real_keynr[key_idx];
const KEY &cur_key = param->table->key_info[keynr_in_table];
const KEY_PART_INFO *key_part = cur_key.key_part;
const KEY &cur_key= param->table->key_info[keynr_in_table];
const KEY_PART_INFO *key_part= cur_key.key_part;
trace_object->add("type", "range_scan")
.add("index", cur_key.name)
@ -2329,7 +2329,7 @@ void TRP_ROR_UNION::trace_basic_info(const PARAM *param,
THD *thd= param->thd;
trace_object->add("type", "index_roworder_union");
Json_writer_array smth_trace(thd, "union_of");
for (TABLE_READ_PLAN **current = first_ror; current != last_ror; current++)
for (TABLE_READ_PLAN **current= first_ror; current != last_ror; current++)
{
Json_writer_object trp_info(thd);
(*current)->trace_basic_info(param, &trp_info);
@ -2364,7 +2364,7 @@ void TRP_INDEX_INTERSECT::trace_basic_info(const PARAM *param,
THD *thd= param->thd;
trace_object->add("type", "index_sort_intersect");
Json_writer_array smth_trace(thd, "index_sort_intersect_of");
for (TRP_RANGE **current = range_scans; current != range_scans_end;
for (TRP_RANGE **current= range_scans; current != range_scans_end;
current++)
{
Json_writer_object trp_info(thd);
@ -2466,9 +2466,9 @@ void TRP_GROUP_MIN_MAX::trace_basic_info(const PARAM *param,
trace_object->add("type", "index_group").add("index", index_info->name);
if (min_max_arg_part)
trace_object->add("group_attribute", min_max_arg_part->field->field_name);
trace_object->add("min_max_arg", min_max_arg_part->field->field_name);
else
trace_object->add_null("group_attribute");
trace_object->add_null("min_max_arg");
trace_object->add("min_aggregate", have_min)
.add("max_aggregate", have_max)
@ -2476,12 +2476,12 @@ void TRP_GROUP_MIN_MAX::trace_basic_info(const PARAM *param,
.add("rows", records)
.add("cost", read_cost);
const KEY_PART_INFO *key_part = index_info->key_part;
const KEY_PART_INFO *key_part= index_info->key_part;
{
Json_writer_array trace_keyparts(thd, "key_parts_used_for_access");
for (uint partno = 0; partno < used_key_parts; partno++)
for (uint partno= 0; partno < used_key_parts; partno++)
{
const KEY_PART_INFO *cur_key_part = key_part + partno;
const KEY_PART_INFO *cur_key_part= key_part + partno;
trace_keyparts.add(cur_key_part->field->field_name);
}
}
@ -3438,7 +3438,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
{
rows= 0;
table->reginfo.impossible_range= 1;
selectivity_for_column.add("selectivity_from_histograms", rows);
selectivity_for_column.add("selectivity_from_histogram", rows);
selectivity_for_column.add("cause", "impossible range");
goto free_alloc;
}
@ -3448,7 +3448,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
if (rows != DBL_MAX)
{
key->field->cond_selectivity= rows/table_records;
selectivity_for_column.add("selectivity_from_histograms",
selectivity_for_column.add("selectivity_from_histogram",
key->field->cond_selectivity);
}
}
@ -3472,6 +3472,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
free_root(&alloc, MYF(0));
}
selectivity_for_columns.end();
if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE))
@ -3546,7 +3547,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
table->cond_selectivity_sampling_explain= &dt->list;
}
}
trace_wrapper.add("cond_selectivity", table->cond_selectivity);
DBUG_RETURN(FALSE);
}
@ -5073,7 +5074,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
trace_idx.add("chosen", false).add("cause", "cost");
continue;
}
const uint keynr_in_table = param->real_keynr[(*cur_child)->key_idx];
const uint keynr_in_table= param->real_keynr[(*cur_child)->key_idx];
imerge_cost += (*cur_child)->read_cost;
all_scans_ror_able &= ((*ptree)->n_ror_scans > 0);
all_scans_rors &= (*cur_child)->is_ror;
@ -5134,7 +5135,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
*/
double rid_comp_cost= static_cast<double>(non_cpk_scan_records) /
TIME_FOR_COMPARE_ROWID;
imerge_cost += rid_comp_cost;
imerge_cost+= rid_comp_cost;
trace_best_disjunct.add("cost_of_mapping_rowid_in_non_clustered_pk_scan",
rid_comp_cost);
}
@ -5142,7 +5143,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
/* Calculate cost(rowid_to_row_scan) */
{
double sweep_cost= get_sweep_read_cost(param, non_cpk_scan_records);
imerge_cost += sweep_cost;
imerge_cost+= sweep_cost;
trace_best_disjunct.add("cost_sort_rowid_and_read_disk", sweep_cost);
}
DBUG_PRINT("info",("index_merge cost with rowid-to-row scan: %g",
@ -5169,7 +5170,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
}
{
const double dup_removal_cost = Unique::get_use_cost(
const double dup_removal_cost= Unique::get_use_cost(
param->imerge_cost_buff, (uint)non_cpk_scan_records,
param->table->file->ref_length,
(size_t)param->thd->variables.sortbuff_size,
@ -6371,11 +6372,11 @@ void TRP_ROR_INTERSECT::trace_basic_info(const PARAM *param,
trace_object->add("clustered_pk_scan", cpk_scan != NULL);
Json_writer_array smth_trace(thd, "intersect_of");
for (ROR_SCAN_INFO **cur_scan = first_scan; cur_scan != last_scan;
for (ROR_SCAN_INFO **cur_scan= first_scan; cur_scan != last_scan;
cur_scan++)
{
const KEY &cur_key = param->table->key_info[(*cur_scan)->keynr];
const KEY_PART_INFO *key_part = cur_key.key_part;
const KEY &cur_key= param->table->key_info[(*cur_scan)->keynr];
const KEY_PART_INFO *key_part= cur_key.key_part;
Json_writer_object trace_isect_idx(thd);
trace_isect_idx.add("type", "range_scan");
@ -6383,15 +6384,15 @@ void TRP_ROR_INTERSECT::trace_basic_info(const PARAM *param,
trace_isect_idx.add("rows", (*cur_scan)->records);
Json_writer_array trace_range(thd, "ranges");
for (const SEL_ARG *current = (*cur_scan)->sel_arg->first(); current;
current = current->next)
for (const SEL_ARG *current= (*cur_scan)->sel_arg->first(); current;
current= current->next)
{
String range_info;
range_info.set_charset(system_charset_info);
for (const SEL_ARG *part = current; part;
part = part->next_key_part ? part->next_key_part : nullptr)
for (const SEL_ARG *part= current; part;
part= part->next_key_part ? part->next_key_part : nullptr)
{
const KEY_PART_INFO *cur_key_part = key_part + part->part;
const KEY_PART_INFO *cur_key_part= key_part + part->part;
append_range(&range_info, cur_key_part, part->min_value,
part->max_value, part->min_flag | part->max_flag);
}
@ -6816,7 +6817,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
*/
const double idx_cost= rows2double(info->index_records) /
TIME_FOR_COMPARE_ROWID;
info->index_scan_costs += idx_cost;
info->index_scan_costs+= idx_cost;
trace_costs->add("index_scan_cost", idx_cost);
}
else
@ -6840,7 +6841,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
{
double sweep_cost= get_sweep_read_cost(info->param,
double2rows(info->out_rows));
info->total_cost += sweep_cost;
info->total_cost+= sweep_cost;
trace_costs->add("disk_sweep_cost", sweep_cost);
DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost));
}
@ -7371,8 +7372,8 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
{
Json_writer_array trace_range(thd, "ranges");
const KEY &cur_key = param->table->key_info[keynr];
const KEY_PART_INFO *key_part = cur_key.key_part;
const KEY &cur_key= param->table->key_info[keynr];
const KEY_PART_INFO *key_part= cur_key.key_part;
String range_info;
range_info.set_charset(system_charset_info);
@ -13384,7 +13385,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
key_part_nr= get_field_keypart(cur_index_info, min_max_arg_item->field);
if (key_part_nr <= cur_group_key_parts)
{
cause = "aggregate column not suffix in idx";
cause= "aggregate column not suffix in idx";
goto next_index;
}
min_max_arg_part= cur_index_info->key_part + key_part_nr - 1;
@ -13438,7 +13439,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
&cur_key_infix_len,
&first_non_infix_part))
{
cause = "nonconst equality gap attribute";
cause= "nonconst equality gap attribute";
goto next_index;
}
}
@ -13449,7 +13450,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
There is a gap but no range tree, thus no predicates at all for the
non-group keyparts.
*/
cause = "no nongroup keypart predicate";
cause= "no nongroup keypart predicate";
goto next_index;
}
else if (first_non_group_part && join->conds)
@ -13474,7 +13475,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
if (join->conds->walk(&Item::find_item_in_field_list_processor, 0,
key_part_range))
{
cause = "keypart reference from where clause";
cause= "keypart reference from where clause";
goto next_index;
}
}
@ -13492,7 +13493,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
{
if (bitmap_is_set(table->read_set, cur_part->field->field_index))
{
cause = "keypart after infix in query";
cause= "keypart after infix in query";
goto next_index;
}
}
@ -13511,7 +13512,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
index_range_tree, &cur_range) ||
(cur_range && cur_range->type != SEL_ARG::KEY_RANGE))
{
cause = "minmax keypart in disjunctive query";
cause= "minmax keypart in disjunctive query";
goto next_index;
}
}
@ -13538,7 +13539,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
{
Json_writer_array trace_range(thd, "ranges");
const KEY_PART_INFO *key_part = cur_index_info->key_part;
const KEY_PART_INFO *key_part= cur_index_info->key_part;
String range_info;
range_info.set_charset(system_charset_info);
@ -13578,7 +13579,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
if (cause)
{
trace_idx.add("usable", false).add("cause", cause);
cause = NULL;
cause= NULL;
}
}
@ -15776,9 +15777,9 @@ static void append_range_all_keyparts(Json_writer_array *range_trace,
DBUG_ASSERT(keypart && keypart != &null_element);
// Navigate to first interval in red-black tree
const KEY_PART_INFO *cur_key_part = key_parts + keypart->part;
const SEL_ARG *keypart_range = keypart->first();
const size_t save_range_so_far_length = range_so_far->length();
const KEY_PART_INFO *cur_key_part= key_parts + keypart->part;
const SEL_ARG *keypart_range= keypart->first();
const size_t save_range_so_far_length= range_so_far->length();
while (keypart_range)
@ -15827,9 +15828,10 @@ static void append_range_all_keyparts(Json_writer_array *range_trace,
static void print_key_value(String *out, const KEY_PART_INFO *key_part,
const uchar *key)
{
Field *field = key_part->field;
Field *field= key_part->field;
if (field->flags & BLOB_FLAG) {
if (field->flags & BLOB_FLAG)
{
// Byte 0 of a nullable key is the null-byte. If set, key is NULL.
if (field->real_maybe_null() && *key)
out->append(STRING_WITH_LEN("NULL"));
@ -15840,7 +15842,7 @@ static void print_key_value(String *out, const KEY_PART_INFO *key_part,
return;
}
uint store_length = key_part->store_length;
uint store_length= key_part->store_length;
if (field->real_maybe_null())
{
@ -15849,7 +15851,8 @@ static void print_key_value(String *out, const KEY_PART_INFO *key_part,
Otherwise, print the key value starting immediately after the
null-byte
*/
if (*key) {
if (*key)
{
out->append(STRING_WITH_LEN("NULL"));
return;
}
@ -15862,9 +15865,11 @@ static void print_key_value(String *out, const KEY_PART_INFO *key_part,
optimizer trace expects. If the column is binary, the hex
representation is printed to the trace instead.
*/
if (field->flags & BINARY_FLAG) {
if (field->flags & BINARY_FLAG)
{
out->append("0x");
for (uint i = 0; i < store_length; i++) {
for (uint i = 0; i < store_length; i++)
{
out->append(_dig_vec_lower[*(key + i) >> 4]);
out->append(_dig_vec_lower[*(key + i) & 0x0F]);
}
@ -15872,7 +15877,7 @@ static void print_key_value(String *out, const KEY_PART_INFO *key_part,
}
StringBuffer<128> tmp(system_charset_info);
TABLE *table = field->table;
TABLE *table= field->table;
my_bitmap_map *old_sets[2];
dbug_tmp_use_all_columns(table, old_sets, table->read_set, table->write_set);

View File

@ -456,6 +456,7 @@ void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables);
static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm,
Item_in_subselect *subq_pred);
@ -697,9 +698,10 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
if (arena)
thd->restore_active_arena(arena, &backup);
in_subs->is_registered_semijoin= TRUE;
OPT_TRACE_TRANSFORM(thd, oto0, oto1, select_lex->select_number,
OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
select_lex->select_number,
"IN (SELECT)", "semijoin");
oto1.add("chosen", true);
trace_transform.add("chosen", true);
}
}
else
@ -840,7 +842,7 @@ bool subquery_types_allow_materialization(THD* thd, Item_in_subselect *in_subs)
in_subs->types_allow_materialization= FALSE; // Assign default values
in_subs->sjm_scan_allowed= FALSE;
OPT_TRACE_TRANSFORM(thd, oto0, oto1,
OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
in_subs->get_select_lex()->select_number,
"IN (SELECT)", "materialization");
@ -856,8 +858,8 @@ bool subquery_types_allow_materialization(THD* thd, Item_in_subselect *in_subs)
if (!inner->type_handler()->subquery_type_allows_materialization(inner,
outer))
{
oto1.add("possible", false);
oto1.add("cause", "types mismatch");
trace_transform.add("possible", false);
trace_transform.add("cause", "types mismatch");
DBUG_RETURN(FALSE);
}
}
@ -879,12 +881,12 @@ bool subquery_types_allow_materialization(THD* thd, Item_in_subselect *in_subs)
{
in_subs->types_allow_materialization= TRUE;
in_subs->sjm_scan_allowed= all_are_fields;
oto1.add("sjm_scan_allowed", all_are_fields)
.add("possible", true);
trace_transform.add("sjm_scan_allowed", all_are_fields)
.add("possible", true);
DBUG_PRINT("info",("subquery_types_allow_materialization: ok, allowed"));
DBUG_RETURN(TRUE);
}
oto1.add("possible", false).add("cause", cause);
trace_transform.add("possible", false).add("cause", cause);
DBUG_RETURN(FALSE);
}
@ -1236,29 +1238,30 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
/* Stop processing if we've reached a subquery that's attached to the ON clause */
if (in_subq->do_not_convert_to_sj)
{
OPT_TRACE_TRANSFORM(thd, oto0, oto1,
OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
in_subq->get_select_lex()->select_number,
"IN (SELECT)", "semijoin");
oto1.add("converted_to_semi_join", false)
.add("cause", "subquery attached to the ON clause");
trace_transform.add("converted_to_semi_join", false)
.add("cause", "subquery attached to the ON clause");
break;
}
if (in_subq->is_flattenable_semijoin)
{
OPT_TRACE_TRANSFORM(thd, oto0, oto1,
OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
in_subq->get_select_lex()->select_number,
"IN (SELECT)", "semijoin");
if (join->table_count +
in_subq->unit->first_select()->join->table_count >= MAX_TABLES)
{
oto1.add("converted_to_semi_join", false);
oto1.add("cause", "table in parent join now exceeds MAX_TABLES");
trace_transform.add("converted_to_semi_join", false);
trace_transform.add("cause",
"table in parent join now exceeds MAX_TABLES");
break;
}
if (convert_subq_to_sj(join, in_subq))
goto restore_arena_and_fail;
oto1.add("converted_to_semi_join", true);
trace_transform.add("converted_to_semi_join", true);
}
else
{
@ -2380,6 +2383,8 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
THD *thd= join->thd;
List_iterator<TABLE_LIST> sj_list_it(join->select_lex->sj_nests);
TABLE_LIST *sj_nest;
if (!join->select_lex->sj_nests.elements)
DBUG_RETURN(FALSE);
Json_writer_object wrapper(thd);
Json_writer_object trace_semijoin_nest(thd,
"execution_plan_for_potential_materialization");
@ -2939,6 +2944,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
{
bool sjm_scan;
SJ_MATERIALIZATION_INFO *mat_info;
THD *thd= join->thd;
if ((mat_info= at_sjmat_pos(join, remaining_tables,
new_join_tab, idx, &sjm_scan)))
{
@ -3040,6 +3046,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
POSITION curpos, dummy;
/* Need to re-run best-access-path as we prefix_rec_count has changed */
bool disable_jbuf= (join->thd->variables.join_cache_level == 0);
Json_writer_temp_disable trace_semijoin_mat_scan(thd);
for (i= first_tab + mat_info->tables; i <= idx; i++)
{
best_access_path(join, join->positions[i].table, rem_tables, i,
@ -3590,6 +3597,12 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
table_map handled_tabs= 0;
join->sjm_lookup_tables= 0;
join->sjm_scan_tables= 0;
THD *thd= join->thd;
if (!join->select_lex->sj_nests.elements)
return;
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_semijoin_strategies(thd,
"fix_semijoin_strategies_for_picked_join_order");
for (tablenr= table_count - 1 ; tablenr != join->const_tables - 1; tablenr--)
{
POSITION *pos= join->best_positions + tablenr;
@ -3614,8 +3627,18 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
first= tablenr - sjm->tables + 1;
join->best_positions[first].n_sj_tables= sjm->tables;
join->best_positions[first].sj_strategy= SJ_OPT_MATERIALIZE;
Json_writer_object semijoin_strategy(thd);
semijoin_strategy.add("semi_join_strategy","sj_materialize");
Json_writer_array semijoin_plan(thd, "join_order");
for (uint i= first; i < first+ sjm->tables; i++)
{
if (unlikely(thd->trace_started()))
{
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(join->best_positions[i].table);
}
join->sjm_lookup_tables |= join->best_positions[i].table->table->map;
}
}
else if (pos->sj_strategy == SJ_OPT_MATERIALIZE_SCAN)
{
@ -3653,8 +3676,16 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
POSITION dummy;
join->cur_sj_inner_tables= 0;
Json_writer_object semijoin_strategy(thd);
semijoin_strategy.add("semi_join_strategy","sj_materialize_scan");
Json_writer_array semijoin_plan(thd, "join_order");
for (i= first + sjm->tables; i <= tablenr; i++)
{
if (unlikely(thd->trace_started()))
{
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(join->best_positions[i].table);
}
best_access_path(join, join->best_positions[i].table, rem_tables, i,
FALSE, prefix_rec_count,
join->best_positions + i, &dummy);
@ -3683,8 +3714,16 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
join buffering
*/
join->cur_sj_inner_tables= 0;
Json_writer_object semijoin_strategy(thd);
semijoin_strategy.add("semi_join_strategy","firstmatch");
Json_writer_array semijoin_plan(thd, "join_order");
for (idx= first; idx <= tablenr; idx++)
{
if (unlikely(thd->trace_started()))
{
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(join->best_positions[idx].table);
}
if (join->best_positions[idx].use_join_buffer)
{
best_access_path(join, join->best_positions[idx].table,
@ -3713,8 +3752,16 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
join buffering
*/
join->cur_sj_inner_tables= 0;
Json_writer_object semijoin_strategy(thd);
semijoin_strategy.add("semi_join_strategy","sj_materialize");
Json_writer_array semijoin_plan(thd, "join_order");
for (idx= first; idx <= tablenr; idx++)
{
if (unlikely(thd->trace_started()))
{
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(join->best_positions[idx].table);
}
if (join->best_positions[idx].use_join_buffer || (idx == first))
{
best_access_path(join, join->best_positions[idx].table,

View File

@ -525,7 +525,7 @@ eliminate_tables_for_list(JOIN *join,
table_map tables_in_list,
Item *on_expr,
table_map tables_used_elsewhere,
Json_writer_array* eliminate_tables);
Json_writer_array* trace_eliminate_tables);
static
bool check_func_dependency(JOIN *join,
table_map dep_tables,
@ -545,7 +545,7 @@ Dep_module_expr *merge_eq_mods(Dep_module_expr *start,
Dep_module_expr *new_fields,
Dep_module_expr *end, uint and_level);
static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl,
Json_writer_array* eliminate_tables);
Json_writer_array* trace_eliminate_tables);
static
void add_module_expr(Dep_analysis_context *dac, Dep_module_expr **eq_mod,
uint and_level, Dep_value_field *field_val, Item *right,
@ -671,12 +671,12 @@ void eliminate_tables(JOIN *join)
}
table_map all_tables= join->all_tables_map();
Json_writer_array eliminated_tables(thd,"eliminated_tables");
Json_writer_array trace_eliminated_tables(thd,"eliminated_tables");
if (all_tables & ~used_tables)
{
/* There are some tables that we probably could eliminate. Try it. */
eliminate_tables_for_list(join, join->join_list, all_tables, NULL,
used_tables, &eliminated_tables);
used_tables, &trace_eliminated_tables);
}
DBUG_VOID_RETURN;
}
@ -720,7 +720,7 @@ static bool
eliminate_tables_for_list(JOIN *join, List<TABLE_LIST> *join_list,
table_map list_tables, Item *on_expr,
table_map tables_used_elsewhere,
Json_writer_array *eliminate_tables)
Json_writer_array *trace_eliminate_tables)
{
TABLE_LIST *tbl;
List_iterator<TABLE_LIST> it(*join_list);
@ -742,9 +742,10 @@ eliminate_tables_for_list(JOIN *join, List<TABLE_LIST> *join_list,
&tbl->nested_join->join_list,
tbl->nested_join->used_tables,
tbl->on_expr,
outside_used_tables, eliminate_tables))
outside_used_tables,
trace_eliminate_tables))
{
mark_as_eliminated(join, tbl, eliminate_tables);
mark_as_eliminated(join, tbl, trace_eliminate_tables);
}
else
all_eliminated= FALSE;
@ -756,7 +757,7 @@ eliminate_tables_for_list(JOIN *join, List<TABLE_LIST> *join_list,
check_func_dependency(join, tbl->table->map, NULL, tbl,
tbl->on_expr))
{
mark_as_eliminated(join, tbl, eliminate_tables);
mark_as_eliminated(join, tbl, trace_eliminate_tables);
}
else
all_eliminated= FALSE;
@ -1797,7 +1798,7 @@ Dep_module* Dep_value_field::get_next_unbound_module(Dep_analysis_context *dac,
*/
static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl,
Json_writer_array* eliminate_tables)
Json_writer_array* trace_eliminate_tables)
{
TABLE *table;
/*
@ -1810,7 +1811,7 @@ static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl,
TABLE_LIST *child;
List_iterator<TABLE_LIST> it(tbl->nested_join->join_list);
while ((child= it++))
mark_as_eliminated(join, child, eliminate_tables);
mark_as_eliminated(join, child, trace_eliminate_tables);
}
else if ((table= tbl->table))
{
@ -1821,7 +1822,7 @@ static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl,
tab->type= JT_CONST;
tab->table->const_table= 1;
join->eliminated_tables |= table->map;
eliminate_tables->add(table->alias.c_ptr_safe());
trace_eliminate_tables->add(table->alias.c_ptr_safe());
join->const_table_map|= table->map;
set_position(join, join->const_tables++, tab, (KEYUSE*)0);
}

View File

@ -24,7 +24,7 @@
#include "my_json_writer.h"
#include "sp_head.h"
const char I_S_table_name[] = "OPTIMIZER_TRACE";
const char I_S_table_name[]= "OPTIMIZER_TRACE";
/**
Whether a list of tables contains information_schema.OPTIMIZER_TRACE.
@ -38,7 +38,7 @@ const char I_S_table_name[] = "OPTIMIZER_TRACE";
*/
bool list_has_optimizer_trace_table(const TABLE_LIST *tbl)
{
for (; tbl; tbl = tbl->next_global)
for (; tbl; tbl= tbl->next_global)
{
if (tbl->schema_table &&
0 == strcmp(tbl->schema_table->table_name, I_S_table_name))
@ -59,14 +59,15 @@ bool sets_var_optimizer_trace(enum enum_sql_command sql_command,
{
List_iterator_fast<set_var_base> it(*set_vars);
const set_var_base *var;
while ((var = it++))
while ((var= it++))
if (var->is_var_optimizer_trace()) return true;
}
return false;
}
ST_FIELD_INFO optimizer_trace_info[] = {
ST_FIELD_INFO optimizer_trace_info[]=
{
/* name, length, type, value, maybe_null, old_name, open_method */
{"QUERY", 65535, MYSQL_TYPE_STRING, 0, false, NULL, SKIP_OPEN_TABLE},
{"TRACE", 65535, MYSQL_TYPE_STRING, 0, false, NULL, SKIP_OPEN_TABLE},
@ -74,12 +75,13 @@ ST_FIELD_INFO optimizer_trace_info[] = {
SKIP_OPEN_TABLE},
{"INSUFFICIENT_PRIVILEGES", 1, MYSQL_TYPE_TINY, 0, false, NULL,
SKIP_OPEN_TABLE},
{NULL, 0, MYSQL_TYPE_STRING, 0, true, NULL, 0}};
{NULL, 0, MYSQL_TYPE_STRING, 0, true, NULL, 0}
};
/*
TODO: one-line needs to be implemented seperately
*/
const char *Opt_trace_context::flag_names[] = {"enabled", "default",
const char *Opt_trace_context::flag_names[]= {"enabled", "default",
NullS};
/*
@ -105,15 +107,15 @@ void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex,
{
if (!thd->trace_started())
return;
char buff[1024];
String str(buff, sizeof(buff), system_charset_info);
str.length(0);
StringBuffer<1024> str(system_charset_info);
ulonglong save_option_bits= thd->variables.option_bits;
thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE;
select_lex->print(thd, &str,
enum_query_type(QT_TO_SYSTEM_CHARSET |
QT_SHOW_SELECT_NUMBER |
QT_ITEM_IDENT_SKIP_DB_NAMES |
QT_VIEW_INTERNAL
));
QT_VIEW_INTERNAL));
thd->variables.option_bits= save_option_bits;
/*
The output is not very pretty lots of back-ticks, the output
is as the one in explain extended , lets try to improved it here.
@ -141,7 +143,7 @@ void opt_trace_disable_if_no_security_context_access(THD *thd)
*/
return;
}
Opt_trace_context *const trace = &thd->opt_trace;
Opt_trace_context *const trace= &thd->opt_trace;
if (!thd->trace_started())
{
/*
@ -187,7 +189,6 @@ void opt_trace_disable_if_no_security_context_access(THD *thd)
thd->main_security_ctx.priv_host,
thd->security_context()->priv_host)))
trace->missing_privilege();
return;
}
void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp)
@ -197,17 +198,16 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp)
thd->system_thread)
return;
Opt_trace_context *const trace = &thd->opt_trace;
Opt_trace_context *const trace= &thd->opt_trace;
if (!thd->trace_started())
return;
bool full_access;
Security_context *const backup_thd_sctx = thd->security_context();
Security_context *const backup_thd_sctx= thd->security_context();
thd->set_security_context(&thd->main_security_ctx);
const bool rc = check_show_routine_access(thd, sp, &full_access) || !full_access;
const bool rc= check_show_routine_access(thd, sp, &full_access) || !full_access;
thd->set_security_context(backup_thd_sctx);
if (rc)
trace->missing_privilege();
return;
}
/**
@ -231,16 +231,16 @@ void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl)
if (likely(!(thd->variables.optimizer_trace &
Opt_trace_context::FLAG_ENABLED)) || thd->system_thread)
return;
Opt_trace_context *const trace = &thd->opt_trace;
Opt_trace_context *const trace= &thd->opt_trace;
if (!thd->trace_started())
return;
Security_context *const backup_thd_sctx = thd->security_context();
Security_context *const backup_thd_sctx= thd->security_context();
thd->set_security_context(&thd->main_security_ctx);
const TABLE_LIST *const first_not_own_table = thd->lex->first_not_own_table();
for (TABLE_LIST *t = tbl; t != NULL && t != first_not_own_table;
t = t->next_global)
const TABLE_LIST *const first_not_own_table= thd->lex->first_not_own_table();
for (TABLE_LIST *t= tbl; t != NULL && t != first_not_own_table;
t= t->next_global)
{
/*
Anonymous derived tables (as in
@ -248,9 +248,9 @@ void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl)
*/
if (!t->is_anonymous_derived_table())
{
const GRANT_INFO backup_grant_info = t->grant;
Security_context *const backup_table_sctx = t->security_ctx;
t->security_ctx = NULL;
const GRANT_INFO backup_grant_info= t->grant;
Security_context *const backup_table_sctx= t->security_ctx;
t->security_ctx= NULL;
/*
(1) check_table_access() fills t->grant.privilege.
(2) Because SELECT privileges can be column-based,
@ -271,8 +271,8 @@ void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl)
*/
rc |= check_table_access(thd, SHOW_VIEW_ACL, t, false, 1, true);
}
t->security_ctx = backup_table_sctx;
t->grant = backup_grant_info;
t->security_ctx= backup_table_sctx;
t->grant= backup_grant_info;
if (rc)
{
trace->missing_privilege();
@ -292,22 +292,22 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view,
Opt_trace_context::FLAG_ENABLED)) ||
thd->system_thread)
return;
Opt_trace_context *const trace = &thd->opt_trace;
Opt_trace_context *const trace= &thd->opt_trace;
if (!thd->trace_started())
return;
Security_context *const backup_table_sctx = view->security_ctx;
Security_context *const backup_thd_sctx = thd->security_context();
const GRANT_INFO backup_grant_info = view->grant;
Security_context *const backup_table_sctx= view->security_ctx;
Security_context *const backup_thd_sctx= thd->security_context();
const GRANT_INFO backup_grant_info= view->grant;
view->security_ctx = NULL; // no SUID context for view
view->security_ctx= NULL; // no SUID context for view
// no SUID context for THD
thd->set_security_context(&thd->main_security_ctx);
const int rc = check_table_access(thd, SHOW_VIEW_ACL, view, false, 1, true);
const int rc= check_table_access(thd, SHOW_VIEW_ACL, view, false, 1, true);
view->security_ctx = backup_table_sctx;
view->security_ctx= backup_table_sctx;
thd->set_security_context(backup_thd_sctx);
view->grant = backup_grant_info;
view->grant= backup_grant_info;
if (rc)
{
@ -347,16 +347,13 @@ class Opt_trace_stmt {
~Opt_trace_stmt()
{
delete current_json;
missing_priv= false;
ctx= NULL;
I_S_disabled= 0;
}
void set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset);
void open_struct(const char *key, char opening_bracket);
void close_struct(const char *saved_key, char closing_bracket);
void fill_info(Opt_trace_info* info);
void add(const char *key, char *opening_bracket, size_t val_length);
Json_writer* get_current_json(){return current_json;}
Json_writer* get_current_json() {return current_json;}
void missing_privilege();
void disable_tracing_for_children();
void enable_tracing_for_children();
@ -372,6 +369,12 @@ private:
String query; // store the query sent by the user
Json_writer *current_json; // stores the trace
bool missing_priv; ///< whether user lacks privilege to see this trace
/*
0 <=> this trace should be in information_schema.
!=0 tracing is disabled, this currently happens when we want to trace a
sub-statement. For now traces are only collect for the top statement
not for the sub-statments.
*/
uint I_S_disabled;
};
@ -440,28 +443,11 @@ bool Opt_trace_context::is_enabled()
Opt_trace_context::Opt_trace_context()
{
current_trace= NULL;
inited= FALSE;
traces= NULL;
max_mem_size= 0;
}
Opt_trace_context::~Opt_trace_context()
{
inited= FALSE;
/*
would be nice to move this to a function
*/
if (traces)
{
while (traces->elements())
{
Opt_trace_stmt *prev= traces->at(0);
delete prev;
traces->del(0);
}
delete traces;
traces= NULL;
}
max_mem_size= 0;
delete_traces();
}
void Opt_trace_context::set_query(const char *query, size_t length, const CHARSET_INFO *charset)
@ -487,26 +473,21 @@ void Opt_trace_context::start(THD *thd, TABLE_LIST *tbl,
DBUG_ASSERT(!current_trace);
current_trace= new Opt_trace_stmt(this);
max_mem_size= max_mem_size_arg;
if (!inited)
{
traces= new Dynamic_array<Opt_trace_stmt*>();
inited= TRUE;
}
set_allowed_mem_size(remaining_mem_size());
}
void Opt_trace_context::end()
{
if (current_trace)
traces->push(current_trace);
traces.push(current_trace);
if (!traces->elements())
if (!traces.elements())
return;
if (traces->elements() > 1)
if (traces.elements() > 1)
{
Opt_trace_stmt *prev= traces->at(0);
Opt_trace_stmt *prev= traces.at(0);
delete prev;
traces->del(0);
traces.del(0);
}
current_trace= NULL;
}
@ -522,7 +503,7 @@ Opt_trace_start::Opt_trace_start(THD *thd, TABLE_LIST *tbl,
if optimizer trace is enabled and the statment we have is traceable,
then we start the context.
*/
const ulonglong var = thd->variables.optimizer_trace;
const ulonglong var= thd->variables.optimizer_trace;
traceable= FALSE;
if (unlikely(var & Opt_trace_context::FLAG_ENABLED) &&
sql_command_can_be_traced(sql_command) &&
@ -554,21 +535,21 @@ Opt_trace_start::~Opt_trace_start()
void Opt_trace_stmt::fill_info(Opt_trace_info* info)
{
if (unlikely(info->missing_priv = get_missing_priv()))
if (unlikely(info->missing_priv= get_missing_priv()))
{
info->trace_ptr = info->query_ptr = "";
info->trace_length = info->query_length = 0;
info->query_charset = &my_charset_bin;
info->missing_bytes = 0;
info->trace_ptr= info->query_ptr= "";
info->trace_length= info->query_length= 0;
info->query_charset= &my_charset_bin;
info->missing_bytes= 0;
}
else
{
info->trace_ptr = current_json->output.get_string()->ptr();
info->trace_length = get_length();
info->query_ptr = query.ptr();
info->query_length = query.length();
info->query_charset = query.charset();
info->missing_bytes = get_truncated_bytes();
info->trace_ptr= current_json->output.get_string()->ptr();
info->trace_length= get_length();
info->query_ptr= query.ptr();
info->query_length= query.length();
info->query_charset= query.charset();
info->missing_bytes= get_truncated_bytes();
info->missing_priv= get_missing_priv();
}
}
@ -659,9 +640,7 @@ void Json_writer::add_str(Item *item)
if (item)
{
THD *thd= current_thd;
char buff[256];
String str(buff, sizeof(buff), system_charset_info);
str.length(0);
StringBuffer<256> str(system_charset_info);
ulonglong save_option_bits= thd->variables.option_bits;
thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE;
@ -675,26 +654,23 @@ void Json_writer::add_str(Item *item)
add_null();
}
void Opt_trace_context::flush_optimizer_trace()
void Opt_trace_context::delete_traces()
{
inited= false;
if (traces)
if (traces.elements())
{
while (traces->elements())
while (traces.elements())
{
Opt_trace_stmt *prev= traces->at(0);
Opt_trace_stmt *prev= traces.at(0);
delete prev;
traces->del(0);
traces.del(0);
}
delete traces;
traces= NULL;
}
}
int fill_optimizer_trace_info(THD *thd, TABLE_LIST *tables, Item *)
{
TABLE *table = tables->table;
TABLE *table= tables->table;
Opt_trace_info info;
/* get_values of trace, query , missing bytes and missing_priv
@ -703,7 +679,7 @@ int fill_optimizer_trace_info(THD *thd, TABLE_LIST *tables, Item *)
*/
Opt_trace_context* ctx= &thd->opt_trace;
if (thd->opt_trace.empty())
if (!thd->opt_trace.empty())
{
Opt_trace_stmt *stmt= ctx->get_top_trace();
stmt->fill_info(&info);

View File

@ -193,9 +193,16 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp);
*/
int fill_optimizer_trace_info(THD *thd, TABLE_LIST *tables, Item *);
#define OPT_TRACE_TRANSFORM(writer, object_level0, object_level1, \
#define OPT_TRACE_TRANSFORM(thd, object_level0, object_level1, \
select_number, from, to) \
Json_writer_object object_level0(writer); \
Json_writer_object object_level1(writer, "transformation"); \
Json_writer_object object_level0(thd); \
Json_writer_object object_level1(thd, "transformation"); \
object_level1.add_select_number(select_number).add("from", from).add("to", to);
#endif
#define OPT_TRACE_VIEWS_TRANSFORM(thd, object_level0, object_level1, \
derived, name, select_number, algorithm) \
Json_writer_object trace_wrapper(thd); \
Json_writer_object trace_derived(thd, derived); \
trace_derived.add("table", name).add_select_number(select_number) \
.add("algorithm", algorithm);
#endif

View File

@ -19,14 +19,14 @@ public:
ulong max_mem_size_arg);
void end();
void set_query(const char *query, size_t length, const CHARSET_INFO *charset);
void flush_optimizer_trace();
void delete_traces();
void set_allowed_mem_size(size_t mem_size);
size_t remaining_mem_size();
private:
Opt_trace_stmt* top_trace()
{
return *(traces->front());
return *(traces.front());
}
public:
@ -39,7 +39,7 @@ public:
Opt_trace_stmt* get_top_trace()
{
if (!traces || !traces->elements())
if (!traces.elements())
return NULL;
return top_trace();
}
@ -52,7 +52,7 @@ public:
bool empty()
{
return traces && (static_cast<uint>(traces->elements()) != 0);
return static_cast<uint>(traces.elements()) == 0;
}
bool is_started()
@ -79,13 +79,8 @@ private:
/*
List of traces (currently it stores only 1 trace)
*/
Dynamic_array<Opt_trace_stmt*> *traces;
Dynamic_array<Opt_trace_stmt*> traces;
Opt_trace_stmt *current_trace;
/*
TRUE: if we allocate memory for list of traces
FALSE: otherwise
*/
bool inited;
size_t max_mem_size;
};

View File

@ -434,7 +434,7 @@ TABLE::best_range_rowid_filter_for_partial_join(uint access_key_no,
double records,
double access_cost_factor)
{
if (!this || range_rowid_filter_cost_info_elems == 0 ||
if (range_rowid_filter_cost_info_elems == 0 ||
covering_keys.is_set(access_key_no))
return 0;

View File

@ -1412,7 +1412,7 @@ void THD::change_user(void)
sp_cache_clear(&sp_func_cache);
sp_cache_clear(&sp_package_spec_cache);
sp_cache_clear(&sp_package_body_cache);
opt_trace.flush_optimizer_trace();
opt_trace.delete_traces();
}
/**
@ -5988,7 +5988,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
binlog by filtering rules.
*/
#ifdef WITH_WSREP
if (WSREP_CLIENT_NNULL(this) && variables.wsrep_trx_fragment_size > 0)
if (WSREP_CLIENT_NNULL(this) && wsrep_thd_is_local(this) &&
variables.wsrep_trx_fragment_size > 0)
{
if (!is_current_stmt_binlog_format_row())
{

View File

@ -34,6 +34,7 @@
#include "sql_class.h"
#include "sql_cte.h"
#include "my_json_writer.h"
#include "opt_trace.h"
typedef bool (*dt_processor)(THD *thd, LEX *lex, TABLE_LIST *derived);
@ -384,6 +385,15 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
{
/* There is random function => fall back to materialization. */
cause= "Random function in the select";
if (unlikely(thd->trace_started()))
{
OPT_TRACE_VIEWS_TRANSFORM(thd, trace_wrapper, trace_derived,
derived->is_derived() ? "derived" : "view",
derived->alias.str ? derived->alias.str : "<NULL>",
derived->get_unit()->first_select()->select_number,
"materialized");
trace_derived.add("cause", cause);
}
derived->change_refs_to_fields();
derived->set_materialized_derived();
DBUG_RETURN(FALSE);
@ -497,19 +507,12 @@ unconditional_materialization:
if (unlikely(thd->trace_started()))
{
/*
Add to the optimizer trace the change in choice for merged
derived tables/views to materialised ones.
*/
Json_writer_object trace_wrapper(thd);
Json_writer_object trace_derived(thd, derived->is_derived() ?
"derived" : "view");
trace_derived.add("table", derived->alias.str ? derived->alias.str : "<NULL>")
.add_select_number(derived->get_unit()->
first_select()->select_number)
.add("initial_choice", "merged")
.add("final_choice", "materialized")
.add("cause", cause);
OPT_TRACE_VIEWS_TRANSFORM(thd,trace_wrapper, trace_derived,
derived->is_derived() ? "derived" : "view",
derived->alias.str ? derived->alias.str : "<NULL>",
derived->get_unit()->first_select()->select_number,
"materialized");
trace_derived.add("cause", cause);
}
derived->change_refs_to_fields();
@ -778,15 +781,11 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
Add to optimizer trace whether a derived table/view
is merged into the parent select or not.
*/
Json_writer_object trace_wrapper(thd);
Json_writer_object trace_derived(thd, derived->is_derived() ?
"derived" : "view");
trace_derived.add("table", derived->alias.str ? derived->alias.str : "<NULL>")
.add_select_number(derived->get_unit()->first_select()->select_number);
if (derived->is_materialized_derived())
trace_derived.add("materialized", true);
if (derived->is_merged_derived())
trace_derived.add("merged", true);
OPT_TRACE_VIEWS_TRANSFORM(thd, trace_wrapper, trace_derived,
derived->is_derived() ? "derived" : "view",
derived->alias.str ? derived->alias.str : "<NULL>",
derived->get_unit()->first_select()->select_number,
derived->is_merged_derived() ? "merged" : "materialized");
}
/*
Above cascade call of prepare is important for PS protocol, but after it

View File

@ -1729,11 +1729,23 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
case COM_STMT_BULK_EXECUTE:
{
mysqld_stmt_bulk_execute(thd, packet, packet_length);
#ifdef WITH_WSREP
if (WSREP_ON)
{
(void)wsrep_after_statement(thd);
}
#endif /* WITH_WSREP */
break;
}
case COM_STMT_EXECUTE:
{
mysqld_stmt_execute(thd, packet, packet_length);
#ifdef WITH_WSREP
if (WSREP_ON)
{
(void)wsrep_after_statement(thd);
}
#endif /* WITH_WSREP */
break;
}
case COM_STMT_FETCH:

View File

@ -359,11 +359,6 @@
data dictionary without changing table rows
*/
#define IS_EQUAL_PACK_LENGTH 2
/**
new_field has a representation that is compatible with the old type
when the storage engine advertises HA_EXTENDED_TYPES_CONVERSION
*/
#define IS_EQUAL_PACK_LENGTH_EXT 3
enum enum_parsing_place
{

View File

@ -121,6 +121,7 @@ static bool best_extension_by_limited_search(JOIN *join,
double read_time, uint depth,
uint prune_level,
uint use_cond_selectivity);
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables);
static uint determine_search_depth(JOIN* join);
C_MODE_START
static int join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2);
@ -302,8 +303,6 @@ void set_postjoin_aggr_write_func(JOIN_TAB *tab);
static Item **get_sargable_cond(JOIN *join, TABLE *table);
static void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables);
#ifndef DBUG_OFF
/*
@ -359,16 +358,16 @@ static void trace_table_dependencies(THD *thd,
{
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_dep(thd, "table_dependencies");
for (uint i = 0; i < table_count; i++)
for (uint i= 0; i < table_count; i++)
{
TABLE_LIST *table_ref = join_tabs[i].tab_list;
TABLE_LIST *table_ref= join_tabs[i].tab_list;
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(&join_tabs[i]);
trace_one_table.add("row_may_be_null",
(bool)table_ref->table->maybe_null);
const table_map map = table_ref->get_map();
const table_map map= table_ref->get_map();
DBUG_ASSERT(map < (1ULL << table_count));
for (uint j = 0; j < table_count; j++)
for (uint j= 0; j < table_count; j++)
{
if (map & (1ULL << j))
{
@ -377,14 +376,10 @@ static void trace_table_dependencies(THD *thd,
}
}
Json_writer_array depends_on(thd, "depends_on_map_bits");
static_assert(sizeof(table_ref->get_map()) <= 64,
"RAND_TABLE_BIT may be in join_tabs[i].dependent, so we test "
"all 64 bits.");
for (uint j = 0; j < 64; j++)
{
if (join_tabs[i].dependent & (1ULL << j))
depends_on.add(static_cast<longlong>(j));
}
Table_map_iterator it(join_tabs[i].dependent);
uint dep_bit;
while ((dep_bit= it++) != Table_map_iterator::BITMAP_END)
depends_on.add(static_cast<longlong>(dep_bit));
}
}
@ -9082,13 +9077,13 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
}
static void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables)
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables)
{
THD *const thd = join->thd;
THD *const thd= join->thd;
Json_writer_array plan_prefix(thd, "plan_prefix");
for (uint i = 0; i < idx; i++)
for (uint i= 0; i < idx; i++)
{
TABLE_LIST *const tr = join->positions[i].table->tab_list;
TABLE_LIST *const tr= join->positions[i].table->tab_list;
if (!(tr->map & remaining_tables))
plan_prefix.add_table_name(join->positions[i].table);
}
@ -9298,9 +9293,6 @@ best_extension_by_limited_search(JOIN *join,
current_record_count / (double) TIME_FOR_COMPARE -
filter_cmp_gain;
/*
TODO add filtering estimates here
*/
advance_sj_state(join, remaining_tables, idx, &current_record_count,
&current_read_time, &loose_scan_pos);
@ -11107,12 +11099,6 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
tab->table->intersect_keys.is_set(tab->ref.key))))
{
/* Range uses longer key; Use this instead of ref on key */
/*
We can trace here, changing ref access to range access here
have a range that uses longer key.
Lets take @spetrunia's opinion
*/
Json_writer_object ref_to_range(thd);
ref_to_range.add("ref_to_range", true);
ref_to_range.add("cause", "range uses longer key");
@ -16455,6 +16441,8 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
double cost, rec_count;
table_map reopt_remaining_tables= last_remaining_tables;
uint i;
THD *thd= join->thd;
Json_writer_temp_disable trace_wo_join_buffering(thd);
if (first_tab > join->const_tables)
{
@ -16489,7 +16477,7 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
{
JOIN_TAB *rs= join->positions[i].table;
POSITION pos, loose_scan_pos;
if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer)
{
/* Find the best access method that would not use join buffering */

View File

@ -6605,9 +6605,6 @@ static bool fill_alter_inplace_info(THD *thd,
*/
ha_alter_info->handler_flags|= ALTER_COLUMN_EQUAL_PACK_LENGTH;
break;
case IS_EQUAL_PACK_LENGTH_EXT:
ha_alter_info->handler_flags|= ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT;
break;
default:
DBUG_ASSERT(0);
/* Safety. */

View File

@ -665,11 +665,11 @@ void print_keyuse_array_for_trace(THD *thd, DYNAMIC_ARRAY *keyuse_array)
KEYUSE *keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, i);
Json_writer_object keyuse_elem(thd);
keyuse_elem.add_table_name(keyuse->table->reginfo.join_tab);
keyuse_elem.add("field", (keyuse->keypart == FT_KEYPART) ? "<fulltext>"
: (keyuse->is_for_hash_join()
? keyuse->table->field[keyuse->keypart]
->field_name.str
: keyuse->table->key_info[keyuse->key]
keyuse_elem.add("field", (keyuse->keypart == FT_KEYPART) ? "<fulltext>":
(keyuse->is_for_hash_join() ?
keyuse->table->field[keyuse->keypart]
->field_name.str :
keyuse->table->key_info[keyuse->key]
.key_part[keyuse->keypart]
.field->field_name.str));
keyuse_elem.add("equals",keyuse->val);

View File

@ -474,7 +474,7 @@ bool check_has_super(sys_var *self, THD *thd, set_var *var)
static Sys_var_bit Sys_core_file("core_file", "write a core-file on crashes",
READ_ONLY GLOBAL_VAR(test_flags), NO_CMD_LINE,
TEST_CORE_ON_SIGNAL, DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
TEST_CORE_ON_SIGNAL, DEFAULT(IF_WIN(TRUE,FALSE)), NO_MUTEX_GUARD, NOT_IN_BINLOG,
0,0,0);
static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
@ -5937,7 +5937,7 @@ static Sys_var_ulong Sys_histogram_size(
"Number of bytes used for a histogram. "
"If set to 0, no histograms are created by ANALYZE.",
SESSION_VAR(histogram_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 255), DEFAULT(0), BLOCK_SIZE(1));
VALID_RANGE(0, 255), DEFAULT(254), BLOCK_SIZE(1));
extern const char *histogram_types[];
static Sys_var_enum Sys_histogram_type(
@ -5947,7 +5947,7 @@ static Sys_var_enum Sys_histogram_type(
"SINGLE_PREC_HB - single precision height-balanced, "
"DOUBLE_PREC_HB - double precision height-balanced.",
SESSION_VAR(histogram_type), CMD_LINE(REQUIRED_ARG),
histogram_types, DEFAULT(0));
histogram_types, DEFAULT(1));
static Sys_var_mybool Sys_no_thread_alarm(
"debug_no_thread_alarm",

View File

@ -229,8 +229,12 @@ size_t Wsrep_client_service::bytes_generated() const
IO_CACHE* cache= wsrep_get_trans_cache(m_thd);
if (cache)
{
m_thd->binlog_flush_pending_rows_event(true);
return my_b_tell(cache);
size_t pending_rows_event_length= 0;
if (Rows_log_event* ev= m_thd->binlog_get_pending_rows_event(true))
{
pending_rows_event_length= ev->get_data_size();
}
return my_b_tell(cache) + pending_rows_event_length;
}
return 0;
}

View File

@ -176,10 +176,12 @@ void Wsrep_server_service::log_view(
{
Wsrep_id id;
Wsrep_view prev_view= wsrep_schema->restore_view(applier->m_thd, id);
bool checkpoint_was_reset= false;
if (prev_view.state_id().id() != view.state_id().id())
{
WSREP_DEBUG("New cluster UUID was generated, resetting position info");
wsrep_set_SE_checkpoint(wsrep::gtid::undefined());
checkpoint_was_reset= true;
}
if (wsrep_debug)
@ -188,7 +190,7 @@ void Wsrep_server_service::log_view(
os << "Storing cluster view:\n" << view;
WSREP_INFO("%s", os.str().c_str());
DBUG_ASSERT(prev_view.state_id().id() != view.state_id().id() ||
view.state_id().seqno() > prev_view.state_id().seqno());
view.state_id().seqno().get() >= prev_view.state_id().seqno().get());
}
if (trans_begin(applier->m_thd, MYSQL_START_TRANS_OPT_READ_WRITE))
@ -216,7 +218,21 @@ void Wsrep_server_service::log_view(
applier->m_thd->mdl_context.release_transactional_locks();
}
wsrep_set_SE_checkpoint(view.state_id());
/*
Backwards compatibility: When running in mixed cluster with
Galera 3.x, the provider does not generate unique sequence numbers
for views. This condition can be checked by inspecting last
committed as returned by the provider. If the last_committed
matches to view state_id seqno, the cluster runs in backwards
compatibility mode and we skip setting the checkpoint for
view.
*/
wsrep::seqno last_committed=
Wsrep_server_state::instance().provider().last_committed_gtid().seqno();
if (checkpoint_was_reset || last_committed != view.state_id().seqno())
{
wsrep_set_SE_checkpoint(view.state_id());
}
DBUG_ASSERT(wsrep_get_SE_checkpoint().id() == view.state_id().id());
}
else

View File

@ -337,7 +337,7 @@ static int generate_binlog_index_opt_val(char** ret)
{
DBUG_ASSERT(ret);
*ret= NULL;
if (opt_bin_log)
if (opt_binlog_index_name)
{
*ret= strcmp(opt_binlog_index_name, "0") ?
my_strdup(opt_binlog_index_name, MYF(0)) : my_strdup("", MYF(0));

View File

@ -83,6 +83,14 @@ static inline bool wsrep_streaming_enabled(THD* thd)
return (thd->wsrep_sr().fragment_size() > 0);
}
/*
Return number of fragments succesfully certified for the
current statement.
*/
static inline size_t wsrep_fragments_certified_for_stmt(THD* thd)
{
return thd->wsrep_trx().fragments_certified_for_statement();
}
static inline int wsrep_start_transaction(THD* thd, wsrep_trx_id_t trx_id)
{

View File

@ -757,7 +757,7 @@ static int show_var_cmp(const void *var1, const void *var2)
{
return strcasecmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
}
#endif /* UNUSED */
/*
* Status variables stuff below
*/
@ -780,6 +780,7 @@ wsrep_assign_to_mysql (SHOW_VAR* mysql, wsrep_stats_var* wsrep_var)
break;
}
}
#endif /* UNUSED */
#if DYNAMIC
// somehow this mysql status thing works only with statically allocated arrays.

View File

@ -4839,9 +4839,7 @@ n_field_mismatch:
if (len_is_stored(len)
&& (field->prefix_len
? len > field->prefix_len
: (fixed_size && (page_is_comp(page)
? len != fixed_size
: len > fixed_size)))) {
: (fixed_size && len != fixed_size))) {
len_mismatch:
btr_index_rec_validate_report(page, rec, index);
ib::error error;

View File

@ -486,14 +486,8 @@ incompatible:
For the metadata record, variable-length columns are
always written with zero length. The DB_TRX_ID will
start right after any fixed-length columns. */
if (index->table->not_redundant()) {
for (uint i = index->n_uniq; i--; ) {
trx_id_offset += index->fields[i]
.fixed_len;
}
} else {
trx_id_offset = rec_get_field_start_offs(
rec, index->n_uniq);
for (uint i = index->n_uniq; i--; ) {
trx_id_offset += index->fields[i].fixed_len;
}
}

View File

@ -100,22 +100,6 @@ dtype_validate(
return(TRUE);
}
bool dict_col_t::same_charset(const dict_col_t& other) const
{
if (dtype_is_non_binary_string_type(mtype, prtype)
&& dtype_is_non_binary_string_type(other.mtype, other.prtype)) {
uint csn1 = (uint) dtype_get_charset_coll(prtype);
uint csn2 = (uint) dtype_get_charset_coll(other.prtype);
CHARSET_INFO* cs1 = get_charset(csn1, MYF(MY_WME));
CHARSET_INFO* cs2 = get_charset(csn2, MYF(MY_WME));
if (!my_charset_same(cs1, cs2)) {
return false;
}
}
return true;
}
#ifdef UNIV_DEBUG
/** Print a data type structure.
@param[in] type data type */

View File

@ -2203,14 +2203,6 @@ dict_index_too_big_for_tree(
}
field_max_size = dict_col_get_max_size(col);
if (!comp && (col->mtype == DATA_INT
|| col->mtype == DATA_CHAR
|| col->mtype == DATA_FIXBINARY)) {
/* DATA_INT, DATA_FIXBINARY and DATA_CHAR are variable-
length (enlarged instantly), but are stored locally. */
field_ext_max_size = 0;
goto add_field_size;
}
field_ext_max_size = field_max_size < 256 ? 1 : 2;
if (field->prefix_len) {

View File

@ -9977,7 +9977,7 @@ innobase_fts_create_doc_id_key(
/* The unique Doc ID field should be an eight-bytes integer */
dict_field_t* field = dict_index_get_nth_field(index, 0);
ut_a(field->col->mtype == DATA_INT);
ut_ad(sizeof(*doc_id) == field->col->len);
ut_ad(sizeof(*doc_id) == field->fixed_len);
ut_ad(!strcmp(index->name, FTS_DOC_ID_INDEX_NAME));
#endif /* UNIV_DEBUG */

View File

@ -135,7 +135,6 @@ static const alter_table_operations INNOBASE_ALTER_INSTANT
| ALTER_ADD_VIRTUAL_COLUMN
| INNOBASE_FOREIGN_OPERATIONS
| ALTER_COLUMN_EQUAL_PACK_LENGTH
| ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT
| ALTER_COLUMN_UNVERSIONED
| ALTER_DROP_VIRTUAL_COLUMN;
@ -270,7 +269,7 @@ inline void dict_table_t::prepare_instant(const dict_table_t& old,
ut_ad(!not_redundant());
for (unsigned i = index.n_fields; i--; ) {
ut_ad(index.fields[i].col->same_format(
*oindex.fields[i].col, true));
*oindex.fields[i].col));
}
}
#endif
@ -458,13 +457,9 @@ inline void dict_index_t::instant_add_field(const dict_index_t& instant)
as this index. Fields for any added columns are appended at the end. */
#ifndef DBUG_OFF
for (unsigned i = 0; i < n_fields; i++) {
DBUG_ASSERT(fields[i].prefix_len
== instant.fields[i].prefix_len);
DBUG_ASSERT(fields[i].fixed_len
== instant.fields[i].fixed_len
|| !table->not_redundant());
DBUG_ASSERT(instant.fields[i].col->same_format(
*fields[i].col, !table->not_redundant()));
DBUG_ASSERT(fields[i].same(instant.fields[i]));
DBUG_ASSERT(instant.fields[i].col->same_format(*fields[i]
.col));
/* Instant conversion from NULL to NOT NULL is not allowed. */
DBUG_ASSERT(!fields[i].col->is_nullable()
|| instant.fields[i].col->is_nullable());
@ -540,7 +535,10 @@ inline bool dict_table_t::instant_column(const dict_table_t& table,
if (const dict_col_t* o = find(old_cols, col_map, n_cols, i)) {
c.def_val = o->def_val;
ut_ad(c.same_format(*o, !not_redundant()));
DBUG_ASSERT(!((c.prtype ^ o->prtype)
& ~(DATA_NOT_NULL | DATA_VERSIONED)));
DBUG_ASSERT(c.mtype == o->mtype);
DBUG_ASSERT(c.len >= o->len);
if (o->vers_sys_start()) {
ut_ad(o->ind == vers_start);
@ -1752,10 +1750,6 @@ ha_innobase::check_if_supported_inplace_alter(
{
DBUG_ENTER("check_if_supported_inplace_alter");
DBUG_ASSERT(!(ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT
& ha_alter_info->handler_flags)
|| !m_prebuilt->table->not_redundant());
if ((ha_alter_info->handler_flags
& INNOBASE_ALTER_VERSIONED_REBUILD)
&& altered_table->versioned(VERS_TIMESTAMP)) {
@ -2951,7 +2945,7 @@ innobase_col_to_mysql(
switch (col->mtype) {
case DATA_INT:
ut_ad(len <= flen);
ut_ad(len == flen);
/* Convert integer data from Innobase to little-endian
format, sign bit restored to normal */
@ -4122,7 +4116,7 @@ innobase_check_foreigns(
@param[in,out] heap Memory heap where allocated
@param[out] dfield InnoDB data field to copy to
@param[in] field MySQL value for the column
@param[in] old_field Old field or NULL if new col is added
@param[in] old_field Old column if altering; NULL for ADD COLUMN
@param[in] comp nonzero if in compact format. */
static void innobase_build_col_map_add(
mem_heap_t* heap,
@ -4141,14 +4135,13 @@ static void innobase_build_col_map_add(
return;
}
ulint size = field->pack_length();
const Field& from = old_field ? *old_field : *field;
ulint size = from.pack_length();
byte* buf = static_cast<byte*>(mem_heap_alloc(heap, size));
const byte* mysql_data = old_field ? old_field->ptr : field->ptr;
row_mysql_store_col_in_innobase_format(
dfield, buf, true, mysql_data, size, comp);
dfield, buf, true, from.ptr, size, comp);
}
/** Construct the translation table for reordering, dropping or
@ -5547,6 +5540,11 @@ static bool innobase_instant_try(
dict_table_get_col_name(user_table, i)));
DBUG_ASSERT(old || col->is_added());
ut_d(const Create_field* new_field = cf_it++);
/* new_field->field would point to an existing column.
If it is NULL, the column was added by this ALTER TABLE. */
ut_ad(!new_field->field == !old);
if (col->is_added()) {
dfield_set_data(d, col->def_val.data,
col->def_val.len);
@ -5580,18 +5578,14 @@ static bool innobase_instant_try(
mem_heap_alloc(ctx->heap, len))
: NULL, true, (*af)->ptr, len,
dict_table_is_comp(user_table));
ut_ad(new_field->field->pack_length() == len);
}
}
ut_d(const Create_field* new_field = cf_it++);
/* new_field->field would point to an existing column.
If it is NULL, the column was added by this ALTER TABLE. */
ut_ad(!new_field->field == !old);
bool update = old && (!ctx->first_alter_pos
|| i < ctx->first_alter_pos - 1);
ut_ad(!old || col->same_format(
*old, !user_table->not_redundant()));
DBUG_ASSERT(!old || col->same_format(*old));
if (update
&& old->prtype == d->type.prtype) {
/* The record is already present in SYS_COLUMNS. */
@ -5680,8 +5674,6 @@ add_all_virtual:
NULL, trx, ctx->heap, NULL);
dberr_t err = DB_SUCCESS;
DBUG_EXECUTE_IF("ib_instant_error",
err = DB_OUT_OF_FILE_SPACE; goto func_exit;);
if (rec_is_metadata(rec, *index)) {
ut_ad(page_rec_is_user_rec(rec));
if (!page_has_next(block->frame)
@ -8748,7 +8740,6 @@ innobase_rename_column_try(
const char* to,
bool new_clustered)
{
pars_info_t* info;
dberr_t error;
DBUG_ENTER("innobase_rename_column_try");
@ -8762,7 +8753,6 @@ innobase_rename_column_try(
goto rename_foreign;
}
info = pars_info_create();
error = DB_SUCCESS;
trx->op_info = "renaming column in SYS_FIELDS";
@ -8789,8 +8779,7 @@ innobase_rename_column_try(
continue;
}
info = pars_info_create();
pars_info_t* info = pars_info_create();
ulint pos = has_prefixes ? i << 16 | f.prefix_len : i;
pars_info_add_ull_literal(info, "indexid", index->id);
@ -8843,7 +8832,7 @@ rename_foreign:
continue;
}
info = pars_info_create();
pars_info_t* info = pars_info_create();
pars_info_add_str_literal(info, "id", foreign->id);
pars_info_add_int4_literal(info, "nth", i);
@ -8885,7 +8874,7 @@ rename_foreign:
continue;
}
info = pars_info_create();
pars_info_t* info = pars_info_create();
pars_info_add_str_literal(info, "id", foreign->id);
pars_info_add_int4_literal(info, "nth", i);
@ -9016,7 +9005,6 @@ static void get_type(const Field& f, ulint& prtype, ulint& mtype, ulint& len)
@param table_name Table name in MySQL
@param pos 0-based index to user_table->cols[] or user_table->v_cols[]
@param f new column
@param cf column modification
@param is_v if it's a virtual column
@retval true Failure
@retval false Success */
@ -9028,7 +9016,6 @@ innobase_rename_or_enlarge_column_try(
const char* table_name,
ulint pos,
const Field& f,
const Create_field& cf,
bool is_v)
{
dict_col_t* col;
@ -9052,7 +9039,7 @@ innobase_rename_or_enlarge_column_try(
ulint prtype, mtype, len;
get_type(f, prtype, mtype, len);
DBUG_ASSERT(!dtype_is_string_type(col->mtype)
|| col->mbminlen == cf.charset->mbminlen);
|| col->mbminlen == f.charset()->mbminlen);
DBUG_ASSERT(col->len <= len);
#ifdef UNIV_DEBUG
@ -9064,7 +9051,7 @@ innobase_rename_or_enlarge_column_try(
and ROW_FORMAT is not REDUNDANT and mbminlen<mbmaxlen.
That is, we treat a UTF-8 CHAR(n) column somewhat like
a VARCHAR. */
ut_ad(!user_table->not_redundant() || col->len == len);
ut_ad(col->len == len);
break;
case DATA_BINARY:
case DATA_VARCHAR:
@ -9072,11 +9059,6 @@ innobase_rename_or_enlarge_column_try(
case DATA_DECIMAL:
case DATA_BLOB:
break;
case DATA_INT:
if (!user_table->not_redundant()) {
break;
}
/* fall through */
default:
ut_ad(col->prtype == prtype);
ut_ad(col->mtype == mtype);
@ -9132,7 +9114,6 @@ innobase_rename_or_enlarge_columns_try(
if (!(ha_alter_info->handler_flags
& (ALTER_COLUMN_EQUAL_PACK_LENGTH
| ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT
| ALTER_COLUMN_NAME))) {
DBUG_RETURN(false);
}
@ -9152,7 +9133,7 @@ innobase_rename_or_enlarge_columns_try(
if (cf->field == *fp) {
if (innobase_rename_or_enlarge_column_try(
ctx->old_table, trx, table_name,
idx, **af, *cf, is_v)) {
idx, **af, is_v)) {
DBUG_RETURN(true);
}
break;
@ -9181,7 +9162,6 @@ innobase_rename_or_enlarge_columns_cache(
{
if (!(ha_alter_info->handler_flags
& (ALTER_COLUMN_EQUAL_PACK_LENGTH
| ALTER_COLUMN_EQUAL_PACK_LENGTH_EXT
| ALTER_COLUMN_NAME))) {
return;
}
@ -9208,8 +9188,6 @@ innobase_rename_or_enlarge_columns_cache(
->m_col
: dict_table_get_nth_col(user_table, col_n);
const bool is_string= dtype_is_string_type(col->mtype);
DBUG_ASSERT(!is_string
|| (*af)->charset() == cf->charset);
DBUG_ASSERT(col->mbminlen
== (is_string
? (*af)->charset()->mbminlen : 0));
@ -9227,7 +9205,7 @@ innobase_rename_or_enlarge_columns_cache(
dict_mem_table_col_rename(
user_table, col_n,
cf->field->field_name.str,
cf->field_name.str, is_virtual);
(*af)->field_name.str, is_virtual);
}
break;

View File

@ -472,18 +472,12 @@ dtype_get_fixed_size_low(
}
#endif /* UNIV_DEBUG */
/* fall through */
case DATA_CHAR:
case DATA_FIXBINARY:
case DATA_INT:
case DATA_FLOAT:
case DATA_DOUBLE:
return(len);
case DATA_FIXBINARY:
case DATA_CHAR:
case DATA_INT:
/* Treat these types as variable length for redundant
row format. We can't rely on fixed_len anymore because record
can have shorter length from before instant enlargement
[MDEV-15563]. Note, that importing such tablespace to
earlier MariaDB versions produces ER_TABLE_SCHEMA_MISMATCH. */
return comp ? len : 0;
case DATA_MYSQL:
if (prtype & DATA_BINARY_TYPE) {
return(len);
@ -631,14 +625,6 @@ dtype_get_sql_null_size(
const dtype_t* type, /*!< in: type */
ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */
{
switch (type->mtype) {
case DATA_INT:
case DATA_CHAR:
case DATA_FIXBINARY:
return(type->len);
default:
break;
}
return(dtype_get_fixed_size_low(type->mtype, type->prtype, type->len,
type->mbminlen, type->mbmaxlen, comp));
}

View File

@ -682,52 +682,18 @@ public:
def_val.data = NULL;
}
private:
/** Determine if the columns have the same character set
@param[in] other column to compare to
@return whether the columns have the same character set */
bool same_charset(const dict_col_t& other) const;
public:
/** Determine if the columns have the same format
except for is_nullable() and is_versioned().
@param[in] other column to compare to
@param[in] redundant table is redundant row format
@return whether the columns have the same format */
bool same_format(const dict_col_t& other, bool redundant = false) const
bool same_format(const dict_col_t& other) const
{
if (len < other.len
|| mbminlen != other.mbminlen
|| mbmaxlen != other.mbmaxlen) {
return false;
}
if (!((prtype ^ other.prtype)
& ~(DATA_NOT_NULL | DATA_VERSIONED))) {
return mtype == other.mtype;
}
if (redundant) {
switch (other.mtype) {
case DATA_CHAR:
case DATA_MYSQL:
case DATA_VARCHAR:
case DATA_VARMYSQL:
return (mtype == DATA_CHAR
|| mtype == DATA_MYSQL
|| mtype == DATA_VARCHAR
|| mtype == DATA_VARMYSQL)
&& same_charset(other);
case DATA_FIXBINARY:
case DATA_BINARY:
return (mtype == DATA_FIXBINARY
|| mtype == DATA_BINARY)
&& same_charset(other);
case DATA_INT:
return mtype == DATA_INT;
}
}
return false;
return mtype == other.mtype
&& len >= other.len
&& mbminlen == other.mbminlen
&& mbmaxlen == other.mbmaxlen
&& !((prtype ^ other.prtype)
& ~(DATA_NOT_NULL | DATA_VERSIONED));
}
};

View File

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2018, MariaDB Corporation.
Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -706,6 +706,11 @@ row_merge_buf_add(
row_field, field, col->len,
old_table->space->zip_size(),
conv_heap);
} else {
/* Field length mismatch should not
happen when rebuilding redundant row
format table. */
ut_ad(index->table->not_redundant());
}
}
}

View File

@ -887,15 +887,10 @@ row_create_prebuilt(
== MAX_REF_PARTS););
uint temp_len = 0;
for (uint i = 0; i < temp_index->n_uniq; i++) {
const dict_field_t& f = temp_index->fields[i];
if (f.col->mtype == DATA_INT) {
ut_ad(f.col->len >= f.fixed_len);
/* dtype_get_fixed_size_low() returns 0
for ROW_FORMAT=REDUNDANT */
ut_ad(table->not_redundant()
? f.col->len == f.fixed_len
: f.fixed_len == 0);
temp_len += f.col->len;
ulint type = temp_index->fields[i].col->mtype;
if (type == DATA_INT) {
temp_len +=
temp_index->fields[i].fixed_len;
}
}
srch_key_len = std::max(srch_key_len,temp_len);

View File

@ -2723,8 +2723,6 @@ row_sel_field_store_in_mysql_format_func(
switch (templ->type) {
const byte* field_end;
case DATA_CHAR:
case DATA_FIXBINARY:
case DATA_VARCHAR:
case DATA_VARMYSQL:
case DATA_BINARY:
@ -2822,8 +2820,7 @@ row_sel_field_store_in_mysql_format_func(
ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len
|| (field_no == templ->icp_rec_field_no
&& field->prefix_len > 0)
|| templ->rec_field_is_prefix
|| !index->table->not_redundant());
|| templ->rec_field_is_prefix);
ut_ad(templ->is_virtual
|| !(field->prefix_len % templ->mbmaxlen));
@ -2845,6 +2842,8 @@ row_sel_field_store_in_mysql_format_func(
ut_ad(0);
/* fall through */
case DATA_CHAR:
case DATA_FIXBINARY:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_DECIMAL:
@ -2859,18 +2858,13 @@ row_sel_field_store_in_mysql_format_func(
case DATA_INT:
/* Convert InnoDB big-endian integer to little-endian
format, sign bit restored to 2's complement form */
DBUG_ASSERT(templ->mysql_col_len >= len);
DBUG_ASSERT(templ->mysql_col_len == len);
byte* ptr = pad;
do *--ptr = *data++; while (ptr != dest);
byte b = templ->is_unsigned || !((pad[-1] ^= 0x80) & 0x80)
? 0 : 0xff;
if (ulint l = templ->mysql_col_len - len) {
DBUG_ASSERT(!index->table->not_redundant());
memset(pad, b, l);
if (!templ->is_unsigned) {
pad[-1] ^= 0x80;
}
break;
}
}

@ -1 +1 @@
Subproject commit af8383daf03bee80b8e54ce207fa9ef1f9d83f94
Subproject commit 92024c7d502b716c8c0ca5e2b9524b43d3a5378c